tazpkg annotate tazpkg @ rev 744

Store sidebar settings in the session cookies (browser sets, changes, and sends them automatically); use "<button>" tag instead of "<a>" and "<input type='button'>" to show buttons (it allows to translate button captions, and provides uniform look of buttons); "list" and "tag" commands shows short description about what is really listed; "tag" respects repo; "blocked" shows blocked packages; small style change; encode COPYING in UTF-8.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jan 09 17:05:12 2015 +0200 (2015-01-09)
parents 21e01cc4fa1f
children 1d6e23a2782f
rev   line source
pankso@6 1 #!/bin/sh
pankso@646 2 #
pankso@646 3 # TazPKG - Tiny autonomous zone packages manager.
pankso@6 4 #
paul@662 5 # This is a lightweight packages manager for *.tazpkg files written in SHell
pankso@646 6 # script. It works well with Busybox ash shell and bash. TazPKG lets you
pankso@646 7 # list, install, remove, download or get information about a package. You
pankso@646 8 # can use 'tazpkg usage' to get a list of commands with short descriptions.
pankso@646 9 # TazPKG also resolves dependencies and can upgrade packages from a mirror.
pankso@6 10 #
pankso@646 11 # (C) 2007-2014 SliTaz - GNU General Public License v3.
pankso@6 12 #
al@633 13 # Authors: See the AUTHORS files
pankso@27 14 #
pankso@6 15
pankso@6 16 ####################
pankso@6 17 # Script variables #
pankso@6 18 ####################
pankso@6 19
pankso@653 20 # TazPKG version
pascal@703 21 VERSION=5.3.3
pankso@586 22
slaxemulator@588 23 . /etc/slitaz/slitaz.conf
pankso@307 24 . /etc/slitaz/tazpkg.conf
pankso@6 25
pankso@590 26 . /lib/libtaz.sh
pankso@661 27 . /usr/lib/slitaz/libpkg.sh
al@695 28 . /usr/lib/tazpkg/tazpkg-find-depends
pankso@590 29
pankso@595 30 # Internationalization.
al@694 31 export TEXTDOMAIN='tazpkg'
al@707 32 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
al@707 33 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
al@707 34 _p() {
al@707 35 local S="$1" P="$2" N="$3"; shift; shift; shift;
al@707 36 printf "$(ngettext "$S" "$P" "$N")" "$@"; }
al@694 37
pankso@343 38
al@603 39 #
al@603 40 # Functions set for translate categories
al@603 41 #
pankso@646 42
al@694 43
al@603 44 # Make array of pre-translated categories
al@694 45
al@603 46 cat_i18n=""
al@707 47 for c in "base-system" "x-window" "utilities" "network" "graphics" \
al@707 48 "multimedia" "office" "development" "system-tools" "security" "games" \
al@707 49 "misc" "meta" "non-free"; do
al@603 50 cat_i18n="$cat_i18n
al@603 51 $(gettext "$c") $c"
al@603 52 done
al@694 53
al@694 54
al@701 55 # Translate category names (must be last in line)
al@701 56
al@701 57 translate_category()
al@701 58 {
al@701 59 sed "s|base-system$|$(_ base-system)|g; s|x-window$|$(_ x-window)|g;
al@701 60 s|utilities$|$(_ utilities)|g; s|network$|$(_ network)|g;
al@701 61 s|graphics$|$(_ graphics)|g; s|multimedia$|$(_ multimedia)|g;
al@701 62 s|office$|$(_ office)|g; s|development$|$(_ development)|g;
al@701 63 s|system-tools$|$(_ system-tools)|g; s|security$|$(_ security)|g;
al@701 64 s|games$|$(_ games)|g; s|misc$|$(_ misc)|g; s|meta$|$(_ meta)|g;
al@701 65 s|non-free$|$(_ non-free)|g"
al@701 66 }
al@701 67
al@701 68
al@603 69 # If category is not one of those translated in native language, keep it
al@603 70 # untranslated. This allows both native and english language support.
al@603 71 # This also supports custom categories.
al@603 72 # And now we support spaces in translated categories
al@694 73
al@603 74 reverse_translate_category()
al@603 75 {
al@603 76 echo "$cat_i18n" | awk "BEGIN{FS=\" \"}{if (/^$@ /) a=\$2}END{if (a==\"\") a=\"$@\"; print a}"
al@603 77 }
al@603 78
al@694 79
al@694 80
al@603 81 #
pankso@653 82 # TazPKG output functions
al@603 83 #
al@694 84
al@694 85
al@603 86 # Print localized title
al@694 87
al@702 88 title() { newline; boldify "$(_ "$@")"; separator; }
al@694 89
al@694 90
al@603 91 # Print footer
al@694 92
al@694 93 footer() { separator; echo "$1"; [ -n "$1" ] && newline; }
al@694 94
al@694 95
al@603 96 # Print current action in brown color (separate from any other msgs)
al@694 97
al@603 98 action() {
al@603 99 case $output in
psychomaniak@708 100 raw|gtk|html) _n "$@" ;;
al@702 101 *) echo -ne "\033[0;33m"$(_ "$@")"\033[0m" ;;
al@603 102 esac
al@603 103 }
al@603 104
al@694 105
pankso@307 106 # Initialize some variables to use words rather than numbers for functions
pankso@307 107 # and actions.
pankso@6 108 COMMAND=$1
pascal@427 109 PACKAGE=${2%/}
slaxemulator@530 110 PACKAGE_DIR="$(cd $(dirname $PACKAGE 2>/dev/null) 2>/dev/null; pwd)"
al@694 111 [ -n "$PACKAGE" ] && PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
pascal@427 112 if [ -f "$PACKAGE" ]; then
pankso@10 113 # Set pkg basename for install, extract
al@694 114 PACKAGE=$(basename $PACKAGE .tazpkg 2>/dev/null)
pankso@10 115 else
pankso@10 116 # Pkg name for remove, search and all other cmds
pascal@427 117 PACKAGE=${PACKAGE%.tazpkg}
pankso@10 118 fi
pankso@6 119 TARGET_DIR=$3
al@694 120 TOP_DIR=$(pwd)
al@605 121 TMP_DIR=/tmp/$RANDOM
pankso@307 122 INSTALL_LIST=""
gokhlayeh@419 123 SAVE_CACHE_DIR="$CACHE_DIR"
pankso@6 124
pankso@6 125 # Path to tazpkg used dir and configuration files
al@700 126 MIRROR=$PKGS_DB/mirror
al@700 127 BLOCKED=$PKGS_DB/blocked-packages.list
al@700 128 UP_LIST=$PKGS_DB/packages.up
slaxemulator@588 129 DEFAULT_MIRROR="$ONLINE_PKGS"
pankso@6 130
pascal@515 131
al@694 132
al@694 133
pankso@6 134 ####################
pankso@6 135 # Script functions #
pankso@6 136 ####################
pankso@6 137
al@694 138
al@717 139 # Interactive mode
al@717 140
al@717 141 im() { tty -s; }
al@717 142
al@717 143
pankso@6 144 # Print the usage.
al@694 145
al@603 146 usage () {
al@603 147 cat << EOT
pankso@600 148
al@702 149 $(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))
al@694 150
al@694 151 $(boldify "$(_ 'Usage:')")
al@694 152 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
al@694 153
al@694 154 $(boldify "$(_ 'SHell:')") tazpkg shell
al@694 155
al@694 156 $(boldify "$(_ 'Commands:')")
al@707 157 $(optlist "\
al@707 158 usage $(_ 'Print this short usage')
al@707 159 bugs $(_ 'Show known bugs in packages')
al@707 160 -a activity $(_ 'Show TazPkg activity log')
al@707 161 -l list $(_ 'List installed packages on the system')
al@707 162 -lm list-mirror $(_ 'List all available packages on the mirror')
al@707 163 info $(_ 'Print information about a package')
al@707 164 desc $(_ 'Print description of a package')
al@707 165 -lf list-files $(_ 'List the files installed with a package')
al@707 166 list-config $(_ 'List the configuration files')
al@707 167
al@707 168 -s search $(_ 'Search for a package by pattern or name')
al@707 169 search-pkgname $(_ 'Search on mirror for package having a particular file')
al@707 170 -sf search-file $(_ 'Search for file in all installed packages files')
al@707 171
al@707 172 get $(_ 'Download a package into the current directory')
al@707 173 -gi get-install $(_ 'Download and install a package from the mirror')
al@707 174 get-install-list $(_ 'Download and install a list of packages from the mirror')
al@707 175 -i install $(_ 'Install a local package')
al@707 176 install-list $(_ 'Install all packages from a list of packages')
al@707 177 -r remove $(_ 'Remove the specified package and all installed files')
al@707 178 -e extract $(_ 'Extract a (*.tazpkg) package into a directory')
al@707 179 pack $(_ 'Pack an unpacked or prepared package tree')
al@707 180
al@707 181 recharge $(_ 'Recharge your packages.list from the mirror')
al@707 182 up|help-up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
al@707 183
al@707 184 repack $(_ 'Create a package archive from an installed package')
al@707 185 repack-config $(_ 'Create a package archive with configuration files')
al@707 186 recompress $(_ 'Rebuild a package with a better compression ratio')
al@707 187 block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
al@707 188 check $(_ 'Verify consistency of installed packages')
al@707 189
al@707 190 add-flavor $(_ 'Install the flavor list of packages')
al@707 191 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
al@707 192
al@707 193 set-release $(_ 'Change release and update packages')
al@707 194 -cc clean-cache $(_ 'Clean all packages downloaded in cache directory')
al@707 195
al@707 196 depends $(_ 'Display dependencies tree')
al@707 197 rdepends $(_ 'Display reverse dependencies tree')
al@707 198
al@707 199 convert $(_ 'Convert alien package to tazpkg')
al@707 200 link $(_ 'Link a package from another slitaz installation')
al@707 201
al@707 202 -sm setup-mirror $(_ 'Change the mirror url configuration')
al@707 203 list-undigest $(_ 'List undigest mirrors')
al@707 204 remove-undigest $(_ 'Remove an undigest mirror')
al@707 205 add-undigest $(_ 'Add an undigest mirror')
al@707 206 setup-undigest $(_ 'Update an undigest mirror')
al@707 207
al@707 208 reconfigure $(_ 'Replay post install script from package')
al@707 209 ")
al@603 210 EOT
pankso@6 211 }
pankso@6 212
al@694 213
pankso@464 214 usage_up() {
al@603 215 cat << EOT
al@694 216 $(emsg "<b>$(_ 'Usage for command up:')</b>") tazpkg up [$(_ 'option')]
al@694 217
al@707 218 * $(longline "$(_ 'Without options run in interactive mode and ask before install')")
al@694 219
al@694 220 $(boldify "$(_ 'Where options are:')")
al@707 221 $(optlist "\
al@707 222 -c --check $(_ 'Check only for available upgrades')
al@707 223 -r --recharge $(_ 'Force recharge of packages list and check')
al@707 224 -i --install $(_ 'Check for upgrades and install them all')
al@707 225 ")
al@694 226
al@694 227 $(boldify "$(_ 'Example:')")
pankso@464 228 tazpkg up --recharge --install
pankso@464 229 tazpkg up -c -r
al@603 230 EOT
pankso@464 231 }
pankso@464 232
al@694 233
paul@662 234 # Check if dir exists
al@694 235
pankso@584 236 check_dir()
pankso@584 237 {
pankso@584 238 if ! [ -d "$1" ]; then
al@707 239 action 'Creating folder "%s"...' "$1"
al@707 240 mkdir -p "$1"
pankso@584 241 status
pankso@584 242 return 1
pankso@584 243 fi
pankso@584 244 }
pankso@584 245
al@694 246
pankso@653 247 # Check if the directories and files used by TazPKG
pankso@590 248 # exist. If not and user is root we create them.
al@694 249
pankso@590 250 check_base_dir()
pankso@590 251 {
al@603 252 if [ "$(id -u)" = "0" ]; then
pankso@590 253 check_dir $1$CACHE_DIR
pankso@590 254 check_dir $1$INSTALLED
pankso@594 255 check_dir $1$SLITAZ_LOGS
al@700 256 if [ ! -f "$1$PKGS_DB/mirror" ]; then
al@700 257 echo "${DEFAULT_MIRROR%/}/" > $1$PKGS_DB/mirror
al@700 258 [ -n "$1" ] && cp $PKGS_DB/packages.* $1$PKGS_DB/
pankso@590 259 fi
pankso@590 260 fi
pankso@590 261 }
pankso@590 262 check_base_dir
pankso@590 263
al@694 264
pankso@6 265 # Check for a package name on cmdline.
al@694 266
pankso@6 267 check_for_package_on_cmdline()
pankso@6 268 {
pankso@6 269 if [ -z "$PACKAGE" ]; then
pankso@600 270 newline
al@694 271 _ 'Please specify a package name on the command line.'
pankso@600 272 newline
al@707 273 exit 1
pankso@6 274 fi
pankso@6 275 }
pankso@6 276
al@694 277
paul@437 278 # Check if the package (*.tazpkg) exists before installing or extracting.
al@694 279
pankso@6 280 check_for_package_file()
pankso@6 281 {
pankso@9 282 if [ ! -f "$PACKAGE_FILE" ]; then
pankso@600 283 newline
al@702 284 _ 'Unable to find file "%s"' $PACKAGE_FILE
al@603 285 newline
al@707 286 exit 1
pankso@6 287 fi
pankso@6 288 }
pankso@6 289
al@694 290
pankso@6 291 # Check for the receipt of an installed package.
al@694 292
pankso@6 293 check_for_receipt()
pankso@6 294 {
al@707 295 if [ ! -f "$1$INSTALLED/$PACKAGE/receipt" ]; then
pankso@600 296 newline
al@707 297 _ 'Unable to find the receipt "%s"' "$1$INSTALLED/$PACKAGE/receipt"
al@603 298 newline
al@707 299 exit 1
pankso@6 300 fi
pankso@6 301 }
pankso@6 302
al@694 303
al@700 304 # Get repositories priority using $PKGS_DB/priority.
gokhlayeh@386 305 # In this files, undigest are called by their name and main mirror
al@633 306 # by main. Sort order: priority
al@694 307
gokhlayeh@386 308 look_for_priority()
gokhlayeh@386 309 {
al@700 310 [ -s $PKGS_DB/priority ] && priority=$(cat $PKGS_DB/priority)
al@700 311 for rep in main $(ls $PKGS_DB/undigest 2>/dev/null); do
al@700 312 if [ ! -s $PKGS_DB/priority ] || \
al@700 313 ! grep -q ^$rep$ $PKGS_DB/priority; then
al@694 314 priority=$(echo -e "$priority\n$rep")
al@694 315 fi
al@694 316 done
al@694 317 priority=$(echo "$priority" | sed '/^$/d' | \
al@694 318 while read line; do
al@694 319 if [ "$line" = main ]; then
al@700 320 echo $PKGS_DB
al@694 321 else
al@700 322 echo $PKGS_DB/undigest/$line
al@694 323 fi
al@694 324 done)
gokhlayeh@386 325 }
gokhlayeh@386 326
al@694 327
pascal@110 328 # Get package name in a directory
al@694 329
pascal@110 330 package_fullname_in_dir()
pascal@110 331 {
gokhlayeh@407 332 [ -f $1/receipt ] || return
pascal@114 333 EXTRAVERSION=""
gokhlayeh@407 334 . $1/receipt
pascal@110 335 echo $PACKAGE-$VERSION$EXTRAVERSION
pascal@110 336 }
pascal@110 337
al@694 338
pascal@110 339 # Get package name that is already installed.
al@694 340
pascal@110 341 get_installed_package_pathname()
pascal@110 342 {
pascal@121 343 for i in $2$INSTALLED/${1%%-*}*; do
pascal@115 344 [ -d $i ] || continue
gokhlayeh@407 345 if [ "$1" = "$(package_fullname_in_dir $i)" ]; then
pascal@110 346 echo $i
pascal@110 347 return
pascal@110 348 fi
pascal@110 349 done
pascal@110 350 }
pascal@110 351
al@694 352
pankso@6 353 # Check if a package is already installed.
al@694 354
pankso@6 355 check_for_installed_package()
pankso@6 356 {
pascal@121 357 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
pankso@600 358 newline
al@702 359 _ '"%s" package is already installed.' $(colorize 34 $PACKAGE)
al@707 360 longline "$(_ 'You can use the --forced option to force installation.')"
al@603 361 newline
al@603 362 exit 0
pankso@6 363 fi
pankso@6 364 }
pankso@6 365
al@694 366
pankso@6 367 # Check for packages.list to download and install packages.
al@694 368
pankso@6 369 check_for_packages_list()
pankso@6 370 {
al@700 371 list_path="$PKGS_DB/packages.list"
al@633 372 if [ ! -f "$list_path" ]; then
pankso@71 373 if test $(id -u) = 0 ; then
pankso@71 374 tazpkg recharge
pankso@71 375 else
pankso@600 376 newline
al@702 377 _ 'Unable to find the list "%s"' $list_path
al@694 378 _ \
pankso@344 379 "You must probably run 'tazpkg recharge' as root to get the latest list of
al@694 380 packages available on the mirror."
al@603 381 newline
al@603 382 exit 0
pankso@71 383 fi
pankso@6 384 fi
pankso@6 385 }
pankso@6 386
al@694 387
al@701 388 # Check for installed.info - local file with format of packages.info
al@707 389 # "installed.info" is absent on not clean installs; check it and re-generate if needed.
al@701 390
al@701 391 check_for_installed_info()
al@701 392 {
al@701 393 info_path="$PKGS_DB/installed.info"
al@701 394 if [ ! -f "$info_path" ]; then
al@701 395 if [ "$(id -u)" == "0" ]; then
al@702 396 _ 'File "%s" generated. Please wait...' installed.info
al@701 397 for pkg in $PKGS_DB/installed/*/receipt; do
al@701 398 unset_receipt
al@701 399 . $pkg
al@701 400 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
al@701 401 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
al@701 402 cat >> $info_path << EOT
al@701 403 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS
al@701 404 EOT
al@701 405 done
al@701 406 else
al@702 407 _ 'Unable to find file "%s"' installed.info
al@701 408 _ 'Please run tazpkg as root.'
al@701 409 exit 1
al@701 410 fi
al@701 411 fi
al@701 412 }
al@701 413
al@701 414
gokhlayeh@419 415 get_cache_dir()
gokhlayeh@419 416 {
gokhlayeh@419 417 echo $rep > $tmp/rep
al@700 418 if [ "$rep" = "$PKGS_DB" ]; then
pankso@586 419 CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_RELEASE/packages"
gokhlayeh@419 420 elif [ "${rep%-incoming}" = "$rep" ]; then
gokhlayeh@419 421 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
gokhlayeh@419 422 else
gokhlayeh@419 423 rep="${rep%-incoming}"
gokhlayeh@419 424 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming"
gokhlayeh@419 425 fi
gokhlayeh@419 426 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
gokhlayeh@419 427 echo $CACHE_DIR > $tmp/cachedir
gokhlayeh@419 428 }
gokhlayeh@419 429
al@694 430
pascal@261 431 # get an already installed package from packages.equiv
al@694 432
pascal@226 433 equivalent_pkg()
pascal@226 434 {
al@700 435 for i in $(grep -hs "^$1=" $PKGS_DB/packages.equiv \
al@700 436 $PKGS_DB/undigest/*/packages.equiv | sed "s/^$1=//"); do
gokhlayeh@409 437 if echo $i | fgrep -q : ; then
pascal@226 438 # format 'alternative:newname'
pascal@226 439 # if alternative is installed then substitute newname
pascal@226 440 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
paul@662 441 # substitute package dependency
pascal@226 442 echo ${i#*:}
pascal@226 443 return
pascal@226 444 fi
pascal@226 445 else
pascal@226 446 # if alternative is installed then nothing to install
pascal@241 447 if [ -f $2$INSTALLED/$i/receipt ]; then
pascal@226 448 # substitute installed package
pascal@226 449 echo $i
pascal@226 450 return
pascal@226 451 fi
pascal@226 452 fi
pascal@226 453 done
pascal@226 454 # if not found in packages.equiv then no substitution
pascal@226 455 echo $1
pascal@226 456 }
pascal@226 457
al@694 458
pascal@261 459 # get a virtual package from packages.equiv
al@694 460
pascal@261 461 virtual_pkg()
pascal@261 462 {
pankso@598 463 for i in $(for rep in $priority; do
gokhlayeh@386 464 grep -hs "^$1=" $rep/packages.equiv
gokhlayeh@386 465 done | sed "s/^$1=//"); do
gokhlayeh@409 466 if echo $i | fgrep -q : ; then
pascal@261 467 # format 'alternative:newname'
pascal@261 468 # if alternative is installed then substitute newname
pascal@261 469 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
paul@662 470 # substitute package dependency
pascal@261 471 echo ${i#*:}
pascal@261 472 return
pascal@261 473 fi
pascal@261 474 else
pascal@262 475 # unconditional substitution
pascal@261 476 echo $i
pascal@261 477 return
pascal@261 478 fi
pascal@261 479 done
pascal@261 480 }
pascal@261 481
al@694 482
pascal@190 483 # Get package filename available on the mirror
al@694 484
pascal@190 485 get_package_filename()
pascal@190 486 {
pascal@190 487 local pkg
gokhlayeh@386 488 for rep in $priority; do
al@694 489 pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | sed 's/^ *//')
al@694 490 [ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" $rep/packages.list | head -1)
pankso@598 491
gokhlayeh@387 492 # Allow user to call a package with his version number.
gokhlayeh@387 493 [ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1)
pankso@598 494
al@694 495 [ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" $rep/packages.list | head -1)
al@694 496 [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" $rep/packages.list | head -1)
gokhlayeh@419 497 [ "$pkg" ] && get_cache_dir && break
gokhlayeh@386 498 done
pascal@226 499 if [ -z "$pkg" ]; then
paul@662 500 # Check for virtual package
pascal@226 501 local equiv
pascal@261 502 equiv=$(virtual_pkg $1)
pascal@226 503 if [ "$equiv" != "$1" ]; then
pascal@226 504 PACKAGE=$equiv
pascal@226 505 get_package_filename $PACKAGE
pascal@226 506 return
pascal@226 507 fi
pascal@226 508 fi
pascal@190 509 echo $pkg
pascal@190 510 }
pascal@190 511
al@694 512
pankso@6 513 # Check for a package in packages.list. Used by get and get-install to grep
pankso@6 514 # package basename.
al@694 515
pankso@6 516 check_for_package_in_list()
pankso@6 517 {
pascal@190 518 local filename
pascal@202 519 local check_only
pascal@202 520 check_only="$1"
gokhlayeh@416 521 filename=$(get_package_filename $PACKAGE)
gokhlayeh@419 522 if [ "$filename" ]; then
pascal@190 523 PACKAGE=$filename
gokhlayeh@419 524 CACHE_DIR=$(cat $tmp/cachedir)
gokhlayeh@419 525 rep=$(cat $tmp/rep)
gokhlayeh@419 526 rm -f $tmp/rep $tmp/cachedir
pankso@6 527 else
pankso@600 528 newline
al@702 529 _ 'Unable to find package "%s" in the mirrored packages list.' $PACKAGE
pankso@600 530 newline
pascal@202 531 [ -n "$check_only" ] && return 1
pankso@6 532 exit 0
pankso@6 533 fi
pankso@6 534 }
pankso@6 535
al@694 536
pascal@183 537 # Log this activity
al@603 538 # (there log_pkg because we have log() in libtaz.sh)
al@694 539
al@603 540 log_pkg()
pascal@183 541 {
pascal@207 542 local extra
al@694 543
pascal@207 544 [ "$1" = "Installed" ] && \
al@700 545 extra=" - $(fgrep $PACKAGE-$VERSION $PKGS_DB/installed.$SUM | awk '{ print $1 }')"
al@694 546
pascal@183 547 [ -e $LOG ] || touch $LOG
al@694 548
pankso@279 549 [ -w $LOG ] &&
al@694 550 echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
pascal@183 551 }
pascal@183 552
al@694 553
pascal@648 554 # Download a get-package script from this mirror
al@694 555
pascal@648 556 download_get_script()
pascal@648 557 {
pascal@648 558 local p
pascal@648 559 for p in $priority ; do
pascal@648 560 local i
pascal@648 561 for i in $(cat $p/mirror) ; do
pascal@648 562 case "$i" in
al@694 563 http://*|ftp://*)
al@694 564 wget -O $2 ${i%packages/*}packages/get/$1 && return 0 ;;
pascal@648 565 esac
pascal@648 566 done
pascal@648 567 done
pascal@648 568 return 1
pascal@648 569 }
pascal@648 570
al@694 571
pascal@187 572 # Download a file from this mirror
al@694 573
pascal@187 574 download_from()
pascal@187 575 {
pascal@187 576 local i
pascal@187 577 local mirrors
pascal@187 578 mirrors="$1"
pascal@187 579 shift
pascal@187 580 for i in $mirrors; do
pascal@187 581 case "$i" in
pankso@580 582 # Mirror URL can have a trailing slash or not.
al@694 583 http://*|ftp://*)
al@694 584 busybox wget -c ${i%/}/$@ && break ;;
al@699 585 https://*)
al@699 586 echo 'Sorry, https not supported' ;;
al@694 587 *)
al@694 588 ln -sf $i/$1 . && break ;;
pascal@187 589 esac
pascal@187 590 done
pascal@187 591 }
pascal@187 592
al@694 593
pascal@17 594 # Download a file trying all mirrors
al@694 595
pascal@17 596 download()
pascal@17 597 {
pascal@187 598 local i
pascal@225 599 case "$1" in
pascal@225 600 *.tazpkg)
gokhlayeh@386 601 for i in $priority ; do
gokhlayeh@386 602 grep -q "^${1%.tazpkg}$" $i/packages.list 2>/dev/null || continue
pascal@225 603 download_from "$(cat $i/mirror)" "$@" && return
pascal@225 604 done
pascal@225 605 esac
al@694 606 for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
pascal@191 607 download_from "$i" "$@" && break
pascal@17 608 done
pascal@17 609 }
pascal@17 610
al@694 611
pascal@297 612 # Extract a package with cpio and gzip/lzma.
al@694 613
pankso@6 614 extract_package()
pankso@6 615 {
al@702 616 action 'Extracting package...'
gokhlayeh@414 617 cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
gokhlayeh@383 618 status
pascal@297 619 if [ -f fs.cpio.lzma ]; then
gokhlayeh@383 620 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
gokhlayeh@355 621 elif [ -f fs.cpio.gz ]; then
gokhlayeh@383 622 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
pascal@297 623 fi
pankso@6 624 }
pankso@6 625
al@694 626
pascal@299 627 remove_with_path()
pascal@299 628 {
gokhlayeh@385 629 # Avoid dirname errors by checking for argument.
gokhlayeh@385 630 [ "$1" ] || return
pankso@598 631
pascal@299 632 local dir
pascal@299 633 rm -f $1 2>/dev/null
pascal@299 634 dir="$1"
pascal@299 635 while [ "$dir" != "/" ]; do
pascal@299 636 dir="$(dirname $dir)"
pascal@299 637 rmdir $dir 2> /dev/null || break
pascal@299 638 done
pascal@299 639 }
pascal@299 640
al@694 641
pascal@377 642 grepesc()
pascal@377 643 {
pascal@377 644 sed 's/\[/\\[/g'
pascal@377 645 }
pascal@377 646
al@694 647
MikeDSmith25@135 648 # This function installs a package in the rootfs.
al@694 649
pankso@6 650 install_package()
pankso@6 651 {
pascal@20 652 ROOT=$1
pascal@20 653 if [ -n "$ROOT" ]; then
al@694 654 # Get absolute path
al@694 655 ROOT=$(realpath $ROOT)
pascal@20 656 fi
gokhlayeh@408 657 {
MikeDSmith25@134 658 # Create package path early to avoid dependencies loop
pascal@122 659 mkdir -p $TMP_DIR
gokhlayeh@408 660 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
pascal@122 661 . $TMP_DIR/receipt
al@701 662 # FIXME: legacy?
pascal@224 663 if grep -q ^pre_depends $TMP_DIR/receipt; then
pascal@224 664 pre_depends $ROOT
pascal@224 665 fi
al@694 666
paul@662 667 # Keep modifiers and file list on upgrade
pascal@273 668 cp $ROOT$INSTALLED/$PACKAGE/modifiers \
pascal@273 669 $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
pascal@249 670 rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
al@694 671
pascal@122 672 # Make the installed package data dir to store
pascal@122 673 # the receipt and the files list.
pascal@122 674 mkdir -p $ROOT$INSTALLED/$PACKAGE
pascal@249 675 cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null
pascal@273 676 cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
pascal@249 677 rm -rf $TMP_DIR 2> /dev/null
pascal@195 678 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
al@700 679 $ROOT$PKGS_DB/installed.$SUM 2> /dev/null
pascal@195 680 cd $(dirname $PACKAGE_FILE)
al@700 681 $CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$PKGS_DB/installed.$SUM
gokhlayeh@408 682 }
al@694 683
MikeDSmith25@134 684 # Resolve package deps.
pascal@120 685 check_for_deps $ROOT
al@694 686 if [ -n "$MISSING_PACKAGE" ]; then
pascal@120 687 install_deps $ROOT
pascal@120 688 fi
pankso@6 689 mkdir -p $TMP_DIR
al@700 690 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$PKGS_DB/$INSTALL_LIST-processed
al@694 691
al@702 692 title 'Installation of package "%s"' $PACKAGE
al@702 693
al@702 694 action 'Copying package...'
pankso@9 695 cp $PACKAGE_FILE $TMP_DIR
pankso@6 696 status
al@694 697
pankso@6 698 cd $TMP_DIR
pankso@6 699 extract_package
pascal@20 700 SELF_INSTALL=0
pascal@114 701 EXTRAVERSION=""
pascal@144 702 CONFIG_FILES=""
al@694 703
pankso@6 704 # Include temporary receipt to get the right variables.
pankso@6 705 . $PWD/receipt
pascal@273 706 cd $ROOT$INSTALLED
al@694 707
al@701 708 # FIXME: legacy?
pascal@20 709 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
al@603 710 action "Checking post install dependencies..."
pascal@125 711 [ -f $INSTALLED/$PACKAGE/receipt ]
pascal@20 712 if ! status; then
al@702 713 _ 'Please run "%s" in / and retry.' "tazpkg install $PACKAGE_FILE"
pascal@273 714 rm -rf $TMP_DIR
pascal@20 715 exit 1
pascal@20 716 fi
pascal@20 717 fi
al@694 718
pascal@273 719 # Get files to remove if upgrading
pascal@273 720 if [ -f $PACKAGE/files.list ]; then
pascal@273 721 while read file; do
pascal@377 722 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
pankso@279 723 for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
gokhlayeh@409 724 fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
pascal@377 725 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
pascal@273 726 done
pascal@273 727 echo $file
pascal@273 728 done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
pascal@273 729 fi
al@694 730
pascal@21 731 # Remember modified packages
al@694 732 {
al@694 733 check=false
al@694 734 for i in $(fgrep -v [ $TMP_DIR/files.list); do
al@694 735 [ -e "$ROOT$i" ] || continue
al@694 736 [ -d "$ROOT$i" ] && continue
al@694 737 echo "- $i"
al@694 738 check=true
al@694 739 done ;
al@694 740 $check && \
al@694 741 for i in *; do
al@694 742 [ "$i" == "$PACKAGE" ] && continue
al@694 743 [ -s $i/files.list ] || continue
al@694 744 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
al@694 745 done;
al@694 746 } | awk '
pascal@299 747 {
pascal@299 748 if ($1 == "-" || file[$2] != "") {
pascal@299 749 file[$2] = file[$2] " " $1
pascal@299 750 if ($1 != "-") {
pascal@299 751 if (pkg[$1] == "") all = all " " $1
pascal@299 752 pkg[$1] = pkg[$1] " " $2
pascal@299 753 }
pascal@299 754 }
pascal@299 755 }
pascal@299 756 END {
pascal@299 757 for (i = split(all, p, " "); i > 0; i--)
pascal@299 758 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
pascal@299 759 printf "%s %s\n",p[i],f[j];
pascal@299 760 }
pascal@299 761 ' | while read dir file; do
pascal@299 762 if grep -qs ^$dir$ $PACKAGE/modifiers; then
pascal@299 763 # Do not overload an overloaded file !
pascal@299 764 rm $TMP_DIR$file 2> /dev/null
pascal@299 765 continue
pascal@299 766 fi
pascal@299 767 grep -qs ^$PACKAGE$ $dir/modifiers && continue
pascal@299 768 if [ -s "$dir/volatile.cpio.gz" ]; then
pascal@299 769 # We can modify backed up files without notice
gokhlayeh@383 770 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
pascal@299 771 grep -q "^${file#/}$" && continue
pascal@299 772 fi
pascal@299 773 echo "$PACKAGE" >> $dir/modifiers
pascal@21 774 done
pascal@299 775
pascal@273 776 cd $TMP_DIR
pascal@20 777 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
al@694 778
pascal@20 779 # Copy the description if found.
pankso@6 780 if [ -f "description.txt" ]; then
pascal@20 781 cp description.txt $ROOT$INSTALLED/$PACKAGE
pankso@6 782 fi
al@694 783
pascal@128 784 # Copy the md5sum if found.
slaxemulator@588 785 if [ -f "$CHECKSUM" ]; then
slaxemulator@588 786 cp $CHECKSUM $ROOT$INSTALLED/$PACKAGE
pascal@128 787 fi
al@694 788
pankso@38 789 # Pre install commands.
pankso@38 790 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 791 pre_install $ROOT
pankso@6 792 fi
al@712 793
al@712 794 if [ -n "$CONFIG_FILES" ]; then
pascal@144 795 # save 'official' configuration files
al@702 796 action 'Saving configuration files...'
pascal@144 797 for i in $CONFIG_FILES; do
pascal@539 798 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
gokhlayeh@416 799 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
pascal@144 800 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
al@694 801
al@712 802 if [ -z "$newconf" ]; then
al@712 803 # keep user configuration files
al@712 804 for i in $CONFIG_FILES; do
al@712 805 { cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
al@712 806 done | while read i; do
al@712 807 [ -e $ROOT/$i ] || continue
al@712 808 cp -a $ROOT/$i fs/$i
al@712 809 done
al@712 810 fi
pascal@144 811 status
pascal@144 812 fi
al@694 813
al@702 814 action 'Installing package...'
al@677 815 [ "$(busybox ls fs/* 2> /dev/null)" ] && cp -a fs/* $ROOT/
pankso@6 816 status
al@694 817
pascal@273 818 if [ -s files2remove.list ]; then
al@702 819 action 'Removing old package...'
pascal@273 820 while read file; do
pascal@299 821 remove_with_path $ROOT$file
pascal@273 822 done < files2remove.list
pascal@299 823 true
pascal@273 824 status
pascal@273 825 fi
al@694 826
pankso@6 827 # Remove the temporary random directory.
al@603 828 action "Removing all tmp files..."
al@694 829 cd ..; rm -rf $TMP_DIR
pankso@6 830 status
al@694 831
pankso@38 832 # Post install commands.
pankso@38 833 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 834 post_install $ROOT
pankso@6 835 fi
al@694 836
al@694 837 # Update-desktop-database if needed.
gokhlayeh@409 838 if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
gokhlayeh@356 839 updatedesktopdb=yes
gokhlayeh@356 840 fi
al@694 841
slaxemulator@369 842 # Update-mime-database if needed.
gokhlayeh@409 843 if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
slaxemulator@369 844 updatemimedb=yes
slaxemulator@369 845 fi
al@694 846
slaxemulator@567 847 # Update-icon-database
slaxemulator@567 848 if [ "$(fgrep /usr/share/icon/hicolor $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
slaxemulator@567 849 updateicondb=yes
slaxemulator@567 850 fi
al@694 851
slaxemulator@534 852 # Compile glib schemas if needed.
slaxemulator@534 853 if [ "$(fgrep /usr/share/glib-2.0/schemas $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
slaxemulator@534 854 compile_schemas=yes
slaxemulator@534 855 fi
al@694 856
slaxemulator@588 857 # Update depmod list
slaxemulator@591 858 if [ "$(fgrep /lib/modules $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
slaxemulator@588 859 updatedepmod=yes
slaxemulator@588 860 fi
al@694 861
al@701 862 # Update installed.info
psychomaniak@714 863 check_for_installed_info
al@701 864 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
al@701 865 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
al@707 866 II=$PKGS_DB/installed.info
al@707 867 sed -i "/^$PACKAGE /d" $II # remove old entry
al@707 868 cat >> $II << EOT
al@701 869 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS
al@701 870 EOT
al@707 871 TEMP_FILE=$(mktemp)
al@707 872 sort $II > $TEMP_FILE; mv -f $TEMP_FILE $II; chmod a+r $II; unset II
al@701 873
pankso@6 874 cd $TOP_DIR
al@702 875 footer "$(_ 'Package "%s" (%s) is installed.' $PACKAGE $VERSION$EXTRAVERSION)"
al@694 876
pascal@183 877 # Log this activity
al@603 878 [ -n "$ROOT" ] || log_pkg Installed
pankso@6 879 }
pankso@6 880
al@694 881
pascal@648 882 # This function may be called by a get script.
al@694 883
pascal@648 884 abort_package()
pascal@648 885 {
pascal@648 886 cd $CUR_DIR
pascal@648 887 rm -rf $TMP_DIR
pascal@648 888 echo "${1:-Abort $PACKAGE.}"
pascal@648 889 exit 1
pascal@648 890 }
pascal@648 891
al@694 892
paul@662 893 # This function installs a package from a get script in the rootfs.
al@694 894
pascal@648 895 install_package_from_get_script()
pascal@648 896 {
pascal@648 897 SCRIPT="$1"
pascal@648 898 ROOT="$2"
pascal@648 899 [ -d $ROOT$INSTALLED/$PACKAGE ] && exit 1
pascal@648 900
pascal@648 901 grep -q no-check-certificate $SCRIPT &&
pascal@648 902 [ ! -d $INSTALLED/wget ] && tazpkg get-install wget
pascal@648 903
pascal@648 904 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@679 905 saved=$PACKAGE
pankso@661 906 unset_receipt
pascal@679 907 PACKAGE=$saved
pankso@661 908
pascal@648 909 set -e
pascal@648 910 . $SCRIPT
pascal@659 911 set +e
pascal@697 912 cd $TMP_DIR
pascal@697 913 [ -d $PACKAGE-$VERSION ] || abort_package \
al@702 914 "$(_ 'Could not download "%s" from "%s". Exiting.' ${TARBALL:-$PACKAGE} ${WGET_URL:-$WEB_SITE})"
al@702 915
pascal@648 916 if [ ! -s $PACKAGE-$VERSION/receipt ]; then
pascal@648 917 cat > $PACKAGE-$VERSION/receipt <<EOT
pascal@648 918 # SliTaz package receipt.
pascal@648 919
pascal@648 920 PACKAGE="$PACKAGE"
pascal@667 921 VERSION="${VERSION:-unknown}"
pascal@648 922 CATEGORY="${CATEGORY:-non-free}"
pascal@648 923 WEB_SITE="$WEB_SITE"
pascal@648 924 SHORT_DESC="${SHORT_DESC:-$PACKAGE}"
pascal@648 925 MAINTAINER="${MAINTAINER:-nobody@slitaz.org}"
pascal@648 926 EOT
pascal@648 927 for i in LICENSE TARBALL WGET_URL CONFIG_FILES SUGGESTED \
pascal@697 928 PROVIDE DEPENDS HOST_ARCH TAGS EXTRA_SOURCE_FILES ; do
pascal@648 929 eval "[ -n \"\$$i\" ] && echo \"$i=\\\"\$$i\\\"\""
pascal@648 930 done >> $PACKAGE-$VERSION/receipt
pascal@648 931 fi
pascal@648 932
pascal@659 933 DEPENDS="$(unset DEPENDS; . $PACKAGE-$VERSION/receipt ; echo $DEPENDS)"
pascal@659 934 for i in $(find_depends $PACKAGE-$VERSION/fs); do
pascal@659 935 case " $DEPENDS " in
al@694 936 *\ $i\ *) continue;;
pascal@659 937 esac
pascal@659 938 grep -q '^DEPENDS="' $PACKAGE-$VERSION/receipt ||
pascal@659 939 echo 'DEPENDS=""' >> $PACKAGE-$VERSION/receipt
pascal@659 940 sed -i "s/^DEPENDS=\"/&$i /" $PACKAGE-$VERSION/receipt
pascal@659 941 done
pascal@659 942
pascal@648 943 tazpkg pack $PACKAGE-$VERSION
pascal@648 944
pascal@648 945 # Clean to save RAM memory before installation
pascal@648 946 rm -rf $PACKAGE-$VERSION
pascal@648 947
pascal@648 948 # Install pseudo package
pascal@648 949 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
pascal@648 950 mv $PACKAGE-$VERSION.tazpkg $CACHE_DIR
pascal@648 951
pascal@648 952 # Clean
pascal@648 953 cd $TOP_DIR
pascal@648 954 rm -rf $TMP_DIR
pascal@648 955 }
pascal@648 956
al@694 957
pascal@122 958 # Check for loop in deps tree.
al@694 959
pascal@122 960 check_for_deps_loop()
pascal@122 961 {
pascal@122 962 local list
pascal@122 963 local pkg
pascal@122 964 local deps
pascal@122 965 pkg=$1
pascal@122 966 shift
pascal@122 967 [ -n "$1" ] || return
pascal@122 968 list=""
al@694 969
pascal@122 970 # Filter out already processed deps
pascal@122 971 for i in $@; do
pascal@122 972 case " $ALL_DEPS" in
al@702 973 *\ $i\ *) ;;
al@702 974 *) list="$list $i";;
pascal@122 975 esac
pascal@122 976 done
pascal@122 977 ALL_DEPS="$ALL_DEPS$list "
pascal@122 978 for i in $list; do
pascal@122 979 [ -f $i/receipt ] || continue
pascal@122 980 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@122 981 case " $deps " in
al@702 982 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
al@702 983 *) check_for_deps_loop $pkg $deps;;
pascal@122 984 esac
pascal@122 985 done
pascal@122 986 }
pascal@122 987
al@694 988
pankso@6 989 # Check for missing deps listed in a receipt packages.
al@694 990
pankso@6 991 check_for_deps()
pankso@6 992 {
pascal@116 993 local saved;
pascal@116 994 saved=$PACKAGE
pascal@116 995 mkdir -p $TMP_DIR
gokhlayeh@408 996 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
pascal@116 997 . $TMP_DIR/receipt
pascal@116 998 PACKAGE=$saved
pascal@116 999 rm -rf $TMP_DIR
al@633 1000
al@633 1001 num=0
al@694 1002 for pkgorg in $DEPENDS; do
pascal@164 1003 i=$(equivalent_pkg $pkgorg $1)
pascal@120 1004 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 1005 MISSING_PACKAGE=$i
al@633 1006 num=$(($num+1))
pascal@122 1007 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
al@702 1008 _ 'WARNING! Dependency loop between "%s" and "%s".' $PACKAGE $i
pankso@6 1009 fi
pankso@6 1010 done
al@633 1011
al@707 1012 if [ -n "$MISSING_PACKAGE" ]; then
al@702 1013 title "$(_ 'Tracking dependencies for package "%s"' $PACKAGE)"
al@694 1014 for pkgorg in $DEPENDS; do
pascal@164 1015 i=$(equivalent_pkg $pkgorg $1)
pascal@120 1016 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 1017 MISSING_PACKAGE=$i
al@702 1018 _ 'Missing package "%s"' $MISSING_PACKAGE
pankso@6 1019 fi
pankso@6 1020 done
al@707 1021 footer "$(_p \
al@707 1022 '%s missing package to install.' \
al@707 1023 '%s missing packages to install.' $num \
al@707 1024 $num)"
pankso@6 1025 fi
pankso@6 1026 }
pankso@6 1027
al@694 1028
pankso@598 1029 # Install all missing deps. Auto install or ask user then install all missing
pankso@308 1030 # deps from local dir, cdrom, media or from the mirror. In case we want to
pankso@6 1031 # install packages from local, we need a packages.list to find the version.
al@694 1032
pankso@6 1033 install_deps()
pankso@6 1034 {
pascal@120 1035 local root
pascal@120 1036 root=""
pascal@121 1037 [ -n "$1" ] && root="--root=$1"
pankso@308 1038 if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then
al@603 1039 answer=0
pankso@308 1040 else
pankso@600 1041 newline
al@696 1042 confirm "$(_ 'Install all missing dependencies? (y/N)')"
al@603 1043 answer=$?
pankso@600 1044 newline
pankso@308 1045 fi
psychomaniak@709 1046 if [ $answer = 0 ] && ! [ "$nodeps" ]; then
al@694 1047 for pkgorg in $DEPENDS; do
pascal@164 1048 pkg=$(equivalent_pkg $pkgorg $1)
pascal@120 1049 if [ ! -d "$1$INSTALLED/$pkg" ]; then
pascal@121 1050 local list
pascal@121 1051 list="$INSTALL_LIST"
pascal@121 1052 [ -n "$list" ] || list="$TOP_DIR/packages.list"
pankso@6 1053 # We can install packages from a local dir by greping
pankso@6 1054 # the TAZPKG_BASENAME in the local packages.list.
pascal@153 1055 found=0
pascal@121 1056 if [ -f "$list" ]; then
al@702 1057 _ 'Checking if package "%s" exists in local list...' $pkg
pascal@110 1058 mkdir $TMP_DIR
pascal@110 1059 for i in $pkg-*.tazpkg; do
pascal@124 1060 [ -f $i ] || continue
gokhlayeh@408 1061 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
pascal@153 1062 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
pascal@121 1063 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
pascal@110 1064 then
pascal@153 1065 found=1
pascal@121 1066 tazpkg install $i $root --list=$list
pascal@110 1067 break
pascal@110 1068 fi
pascal@110 1069 done
pascal@110 1070 rm -rf $TMP_DIR
pascal@153 1071 fi
pankso@6 1072 # Install deps from the mirror.
pascal@153 1073 if [ $found -eq 0 ]; then
al@700 1074 if [ ! -f "$PKGS_DB/packages.list" ]; then
pankso@6 1075 tazpkg recharge
pankso@6 1076 fi
pascal@120 1077 tazpkg get-install $pkg $root
pankso@6 1078 fi
pankso@6 1079 fi
pankso@6 1080 done
pankso@6 1081 else
pankso@600 1082 newline
al@702 1083 _ 'Leaving dependencies for package "%s" unresolved.' $PACKAGE
al@702 1084 _ 'The package is installed but will probably not work.'
pankso@600 1085 newline
pankso@6 1086 fi
pankso@6 1087 }
pankso@6 1088
al@694 1089
pankso@279 1090 # Search pattern in installed packages.
al@694 1091
pankso@54 1092 search_in_installed_packages()
pankso@54 1093 {
al@694 1094 _ 'Installed packages'
slaxemulator@475 1095 separator
al@633 1096 num=0
al@702 1097 for pkg in $(ls -1 $INSTALLED | grep -i "$PATTERN"); do
pascal@114 1098 EXTRAVERSION=""
pascal@122 1099 [ -f $INSTALLED/$pkg/receipt ] || continue
pankso@54 1100 . $INSTALLED/$pkg/receipt
al@694 1101 emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(_n $CATEGORY)"
al@633 1102 num=$(($num+1))
pankso@54 1103 done
al@694 1104
al@707 1105 footer "$(_p \
al@707 1106 '%s installed package found for "%s"' \
al@707 1107 '%s installed packages found for "%s"' $num \
al@707 1108 $num "$PATTERN")"
pankso@54 1109 }
pankso@54 1110
al@694 1111
pankso@279 1112 # Search in packages.list for available pkgs.
al@694 1113
pankso@54 1114 search_in_packages_list()
pankso@54 1115 {
al@707 1116 _ 'Available packages'
slaxemulator@475 1117 separator
al@633 1118 num=0
al@694 1119 BPATTERN="$(emsg "<b>$PATTERN</b>")"
al@700 1120 for i in $PKGS_DB/packages.list $PKGS_DB/undigest/*/packages.list; do
al@694 1121 grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
al@633 1122 num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
pascal@187 1123 done
al@700 1124 if [ ! -f "$PKGS_DB/packages.list" ]; then
pankso@600 1125 newline
al@707 1126 longline "$(_ \
al@707 1127 "No \"%s\" found to check for mirrored packages. For more results, please run \
al@707 1128 \"%s\" once as root before searching." packages.list 'tazpkg recharge')"
pankso@600 1129 newline
pankso@54 1130 fi
al@707 1131 footer "$(_p \
al@707 1132 '%s available package found for "%s"' \
al@707 1133 '%s available packages found for "%s"' $num \
al@707 1134 $num $PATTERN)"
pankso@54 1135 }
pankso@54 1136
al@694 1137
pankso@279 1138 # search --mirror: Search in packages.txt for available pkgs and give more
pankso@279 1139 # info than --list or default.
al@694 1140
pankso@54 1141 search_in_packages_txt()
pankso@54 1142 {
al@694 1143 _ 'Matching packages name with version and desc'
slaxemulator@475 1144 separator
al@633 1145 num=0
al@700 1146 for i in $PKGS_DB/packages.txt $PKGS_DB/undigest/*/packages.txt; do
pascal@187 1147 grep -is -A 2 "^$PATTERN" $i
al@633 1148 num=$(($num + `grep -is "^$PATTERN" $i | wc -l`))
pascal@187 1149 done
al@700 1150 if [ ! -f "$PKGS_DB/packages.txt" ]; then
pankso@600 1151 newline
al@707 1152 longline "$(_ \
al@707 1153 "No \"%s\" found to check for mirrored packages. For more results, please run \
al@707 1154 \"%s\" once as root before searching." packages.txt 'tazpkg recharge')"
pankso@600 1155 newline
pankso@54 1156 fi
al@707 1157 footer "$(_p \
al@707 1158 '%s available package found for "%s"' \
al@707 1159 '%s available packages found for "%s"' $num \
al@707 1160 $num $PATTERN)"
pankso@54 1161 }
pankso@54 1162
al@694 1163
pascal@74 1164 # Install package-list from a flavor
al@694 1165
pascal@74 1166 install_flavor()
pascal@74 1167 {
al@603 1168 check_root $@
pankso@598 1169
gokhlayeh@386 1170 # Get repositories priority list.
gokhlayeh@386 1171 look_for_priority
pankso@598 1172
pascal@74 1173 FLAVOR=$1
pascal@74 1174 ARG=$2
pascal@74 1175 mkdir -p $TMP_DIR
pascal@74 1176 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
pascal@74 1177 cd $TMP_DIR
pascal@74 1178 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
pascal@643 1179 zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
al@694 1180
pascal@74 1181 while read file; do
pascal@74 1182 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
pascal@122 1183 [ -f $pkg/receipt ] || continue
pascal@114 1184 EXTRAVERSION=""
pascal@74 1185 . $pkg/receipt
pascal@114 1186 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
pascal@74 1187 done
pascal@114 1188 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
pascal@74 1189 cd $CACHE_DIR
pascal@74 1190 download $file.tazpkg
pascal@74 1191 cd $TMP_DIR
al@694 1192 tazpkg install $CACHE_DIR/$file.tazpkg --forced
pascal@74 1193 done < $FLAVOR.pkglist
al@694 1194
pascal@75 1195 [ -f $FLAVOR.nonfree ] && while read pkg; do
pascal@75 1196 [ -d $INSTALLED/$pkg ] || continue
pascal@75 1197 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
pascal@75 1198 get-$pkg
pascal@75 1199 done < $FLAVOR.nonfree
al@694 1200
pascal@74 1201 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
pascal@122 1202 [ -f $INSTALLED/$pkg/receipt ] || continue
pascal@114 1203 EXTRAVERSION=""
pascal@74 1204 . $INSTALLED/$pkg/receipt
pascal@114 1205 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
pascal@75 1206 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
pascal@74 1207 tazpkg remove $PACKAGE
pascal@74 1208 done
pascal@74 1209 else
al@702 1210 _ "Can't find flavor \"%s\". Abort." $FLAVOR
pascal@74 1211 fi
pascal@74 1212 cd $TOP_DIR
pascal@74 1213 rm -rf $TMP_DIR
pascal@74 1214 }
pascal@74 1215
al@694 1216
pascal@187 1217 # Update mirror urls
al@694 1218
pascal@187 1219 setup_mirror()
pascal@187 1220 {
pascal@187 1221 # Backup old list.
pascal@187 1222 if [ -f "$1/mirror" ]; then
pascal@187 1223 cp -f $1/mirror $1/mirror.bak
pascal@187 1224 fi
al@603 1225 title 'Current mirror(s)'
pascal@187 1226 echo " `cat $1/mirror 2> /dev/null`"
al@707 1227 longline "$(_ \
al@707 1228 "Please enter URL of the new mirror (http, ftp or local path). You must specify \
al@707 1229 the complete address to the directory of the packages and packages.list file.")"
pankso@600 1230 newline
al@694 1231 _n 'New mirror(s) URL: '
pascal@187 1232 NEW_MIRROR_URL=$2
pascal@187 1233 if [ -n "$NEW_MIRROR_URL" ]; then
pascal@187 1234 echo $NEW_MIRROR_URL
pascal@187 1235 else
pascal@187 1236 read NEW_MIRROR_URL
pascal@187 1237 fi
pascal@187 1238 if [ "$NEW_MIRROR_URL" = "" ]; then
al@694 1239 _ 'Nothing has been changed.'
pascal@187 1240 else
al@702 1241 _ 'Setting mirror(s) to: "%s"' $NEW_MIRROR_URL
pascal@187 1242 rm -f $1/mirror
pascal@187 1243 for i in $NEW_MIRROR_URL; do
pascal@685 1244 echo "${i%/}/" >> $1/mirror
pankso@279 1245 done
pascal@187 1246 fi
pankso@600 1247 newline
pascal@187 1248 }
pascal@187 1249
al@694 1250
paul@247 1251 # recursive dependencies scan
al@694 1252
pascal@205 1253 dep_scan()
pascal@205 1254 {
al@694 1255 for i in $1; do
al@694 1256 case " $ALL_DEPS " in
al@694 1257 *\ $i\ *) continue;;
al@694 1258 esac
al@694 1259 ALL_DEPS="$ALL_DEPS $i"
al@700 1260 [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $PKGS_DB/packages.txt | \
al@694 1261 tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
al@694 1262 [ -f $i/receipt ] || continue
al@694 1263 DEPENDS=""
al@694 1264 . $i/receipt
al@694 1265 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
al@694 1266 done
pascal@205 1267 }
pascal@205 1268
al@694 1269
paul@247 1270 # recursive reverse dependencies scan
al@694 1271
pascal@205 1272 rdep_scan()
pascal@205 1273 {
al@694 1274 SEARCH=$1
al@694 1275
al@694 1276 for i in * ; do
al@694 1277 DEPENDS=""
al@694 1278 . $i/receipt
al@694 1279 echo "$i $(echo $DEPENDS)"
al@694 1280 done | busybox awk -v search=$SEARCH '
pascal@260 1281 function show_deps(deps, all_deps, pkg, space)
pascal@260 1282 {
pascal@260 1283 if (all_deps[pkg] == 1) return
pascal@260 1284 all_deps[pkg] = 1
pascal@304 1285 if (space != "") printf "%s %s\n",space,pkg
pascal@299 1286 for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) {
pascal@304 1287 show_deps(deps, all_deps, mydeps[i],"==" space)
pascal@260 1288 }
pascal@260 1289 }
pascal@260 1290
pascal@260 1291 {
pascal@260 1292 all_deps[$1] = 0
pascal@260 1293 for (i = 2; i <= NF; i++)
pascal@260 1294 deps[$i] = deps[$i] " " $1
pascal@260 1295 }
pascal@260 1296
pascal@260 1297 END {
pascal@260 1298 show_deps(deps, all_deps, search, "")
pascal@260 1299 }
pascal@304 1300 ' | while read spc pkg; do
al@694 1301 echo -n $spc | sed 's/=/ /g'
al@694 1302 echo -n $pkg
al@694 1303 echo -n ' ('
al@700 1304 fgrep -A 3 $pkg $PKGS_DB/packages.txt | tail -1 | \
al@694 1305 sed 's/.*(\([^ ]*\).*/\1)/'
al@694 1306 done
pascal@205 1307 }
pascal@205 1308
al@694 1309
gokhlayeh@356 1310 update_desktop_database()
gokhlayeh@356 1311 {
gokhlayeh@382 1312 if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
pascal@578 1313 chroot "$1/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null
gokhlayeh@356 1314 fi
gokhlayeh@356 1315 }
gokhlayeh@356 1316
al@694 1317
slaxemulator@369 1318 update_mime_database()
slaxemulator@369 1319 {
slaxemulator@394 1320 if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
pascal@578 1321 chroot "$1/" /usr/bin/update-mime-database /usr/share/mime
slaxemulator@369 1322 fi
slaxemulator@369 1323 }
slaxemulator@369 1324
al@694 1325
slaxemulator@567 1326 update_icon_database()
slaxemulator@567 1327 {
slaxemulator@567 1328 if [ -f $1/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then
pascal@578 1329 chroot "$1/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor
slaxemulator@567 1330 fi
slaxemulator@567 1331 }
slaxemulator@567 1332
al@694 1333
slaxemulator@534 1334 compile_glib_schemas()
slaxemulator@534 1335 {
slaxemulator@534 1336 if [ -f $1/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then
pascal@578 1337 chroot "$1/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
slaxemulator@534 1338 fi
slaxemulator@534 1339 }
slaxemulator@534 1340
al@694 1341
slaxemulator@588 1342 update_kernel_modules()
slaxemulator@588 1343 {
slaxemulator@588 1344 if [ -f $1/sbin/depmod ] && [ -n "$updatedepmod" ]; then
slaxemulator@588 1345 chroot "$1/" /sbin/depmod -a
slaxemulator@588 1346 fi
slaxemulator@588 1347 }
slaxemulator@588 1348
al@694 1349
al@694 1350
al@694 1351
al@694 1352
pankso@6 1353 ###################
pankso@653 1354 # TazPKG commands #
pankso@6 1355 ###################
pankso@6 1356
pankso@6 1357 case "$COMMAND" in
pankso@504 1358 list|-l)
al@701 1359 # List all installed packages or a specific category.
al@603 1360 shift
al@701 1361 check_for_installed_info
al@701 1362
al@701 1363 case $1 in
al@701 1364 b|blocked)
al@701 1365 # Display the list of blocked packages.
al@701 1366 title 'Blocked packages'
al@701 1367 if [ -s "$BLOCKED" ];then
al@701 1368 cat $BLOCKED
al@701 1369 else
al@701 1370 _ 'No blocked packages found.'
pankso@6 1371 fi
al@701 1372 newline; exit 0
al@701 1373 ;;
al@701 1374 c|cat|categories)
al@701 1375 # Display the list of categories.
al@701 1376 title 'Packages categories'
al@701 1377 echo "$PKGS_CATEGORIES" | sed 's|[^a-z-]|\n|g; /^$/d' | \
al@701 1378 sed 's|\(.*\)|\1'$'\033''[15G \1|' | translate_category
al@701 1379 num=$(echo -n "$PKGS_CATEGORIES" | wc -l)
al@707 1380 footer "$(_p \
al@707 1381 '%s category' \
al@707 1382 '%s categories' $num \
al@707 1383 $num)"
al@701 1384 exit 0
al@701 1385 ;;
al@701 1386 '')
al@701 1387 # By default list all packages and versions.
al@701 1388 title 'List of all installed packages'
al@701 1389 TMPLIST=$(mktemp)
al@701 1390 awk -F$'\t' '{print $1"\033[35G "$2"\033[53G "$3}' \
al@701 1391 $PKGS_DB/installed.info | tee $TMPLIST | translate_category
al@701 1392
al@701 1393 packages=$(wc -l $TMPLIST | awk '{print $1}'); rm $TMPLIST
al@707 1394 footer "$(emsg $(_p \
al@707 1395 '%s package installed.' \
al@707 1396 '%s packages installed.' $packages \
al@707 1397 "<c 32>$packages</c>"))"
al@701 1398 ;;
al@701 1399 *)
al@701 1400 # Check for an asked category.
al@701 1401 ASKED_CATEGORY_I18N="$@"
al@701 1402 ASKED_CATEGORY=$(reverse_translate_category "$ASKED_CATEGORY_I18N")
al@702 1403 title 'Installed packages of category "%s"' $ASKED_CATEGORY_I18N
al@701 1404 TMPLIST=$(mktemp)
al@701 1405 awk -F$'\t' '
al@701 1406 {
al@701 1407 if ($3 == "'$ASKED_CATEGORY'")
al@701 1408 print $1"\033[35G "$2
al@701 1409 }' \
al@701 1410 $PKGS_DB/installed.info | tee $TMPLIST | translate_category
al@701 1411
al@701 1412 packages=$(wc -l $TMPLIST | awk '{print $1}'); rm $TMPLIST
al@707 1413 footer "$(emsg $(_p \
al@707 1414 '%s package installed of category "%s".' \
al@707 1415 '%s packages installed of category "%s".' $packages \
al@707 1416 "<c 32>$packages</c>" "<c 34>$ASKED_CATEGORY_I18N</c>"))"
al@701 1417 ;;
al@701 1418 esac ;;
al@694 1419
pankso@600 1420 list-mirror|-lm)
paul@247 1421 # List all available packages on the mirror. Option --diff displays
pankso@6 1422 # last mirrored packages diff (see recharge).
pankso@6 1423 check_for_packages_list
pankso@53 1424 case $2 in
pankso@53 1425 --diff)
al@700 1426 if [ -f "$PKGS_DB/packages.diff" ]; then
al@603 1427 title 'Mirrored packages diff'
al@700 1428 cat $PKGS_DB/packages.diff
al@700 1429 num=$(wc -l < $PKGS_DB/packages.diff)
al@707 1430 footer "$(_p \
al@707 1431 '%s new package listed on the mirror.' \
al@707 1432 '%s new packages listed on the mirror.' $num \
al@707 1433 $num)"
pankso@53 1434 else
pankso@600 1435 newline
al@694 1436 _ 'Unable to list anything, no packages.diff found.'
al@694 1437 _ 'Recharge your current list to create a first diff.'
pankso@600 1438 newline
al@694 1439 fi; exit 0 ;;
al@603 1440 --text|--txt|--raw|*)
al@603 1441 title 'List of available packages on the mirror'
al@700 1442 cat $PKGS_DB/packages.txt ;;
pankso@53 1443 esac
al@700 1444 pkgs=$(wc -l < $PKGS_DB/packages.list)
al@707 1445 footer "$(emsg "$(_p \
al@707 1446 '%s package in the last recharged list.' \
al@707 1447 '%s packages in the last recharged list.' $pkgs \
al@707 1448 "<c 32>$pkgs</c>")")"
al@603 1449 ;;
al@694 1450
al@694 1451
pankso@600 1452 list-files|-lf)
pankso@6 1453 # List files installed with the package.
pankso@6 1454 check_for_package_on_cmdline
pankso@6 1455 check_for_receipt
al@702 1456 title 'Installed files by "%s"' $PACKAGE
pascal@648 1457 sort < $INSTALLED/$PACKAGE/files.list
mojo@664 1458 files=$(wc -l < $INSTALLED/$PACKAGE/files.list)
al@707 1459 footer "$(emsg "$(_p \
al@707 1460 '%s file' '%s files' $files \
al@707 1461 "<c 32>$files</c>")")"
al@603 1462 ;;
al@694 1463
al@694 1464
pankso@6 1465 info)
pascal@119 1466 # Information about package.
pankso@6 1467 check_for_package_on_cmdline
pankso@6 1468 check_for_receipt
pascal@114 1469 EXTRAVERSION=""
pankso@6 1470 . $INSTALLED/$PACKAGE/receipt
al@717 1471 im && title 'TazPKG information'
al@622 1472 # Display localized short description
al@702 1473 for LC in $LANG ${LANG%_*}; do
al@702 1474 if [ -e "$PKGS_DB/packages-desc.$LC" ]; then
al@702 1475 LOCDESC=$(grep -e "^$PACKAGE " $PKGS_DB/packages-desc.$LC | cut -d' ' -f2)
al@702 1476 [ -n "$LOCDESC" ] && SHORT_DESC="$LOCDESC"
al@702 1477 fi
al@702 1478 done
al@702 1479 emsg "$(
al@702 1480 {
al@702 1481 _ 'Package : %s' "$PACKAGE"
al@702 1482 _ 'Version : %s' "$VERSION$EXTRAVERSION"
al@702 1483 _ 'Category : %s' "$(_ $CATEGORY)"
al@702 1484 _ 'Short desc : %s' "$SHORT_DESC"
al@702 1485 _ 'Maintainer : %s' "$MAINTAINER"
al@702 1486 _ 'License : %s' "$LICENSE"
al@702 1487 _ 'Depends : %s' "$DEPENDS"
al@702 1488 _ 'Suggested : %s' "$SUGGESTED"
al@702 1489 _ 'Build deps : %s' "$BUILD_DEPENDS"
al@702 1490 _ 'Wanted src : %s' "$WANTED"
al@702 1491 _ 'Web site : %s' "$WEB_SITE"
al@702 1492 _ 'Tags : %s' "$TAGS"
al@702 1493 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
al@717 1494 im && footer
al@717 1495 ;;
al@694 1496
al@694 1497
pankso@6 1498 desc)
al@717 1499 # Display package description
al@711 1500 if [ -n "$(grep -e "^$PACKAGE " $PKGS_DB/installed.info)" ]; then
al@717 1501 im && title 'Description of package "%s"' $PACKAGE
al@711 1502 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
al@711 1503 cat $INSTALLED/$PACKAGE/description.txt
al@711 1504 else
al@717 1505 im && awk -F$'\t' '{if ($1 == "'$PACKAGE'") print $4}' $PKGS_DB/installed.info
al@711 1506 fi
al@717 1507 im && footer
pankso@6 1508 else
al@717 1509 im && _ 'Package "%s" is not installed.' "$PACKAGE"
al@711 1510 fi
al@711 1511 ;;
al@694 1512
al@694 1513
pankso@654 1514 activity|log|-a)
pankso@654 1515 # Show activity log
pankso@654 1516 [ "$nb" ] || nb=18
pankso@654 1517 title 'TazPKG Activity'
pankso@654 1518 IFS=" "
al@694 1519 tail -n ${nb} ${LOG} | \
al@694 1520 while read date hour none action none pkg vers none; do
al@694 1521 case $action in
pankso@654 1522 Installed)
al@694 1523 action=$(colorize 32 $action) ;;
pankso@654 1524 Removed)
al@694 1525 action=$(colorize 31 $action) ;;
pankso@654 1526 *)
al@694 1527 action=$(boldify $action) ;;
pankso@654 1528 esac
al@694 1529 echo "$date $hour : $action $pkg $vers"
al@694 1530 done
al@694 1531 unset IFS
al@694 1532 footer ;;
al@694 1533
al@694 1534
pankso@504 1535 search|-s)
pankso@6 1536 # Search for a package by pattern or name.
pankso@54 1537 PATTERN="$2"
pankso@54 1538 if [ -z "$PATTERN" ]; then
pankso@600 1539 newline
al@694 1540 _ 'Please specify a pattern or package name to search for.'
al@694 1541 echo "$(_ 'Example:') 'tazpkg search paint'"
pankso@600 1542 newline
pankso@6 1543 exit 0
pankso@6 1544 fi
al@702 1545 title 'Search result for "%s"' $PATTERN
pankso@54 1546 # Default is to search in installed pkgs and the raw list.
pankso@654 1547 case "$3" in
pankso@54 1548 -i|--installed)
pankso@54 1549 search_in_installed_packages ;;
pankso@54 1550 -l|--list)
pankso@54 1551 search_in_packages_list ;;
pankso@54 1552 -m|--mirror)
pankso@54 1553 search_in_packages_txt ;;
pankso@54 1554 *)
pankso@54 1555 search_in_installed_packages
jozee@338 1556 search_in_packages_list ;;
pankso@309 1557 esac ;;
al@694 1558
al@694 1559
pankso@593 1560 search-file|-sf)
pankso@12 1561 # Search for a file by pattern or name in all files.list.
pankso@12 1562 if [ -z "$2" ]; then
pankso@600 1563 newline
al@694 1564 _ 'Please specify a pattern or file name to search for.'
al@694 1565 echo "$(_ 'Example:') 'tazpkg search-file libnss'"
pankso@600 1566 newline
pankso@12 1567 exit 0
pankso@12 1568 fi
al@702 1569 title 'Search result for file "%s"' $2
al@702 1570
al@702 1571 TMPLIST=$(mktemp)
pascal@98 1572 if [ "$3" == "--mirror" ]; then
pankso@279 1573
al@702 1574 for i in $PKGS_DB/files.list.lzma $PKGS_DB/undigest/*/files.list.lzma; do
al@694 1575 [ -f $i ] || continue
al@704 1576 lzcat $i | awk -F: -vP="$(gettext 'Package %s:')" -vT=$TMPLIST '
al@704 1577 BEGIN { last = "" }
al@702 1578 $2 ~ /'$2'/ {
al@702 1579 if (last != $1) {
al@702 1580 last = $1;
al@702 1581 PP = P;
al@702 1582 sub(/%s/, $1, PP);
al@702 1583 printf("\n\e[1;33m%s\e[0;39m\n", PP);
al@603 1584 }
al@702 1585 gsub(/'$2'/, "\e[0;32m'$2'\e[0;39m", $2);
al@704 1586 print $2;
al@704 1587 printf "%s" 1 >> T;
al@704 1588 }'
pascal@187 1589 done
pascal@98 1590
pascal@98 1591 else
pascal@98 1592
al@603 1593 # Check all pkg files.list in search match which specify the package
al@603 1594 # name and the full path to the file(s).
al@694 1595 for pkg in $INSTALLED/*; do
al@603 1596 if grep -qs "$2" $pkg/files.list; then
al@603 1597 . $pkg/receipt
al@603 1598 newline
al@702 1599 emsg "<c 33>$(_ 'Package %s:' $PACKAGE)</c>"
al@704 1600 awk -vT=$TMPLIST '
al@702 1601 /'$2'/ {
al@702 1602 gsub(/'$2'/, "\e[0;32m'$2'\e[0;39m", $0);
al@704 1603 print " "$0;
al@704 1604 printf "%s" 1 >> T;
al@702 1605 }
al@704 1606 ' $pkg/files.list
al@603 1607 fi
al@603 1608 done
pascal@98 1609
pascal@98 1610 fi
al@702 1611
al@704 1612 match=$(wc -m < $TMPLIST)
al@702 1613 rm $TMPLIST
al@702 1614
al@707 1615 footer "$(emsg "$(_p \
al@707 1616 '%s file' '%s files' $match \
al@707 1617 "<c 32>$match</c>")")"
al@603 1618 ;;
al@694 1619
al@694 1620
pankso@598 1621 search-pkgname)
pankso@344 1622 # Search for a package name
jozee@318 1623 if [ -z "$2" ]; then
pankso@600 1624 newline
al@694 1625 _ 'Please specify a pattern or file name to search for.'
al@694 1626 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
pankso@600 1627 newline
jozee@318 1628 exit 0
jozee@318 1629 fi
al@702 1630 title 'Search result for package "%s"' $2
pankso@598 1631
pankso@503 1632 # Search for a file on mirror and output only the package name
al@704 1633 TMPLIST=$(mktemp)
al@704 1634 for i in $PKGS_DB/files.list.lzma $PKGS_DB/undigest/*/files.list.lzma; do
al@704 1635 [ -f $i ] || continue
al@704 1636 lzcat $i | awk -F: -vT=$TMPLIST '
al@704 1637 BEGIN { P = "" }
al@704 1638 $2 ~ /'$2'/ {
al@704 1639 if ($1 != P) {
al@704 1640 print $1;
al@704 1641 printf "%s" 1 >> T;
al@704 1642 P = $1
al@704 1643 }
al@704 1644 }'
jozee@318 1645 done
al@704 1646 match=$(wc -m < $TMPLIST)
al@704 1647 rm $TMPLIST
al@704 1648
al@707 1649 footer "$(emsg "$(_p \
al@707 1650 '%s package' '%s packages' $match \
al@707 1651 "<c 32>$match</c>")")"
jozee@318 1652 ;;
al@694 1653
al@694 1654
pankso@504 1655 install|-i)
pankso@6 1656 # Install .tazpkg packages.
al@603 1657 check_root $@
pankso@6 1658 check_for_package_on_cmdline
pankso@6 1659 check_for_package_file
al@701 1660 check_for_installed_info
pankso@598 1661
al@704 1662 if [ -n "$root" ]; then
al@704 1663 ROOT="$root";
al@704 1664 check_base_dir "$root"
al@704 1665 fi
gokhlayeh@429 1666 [ "$list" ] && INSTALL_LIST="$list"
slaxemulator@488 1667 if [ "$rootconfig" ]; then
slaxemulator@487 1668 if [ "$root" ]; then
slaxemulator@487 1669 CACHE_DIR=$root/$CACHE_DIR
slaxemulator@487 1670 SAVE_CACHE_DIR=$CACHE_DIR
al@700 1671 PKGS_DB=$root/$PKGS_DB
slaxemulator@487 1672 else
slaxemulator@487 1673 echo "rootconfig needs --root= option used." >&2
slaxemulator@487 1674 exit 1
slaxemulator@487 1675 fi
slaxemulator@487 1676 fi
gokhlayeh@436 1677
gokhlayeh@386 1678 # Get repositories priority list.
gokhlayeh@386 1679 look_for_priority
gokhlayeh@436 1680
pankso@6 1681 # Check if forced install.
al@704 1682 if [ -z "$forced" ]; then
pascal@121 1683 check_for_installed_package $ROOT
pankso@6 1684 fi
gokhlayeh@356 1685 install_package $ROOT
slaxemulator@369 1686 update_desktop_database $ROOT
pankso@598 1687 update_mime_database $ROOT
pankso@598 1688 update_icon_database $ROOT
al@704 1689 compile_glib_schemas $ROOT
al@704 1690 ;;
al@694 1691
al@694 1692
erjo@59 1693 install-list|get-install-list)
pankso@6 1694 # Install a set of packages from a list.
al@603 1695 check_root $@
pankso@6 1696 if [ -z "$2" ]; then
pankso@600 1697 newline
al@704 1698 longline "$(_ \
al@704 1699 "Please change directory (cd) to the packages repository and specify the \
al@704 1700 list of packages to install.")"
al@704 1701 echo "$(_ 'Example:') $(emsg '<b>tazpkg install-list</b> <c 33>packages.list</c>')"
al@694 1702 exit 0
pankso@6 1703 fi
al@704 1704
pankso@6 1705 # Check if the packages list exist.
al@704 1706 if [ ! -f "$2" ]; then
al@704 1707 _ 'Unable to find list "%s"' "$2"
pankso@6 1708 exit 0
pankso@6 1709 fi
pankso@279 1710
al@704 1711 LIST=$(cat $2)
al@704 1712
pascal@120 1713 # Remember processed list
pascal@121 1714 export INSTALL_LIST="$2"
pascal@120 1715
erjo@59 1716 # Set $COMMAND and install all packages.
al@704 1717 COMMAND=${1%-list}
al@704 1718
pascal@121 1719 touch $2-processed
pascal@314 1720
pascal@314 1721 # Upgrade tazpkg first. It may handle new features/formats...
pascal@340 1722 # then upgrade essential packages early
pascal@341 1723 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
al@704 1724 slitaz-base-files tazpkg ; do
pascal@341 1725 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
al@704 1726 [ -z "$pkg" ] && continue
al@704 1727 _ 'Adding implicit depends "%s"...' $pkg
pascal@341 1728 LIST="$pkg
pascal@341 1729 $LIST"
pascal@340 1730 done
pascal@314 1731
al@694 1732 for pkg in $LIST; do
pascal@121 1733 grep -qs ^$pkg$ $2-processed && continue
mojo@735 1734 [ -d "$root/var/lib/tazpkg/installed" ] &&
pankso@660 1735 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
pankso@6 1736 done
pankso@309 1737 rm -f $2-processed ;;
al@694 1738
al@694 1739
pankso@76 1740 add-flavor)
pascal@74 1741 # Install a set of packages from a flavor.
pankso@309 1742 install_flavor $2 ;;
al@694 1743
al@694 1744
pankso@76 1745 install-flavor)
pascal@74 1746 # Install a set of packages from a flavor and purge other ones.
pankso@309 1747 install_flavor $2 --purge ;;
al@694 1748
al@694 1749
pankso@76 1750 set-release)
paul@662 1751 # Change current release and upgrade packages.
pascal@74 1752 RELEASE=$2
pankso@76 1753 if [ -z "$RELEASE" ]; then
pankso@600 1754 newline
al@694 1755 _ 'Please specify the release you want on the command line.'
al@694 1756 echo "$(_ 'Example:') tazpkg set-release cooking"
pankso@600 1757 newline
pankso@76 1758 exit 0
pankso@76 1759 fi
al@700 1760 rm $PKGS_DB/mirror
pascal@74 1761 echo "$RELEASE" > /etc/slitaz-release
pascal@74 1762 tazpkg recharge && tazpkg upgrade
pascal@222 1763
pascal@222 1764 # Install missing depends
pascal@222 1765 cd $INSTALLED
pascal@222 1766 for i in * ; do
pascal@222 1767 DEPENDS=""
pascal@222 1768 . $i/receipt
pascal@222 1769 for j in $DEPENDS ; do
pascal@222 1770 [ -d $j ] || tazpkg get-install $j
pascal@222 1771 done
pankso@309 1772 done ;;
al@694 1773
al@694 1774
pankso@504 1775 remove|-r)
pankso@6 1776 # Remove packages.
al@603 1777 check_root $@
pankso@6 1778 check_for_package_on_cmdline
al@701 1779 check_for_installed_info
pankso@598 1780
al@694 1781 [ -n "$root" ] && ROOT="$root"
slaxemulator@370 1782 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
pankso@600 1783 newline
al@704 1784 _ 'Package "%s" is not installed.' $PACKAGE
pankso@6 1785 exit 0
pankso@6 1786 else
pascal@30 1787 ALTERED=""
pascal@30 1788 THE_PACKAGE=$PACKAGE # altered by receipt
slaxemulator@370 1789 for i in $(cd $ROOT$INSTALLED ; ls); do
slaxemulator@370 1790 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
pankso@37 1791 DEPENDS=""
slaxemulator@370 1792 . $ROOT$INSTALLED/$i/receipt
pascal@30 1793 case " $(echo $DEPENDS) " in
al@704 1794 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
pascal@30 1795 esac
pascal@30 1796 done
pascal@114 1797 EXTRAVERSION=""
slaxemulator@370 1798 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
pankso@6 1799 fi
pankso@600 1800 newline
pascal@30 1801 if [ -n "$ALTERED" ]; then
al@704 1802 _ 'The following packages depend on package "%s":' $PACKAGE
pascal@30 1803 for i in $ALTERED; do
pascal@30 1804 echo " $i"
pascal@30 1805 done
pascal@30 1806 fi
slaxemulator@370 1807 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
pascal@163 1808 if [ -n "$REFRESH" ]; then
al@704 1809 _ 'The following packages have been modified by package "%s":' $PACKAGE
pascal@163 1810 for i in $REFRESH; do
pascal@170 1811 echo " ${i%/modifiers}"
pascal@163 1812 done
pascal@163 1813 fi
gokhlayeh@423 1814 if [ "$auto" ]; then
al@603 1815 answer=0
gokhlayeh@423 1816 else
al@704 1817 confirm "$(_ 'Remove package "%s" (%s)? (y/N)' $PACKAGE $VERSION$EXTRAVERSION)"
al@603 1818 answer=$?
gokhlayeh@423 1819 fi
al@603 1820 if [ $answer = 0 ]; then
al@704 1821 title 'Removing package "%s"' $PACKAGE
pankso@38 1822 # Pre remove commands.
slaxemulator@371 1823 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
slaxemulator@533 1824 pre_remove $ROOT
pankso@38 1825 fi
al@603 1826 action "Removing all files installed..."
slaxemulator@370 1827 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
al@694 1828 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
al@694 1829 for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do
al@603 1830 [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
al@603 1831 done
al@603 1832 remove_with_path $ROOT$file
pascal@206 1833 done
pascal@255 1834 else
al@694 1835 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
slaxemulator@371 1836 remove_with_path $ROOT$file
pascal@255 1837 done
pascal@255 1838 fi
pankso@6 1839 status
slaxemulator@370 1840 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
slaxemulator@533 1841 post_remove $ROOT
pankso@51 1842 fi
al@694 1843
pankso@6 1844 # Remove package receipt.
al@603 1845 action "Removing package receipt..."
slaxemulator@370 1846 rm -rf $ROOT$INSTALLED/$PACKAGE
pankso@6 1847 status
al@694 1848
pascal@253 1849 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
al@700 1850 $PKGS_DB/installed.$SUM 2> /dev/null
al@694 1851
al@701 1852 # Update installed.info
al@701 1853 sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info
al@701 1854
pascal@183 1855 # Log this activity
al@603 1856 log_pkg Removed
al@701 1857
gokhlayeh@423 1858 if [ "$ALTERED" ]; then
gokhlayeh@423 1859 if [ "$auto" ]; then
al@603 1860 answer=0
gokhlayeh@423 1861 else
al@704 1862 confirm "$(_ 'Remove packages depending on package "%s"? (y/N)' $PACKAGE)"
al@603 1863 answer=$?
gokhlayeh@423 1864 fi
al@603 1865 if [ $answer = 0 ]; then
pascal@30 1866 for i in $ALTERED; do
slaxemulator@370 1867 if [ -d "$ROOT$INSTALLED/$i" ]; then
slaxemulator@371 1868 tazpkg remove $i $ROOTOPTS
pankso@37 1869 fi
pascal@30 1870 done
pascal@30 1871 fi
pascal@30 1872 fi
gokhlayeh@423 1873 if [ "$REFRESH" ]; then
gokhlayeh@423 1874 if [ "$auto" ]; then
al@603 1875 answer=0
gokhlayeh@423 1876 else
al@704 1877 confirm "$(_ 'Reinstall packages modified by package "%s"? (y/N)' $PACKAGE)"
al@603 1878 answer=$?
gokhlayeh@423 1879 fi
al@603 1880 if [ $answer = 0 ]; then
pascal@163 1881 for i in $REFRESH; do
slaxemulator@370 1882 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
al@704 1883 _ 'Check %s for reinstallation' "$INSTALLED/$i"
pascal@163 1884 continue
pascal@163 1885 fi
slaxemulator@370 1886 rm -r $ROOT$INSTALLED/$i
slaxemulator@371 1887 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
pascal@163 1888 done
pascal@163 1889 fi
pascal@163 1890 fi
pankso@6 1891 else
pankso@600 1892 newline
al@704 1893 _ 'Uninstallation of package "%s" cancelled.' $PACKAGE
pankso@6 1894 fi
pankso@600 1895 newline ;;
al@694 1896
al@694 1897
pankso@600 1898 extract|-e)
pankso@6 1899 # Extract .tazpkg cpio archive into a directory.
pankso@6 1900 check_for_package_on_cmdline
pankso@6 1901 check_for_package_file
al@704 1902 title 'Extracting package "%s"' $PACKAGE
al@694 1903
MikeDSmith25@135 1904 # If no directory destination is found on the cmdline
MikeDSmith25@135 1905 # we create one in the current dir using the package name.
pankso@6 1906 if [ -n "$TARGET_DIR" ]; then
pankso@6 1907 DESTDIR=$TARGET_DIR/$PACKAGE
pankso@6 1908 else
pankso@6 1909 DESTDIR=$PACKAGE
pankso@6 1910 fi
pankso@6 1911 mkdir -p $DESTDIR
al@694 1912
al@603 1913 action "Copying original package..."
pankso@9 1914 cp $PACKAGE_FILE $DESTDIR
pankso@6 1915 status
al@694 1916
pankso@6 1917 cd $DESTDIR
pankso@6 1918 extract_package
al@704 1919 [ -e "receipt" ] && \
al@704 1920 footer "$(_ 'Package "%s" is extracted to "%s"') $PACKAGE $DESTDIR"
al@603 1921 ;;
al@694 1922
al@694 1923
pascal@297 1924 recompress)
pascal@297 1925 # Recompress .tazpkg cpio archive with lzma.
pascal@297 1926 check_for_package_on_cmdline
pascal@297 1927 check_for_package_file
al@707 1928 title 'Recompressing package "%s"' $PACKAGE
pascal@297 1929 mkdir -p $TMP_DIR
al@694 1930
al@603 1931 action "Copying original package..."
pascal@297 1932 cp $PACKAGE_FILE $TMP_DIR
pascal@297 1933 status
al@694 1934
pascal@297 1935 cd $TMP_DIR
pascal@297 1936 extract_package
al@694 1937
al@707 1938 action "Recompressing the FS..."
gokhlayeh@383 1939 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@297 1940 rm -rf fs
pascal@297 1941 status
al@694 1942
al@603 1943 action "Creating new package..."
gokhlayeh@383 1944 find . -print | cpio -o -H newc --quiet > \
pascal@297 1945 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
pascal@297 1946 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
pascal@297 1947 $TOP_DIR/$(basename $PACKAGE_FILE)
pascal@297 1948 status
al@694 1949
pascal@297 1950 cd $TOP_DIR
al@603 1951 rm -rf $TMP_DIR
al@603 1952 separator; newline ;;
al@694 1953
al@694 1954
pascal@139 1955 list-config)
pascal@139 1956 # List configuration files installed.
al@724 1957 if [ -n "$box" ]; then
al@707 1958 mkdir -p $TMP_DIR; cd $TMP_DIR
pascal@210 1959 FILES="$INSTALLED/*/volatile.cpio.gz"
pascal@210 1960 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
pankso@279 1961 for i in $FILES; do
gokhlayeh@383 1962 zcat $i | cpio -idm --quiet > /dev/null
pascal@190 1963 find * -type f 2>/dev/null | while read file; do
pascal@190 1964 if [ ! -e /$file ]; then
al@694 1965 echo -n "----------|----|----|$(_n 'File lost')"
pascal@190 1966 else
al@694 1967 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
al@694 1968 cmp $file /$file > /dev/null 2>&1 || \
pascal@141 1969 echo -n "$(stat -c "%.16y" /$file)"
pascal@190 1970 fi
pascal@143 1971 echo "|/$file"
pascal@141 1972 done
pascal@141 1973 rm -rf *
pascal@146 1974 done
pascal@141 1975 cd $TOP_DIR
pascal@141 1976 rm -rf $TMP_DIR
pascal@141 1977 else
al@724 1978 im && title 'Configuration files'
pankso@279 1979 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@146 1980 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
pascal@146 1981 [ -f "$i" ] || continue
gokhlayeh@383 1982 zcat $i | cpio -t --quiet
pascal@146 1983 done | sed 's|^|/|' | sort
al@724 1984 im && footer
pankso@309 1985 fi ;;
al@694 1986
al@694 1987
pascal@139 1988 repack-config)
pascal@137 1989 # Create SliTaz package archive from configuration files.
al@707 1990 mkdir -p $TMP_DIR; cd $TMP_DIR
pascal@137 1991 CONFIG_VERSION=1.0
pascal@137 1992 mkdir config-$CONFIG_VERSION
pascal@137 1993 cd config-$CONFIG_VERSION
pankso@279 1994 for i in $INSTALLED/*/volatile.cpio.gz; do
gokhlayeh@383 1995 zcat $i | cpio -t --quiet
pascal@137 1996 done > files.list
pascal@137 1997 mkdir fs
pascal@137 1998 cd fs
gokhlayeh@416 1999 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
pascal@137 2000 mkdir -p etc/tazlito
pankso@279 2001 for i in $INSTALLED/*/receipt; do
pascal@137 2002 EXTRAVERSION=""
pascal@137 2003 . $i
pascal@137 2004 echo "$PACKAGE-$VERSION$EXTRAVERSION"
pascal@137 2005 done > etc/tazlito/config-packages.list
pascal@137 2006 cd ..
pascal@137 2007 echo "etc/tazlito/config-packages.list" >> files.list
al@603 2008 pkg_date=$(date +"%x %X")
pascal@137 2009 cat > receipt <<EOT
pascal@137 2010 # SliTaz package receipt.
pascal@137 2011
pascal@137 2012 PACKAGE="config"
pascal@137 2013 VERSION="$CONFIG_VERSION"
pascal@137 2014 CATEGORY="base-system"
al@707 2015 SHORT_DESC="$(_n 'User configuration backup on date %s' $pkg_date)"
pascal@137 2016 DEPENDS="$(ls $INSTALLED)"
pascal@137 2017 EOT
pascal@137 2018 cd ..
pascal@137 2019 tazpkg pack config-$CONFIG_VERSION
pascal@137 2020 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
pascal@137 2021 cd $TOP_DIR
pascal@137 2022 rm -rf $TMP_DIR
pascal@137 2023 ;;
al@694 2024
al@694 2025
pascal@18 2026 repack)
MikeDSmith25@135 2027 # Create SliTaz package archive from an installed package.
pascal@18 2028 check_for_package_on_cmdline
pascal@18 2029 check_for_receipt
pascal@114 2030 EXTRAVERSION=""
pascal@114 2031 . $INSTALLED/$PACKAGE/receipt
al@707 2032 title 'Repacking "%s"' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
al@707 2033
pascal@24 2034 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
al@707 2035 _ "Can't repack package \"%s\"" $PACKAGE
pascal@24 2036 exit 1
pascal@24 2037 fi
al@707 2038
pascal@21 2039 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
al@707 2040 _ "Can't repack, \"%s\" files have been modified by:" $PACKAGE
pascal@21 2041 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
pascal@21 2042 echo " $i"
pascal@21 2043 done
pascal@21 2044 exit 1
pascal@21 2045 fi
al@707 2046
pascal@18 2047 MISSING=""
pascal@63 2048 while read i; do
pascal@18 2049 [ -e "$i" ] && continue
pascal@63 2050 [ -L "$i" ] || MISSING="$MISSING\n $i"
pascal@63 2051 done < $INSTALLED/$PACKAGE/files.list
pascal@18 2052 if [ -n "$MISSING" ]; then
al@694 2053 _n "Can't repack, the following files are lost:"
pascal@63 2054 echo -e "$MISSING"
pascal@18 2055 exit 1
pascal@18 2056 fi
al@707 2057
al@707 2058 mkdir -p $TMP_DIR; cd $TMP_DIR
pascal@298 2059 FILES="fs.cpio.lzma\n"
al@707 2060 for i in $(ls $INSTALLED/$PACKAGE); do
al@707 2061 case $i in
al@707 2062 volatile.cpio.gz|modifiers) ;;
al@707 2063 *) cp $INSTALLED/$PACKAGE/$i .; FILES="$FILES$i\n" ;;
al@707 2064 esac
pascal@24 2065 done
al@707 2066
pascal@72 2067 ln -s / rootfs
pascal@72 2068 mkdir tmp
al@707 2069 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet | \
al@707 2070 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
pascal@72 2071 mv tmp/rootfs fs
al@707 2072
pascal@145 2073 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
pascal@145 2074 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
gokhlayeh@416 2075 { cd fs; cpio -idm --quiet; cd ..; }
pascal@145 2076 fi
al@707 2077
gokhlayeh@409 2078 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
pascal@107 2079 . $INSTALLED/$PACKAGE/receipt
pascal@107 2080 repack_cleanup fs
pascal@107 2081 fi
al@707 2082
slaxemulator@588 2083 if [ -f $INSTALLED/$PACKAGE/$CHECKSUM ]; then
slaxemulator@588 2084 sed 's, , fs,' < $INSTALLED/$PACKAGE/$CHECKSUM | \
slaxemulator@588 2085 $CHECKSUM -s -c || {
al@707 2086 _ "Can't repack, %s error." $CHECKSUM
pascal@107 2087 cd $TOP_DIR
pascal@214 2088 rm -rf $TMP_DIR
pascal@107 2089 exit 1
pascal@214 2090 }
pascal@107 2091 fi
al@707 2092
gokhlayeh@383 2093 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
gokhlayeh@383 2094 echo -e "$FILES" | cpio -o -H newc --quiet > \
pascal@114 2095 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
pascal@74 2096 cd $TOP_DIR
pascal@18 2097 \rm -R $TMP_DIR
al@707 2098 _ 'Package "%s" repacked successfully.' $PACKAGE
al@707 2099 _ 'Size: %s' "$(du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg)"
pankso@600 2100 newline ;;
al@694 2101
al@694 2102
pankso@6 2103 pack)
pankso@600 2104 # Create SliTaz package archive using cpio and lzma.
pankso@600 2105 # TODO: Cook also pack packages, we should share code in libpkg.sh
pankso@6 2106 check_for_package_on_cmdline
pankso@6 2107 cd $PACKAGE
pankso@6 2108 if [ ! -f "receipt" ]; then
al@694 2109 _ 'Receipt is missing. Please read the documentation.'
pankso@6 2110 exit 0
pankso@6 2111 else
al@707 2112 title 'Packing package "%s"' $PACKAGE
MikeDSmith25@135 2113 # Create files.list with redirecting find outpout.
al@603 2114 action "Creating the list of files..."
al@603 2115 cd fs
pankso@6 2116 find . -type f -print > ../files.list
pankso@6 2117 find . -type l -print >> ../files.list
pankso@6 2118 cd .. && sed -i s/'^.'/''/ files.list
pankso@6 2119 status
al@707 2120 action 'Creating %s of files...' $CHECKSUM
pascal@138 2121 while read file; do
pascal@138 2122 [ -L "fs$file" ] && continue
pascal@138 2123 [ -f "fs$file" ] || continue
pascal@158 2124 case "$file" in
al@694 2125 /lib/modules/*/modules.*|*.pyc) continue;;
pascal@158 2126 esac
slaxemulator@588 2127 $CHECKSUM "fs$file" | sed 's/ fs/ /'
slaxemulator@588 2128 done < files.list > $CHECKSUM
pascal@138 2129 status
slaxemulator@588 2130 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
pascal@147 2131 description.txt 2> /dev/null | awk \
pascal@147 2132 '{ sz=$1 } END { print sz }')
pankso@6 2133 # Build cpio archives.
al@707 2134 action "Compressing the FS..."
gokhlayeh@383 2135 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@138 2136 rm -rf fs
pascal@147 2137 status
pascal@298 2138 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
slaxemulator@588 2139 $CHECKSUM description.txt 2> /dev/null | awk \
pascal@147 2140 '{ sz=$1 } END { print sz }')
al@603 2141 action "Updating receipt sizes..."
pankso@279 2142 sed -i s/^PACKED_SIZE.*$// receipt
pankso@279 2143 sed -i s/^UNPACKED_SIZE.*$// receipt
pascal@147 2144 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@147 2145 status
al@603 2146 action "Creating full cpio archive..."
gokhlayeh@383 2147 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
pascal@147 2148 status
al@603 2149 action "Restoring original package tree..."
gokhlayeh@383 2150 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pascal@147 2151 status
pascal@298 2152 rm fs.cpio.lzma && cd ..
al@707 2153 footer "$(_ 'Package "%s" compressed successfully.' $PACKAGE)"
al@603 2154 pkg_size=$(du -sh $PACKAGE.tazpkg)
al@707 2155 _ 'Size: %s' $pkg_size
pankso@600 2156 newline
pankso@309 2157 fi ;;
al@694 2158
al@694 2159
pankso@6 2160 recharge)
pankso@6 2161 # Recharge packages.list from a mirror.
pankso@581 2162 #
al@694 2163 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
paul@607 2164 # must have only the chosen main mirror.
pankso@581 2165 #
al@603 2166 check_root $@
pankso@598 2167
gokhlayeh@448 2168 ARG=$2
gokhlayeh@448 2169 if [ "$root" ]; then
al@700 2170 PKGS_DB=$root$PKGS_DB
gokhlayeh@448 2171 [ "${2#--}" != "$2" ] && ARG=$3
gokhlayeh@448 2172 fi
gokhlayeh@448 2173 if [ "$ARG" = main ]; then
al@700 2174 repository_to_recharge=$PKGS_DB
gokhlayeh@448 2175 elif [ "$ARG" ]; then
al@700 2176 if [ -d "$PKGS_DB/undigest/$ARG" ]; then
al@700 2177 repository_to_recharge=$PKGS_DB/undigest/$ARG
gokhlayeh@430 2178 else
al@700 2179 repo="$PKGS_DB/undigest/$ARG"
al@707 2180 _ "Repository \"%s\" doesn't exist." $repo >&2
gokhlayeh@430 2181 exit 1
gokhlayeh@430 2182 fi
gokhlayeh@430 2183 else
al@700 2184 repository_to_recharge="$PKGS_DB $PKGS_DB/undigest/*"
pankso@598 2185 fi
gokhlayeh@430 2186 for path in $repository_to_recharge; do
pascal@187 2187 [ -f $path/mirror ] || continue
gokhlayeh@430 2188 cd $path
pankso@598 2189
gokhlayeh@430 2190 # Quietly check if recharging is needed.
gokhlayeh@430 2191 [ -f ID ] && mv ID ID.bak
mojo@575 2192 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
al@694 2193 if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
al@700 2194 if [ "$path" = "$PKGS_DB" ]; then
gokhlayeh@430 2195 repository_name=Main
gokhlayeh@430 2196 else
al@603 2197 base_path="$(basename $path)"
al@707 2198 repository_name="$(_n 'Undigest %s' $base_path)"
gokhlayeh@430 2199 fi
al@707 2200 _ 'Repository "%s" is up to date.' $repository_name
gokhlayeh@430 2201 rm ID.bak
gokhlayeh@430 2202 continue
gokhlayeh@430 2203 fi
gokhlayeh@432 2204
gokhlayeh@432 2205 # Don't let ID be a symlink when using local repository.
gokhlayeh@432 2206 if [ -f ID ]; then
gokhlayeh@432 2207 mv -f ID ID.bak
gokhlayeh@432 2208 cat ID.bak > ID
slaxemulator@576 2209 rm ID.bak
gokhlayeh@432 2210 fi
pankso@598 2211
pankso@600 2212 newline
al@700 2213 if [ "$path" != "$PKGS_DB" ]; then
al@603 2214 base_path="$(basename $path)"
al@707 2215 _ 'Recharging undigest %s:' $base_path
pascal@187 2216 fi
gokhlayeh@430 2217
pascal@187 2218 if [ -f "packages.list" ]; then
al@603 2219 action "Creating backup of the last packages list..."
slaxemulator@588 2220 for i in packages.desc packages.$SUM packages.txt \
pankso@580 2221 packages.list packages.equiv files.list.lzma \
al@699 2222 extra.list mirrors packages.info
pankso@580 2223 do
gokhlayeh@438 2224 mv -f $i $i.bak 2>/dev/null
gokhlayeh@438 2225 done
pascal@187 2226 status
pascal@187 2227 fi
gokhlayeh@546 2228
al@699 2229 for i in desc $SUM txt list equiv; do
mojo@575 2230 download_from "$(cat mirror)" packages.$i
gokhlayeh@438 2231 done
pankso@598 2232 download_from "$(cat mirror)" files.list.lzma
pascal@692 2233 download_from "$(cat mirror)" extra.list
al@699 2234 download_from "$(sed 's|packages/.*||' mirror)" mirrors
al@699 2235
al@699 2236 # packages.info
al@699 2237 download_from "$(cat mirror)" packages.info.lzma
al@699 2238 lzma d packages.info.lzma packages.info
al@699 2239 rm packages.info.lzma
pankso@598 2240
pascal@187 2241 if [ -f "packages.list.bak" ]; then
pascal@187 2242 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
pascal@692 2243 [ -f "extra.list.bak" ] &&
pascal@692 2244 diff -u extra.list.bak extra.list | grep ^+[a-z] >> packages.diff
pascal@187 2245 sed -i s/+// packages.diff
al@603 2246 title 'Mirrored packages diff'
pascal@187 2247 cat packages.diff
al@701 2248 new_pkgs=$(wc -l < packages.diff)
al@707 2249 footer "$(emsg "$(_p \
al@707 2250 '%s new package on the mirror.' \
al@707 2251 '%s new packages on the mirror.' $new_pkgs \
al@707 2252 "<c 32>$new_pkgs</c>")")"
pankso@6 2253 else
al@707 2254 footer "$(longline "$(_ "Last %s is ready to use. Note that \
al@707 2255 next time you recharge the list, a list of differences will be displayed to \
al@710 2256 show new and upgradeable packages." packages.list)")"
pascal@187 2257 fi
pankso@309 2258 done ;;
al@694 2259
al@694 2260
al@603 2261 help-up)
al@603 2262 # Options available for the command: up
al@603 2263 newline; usage_up; newline
pankso@645 2264 exit 1 ;;
al@694 2265
al@694 2266
al@603 2267 up|upgrade)
al@707 2268 check_root
pankso@466 2269 #
paul@476 2270 # This is the new way to upgrade packages making 'upgrade' and
pankso@466 2271 # upgradeable out-of-date. This new way is much, much more faster!
paul@476 2272 # Look into installed packages and get data from receipt, it is fast
paul@476 2273 # and easy to handle vars after using only md5sum to compare packages
pankso@598 2274 #
al@691 2275 for opt in $@; do
pankso@466 2276 case "$opt" in
al@691 2277 --recharge|-r) tazpkg recharge ;;
al@691 2278 --install|-i) install="y" ;;
al@691 2279 --check|-c) install="n" ;;
pankso@466 2280 esac
pankso@466 2281 done
pankso@598 2282 time=$(date +%s)
al@744 2283
gokhlayeh@536 2284 look_for_priority
gokhlayeh@536 2285 for repo in $priority; do
gokhlayeh@536 2286 pkg_list=$repo/packages.list
al@691 2287 mtime=$(find $pkg_list -mtime +7)
gokhlayeh@536 2288 if [ "$mtime" ]; then
al@744 2289 if [ "$repo" == "$PKGS_DB" ]; then
gokhlayeh@536 2290 repo_name=main
gokhlayeh@536 2291 else
gokhlayeh@536 2292 repo_name="${repo##*/}"
slaxemulator@516 2293 fi
al@707 2294 _ 'List "%s" is older than one week... Recharging.' $pkg_list
gokhlayeh@536 2295 tazpkg recharge $repo_name
gokhlayeh@536 2296 fi
gokhlayeh@536 2297 done
al@744 2298
al@707 2299 emsg "<n>$(_ 'Package')<i 28> $(_ 'Version')<i 48> $(_ 'Status')<->"
al@744 2300
slaxemulator@535 2301 cd $INSTALLED
pankso@600 2302 newline > $UP_LIST
ben@483 2303 blocked_count=0
al@744 2304 installed_sum=$PKGS_DB/installed.$SUM
al@744 2305
al@691 2306 for pkg in *; do
al@691 2307 [ ! -d $pkg ] && continue
pankso@485 2308 unset VERSION EXTRAVERSION
pankso@466 2309 . $pkg/receipt
pankso@485 2310 md5=$(fgrep " $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
slaxemulator@588 2311 $installed_sum | awk '{print $1}')
gokhlayeh@536 2312 for repo in $priority; do
gokhlayeh@536 2313 pkg_desc=$repo/packages.desc
gokhlayeh@536 2314 pkg_list=$repo/packages.list
slaxemulator@588 2315 pkg_sum=$repo/packages.$SUM
gokhlayeh@536 2316
slaxemulator@588 2317 if ! fgrep -q "$md5 $PACKAGE-" $pkg_sum; then
paul@662 2318 # Jump to next repository in priority if pkg doesn't exist
gokhlayeh@536 2319 # in this one.
gokhlayeh@536 2320 grep -q ^$PACKAGE- $pkg_list || continue
gokhlayeh@536 2321
al@603 2322 emsg -n "$PACKAGE<i 28> $VERSION"
pankso@598 2323
al@700 2324 # Skip pkgs listed in $PKGS_DB/blocked-packages.list
gokhlayeh@536 2325 if $(grep -qs "^$PACKAGE" $BLOCKED); then
pankso@598 2326 blocked_count=$(($blocked_count + 1))
al@694 2327 emsg "<i 48><c 31> $(_ 'Blocked')</c>"
gokhlayeh@536 2328 break
gokhlayeh@536 2329 fi
pankso@598 2330
gokhlayeh@536 2331 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}')
pankso@598 2332
ben@483 2333 if [ "$VERSION" == "$new" ]; then
al@694 2334 emsg "<i 48><c 34> $(_ 'New build')</c>"
ben@483 2335 else
al@707 2336 emsg "<i 48><c 32> $(_ 'New version %s' $new)</c>"
ben@483 2337 fi
ben@483 2338 echo "$PACKAGE" >> $UP_LIST
gokhlayeh@536 2339 break
pankso@466 2340 fi
gokhlayeh@536 2341 done
pankso@466 2342 done
pankso@466 2343 sed -i /^$/d $UP_LIST
pascal@648 2344 upnb=$(wc -l < $UP_LIST)
pankso@496 2345 pkgs=$(ls | wc -l)
pankso@598 2346 time=$(($(date +%s) - $time))
al@744 2347 if [ "$upnb" == 0 ]; then
pankso@480 2348 install="n"
al@694 2349 _ 'System is up-to-date...'
pankso@598 2350 fi
al@707 2351
al@707 2352 footer "$(emsg "$(_p \
al@707 2353 '%s installed package scanned in %ds' \
al@707 2354 '%s installed packages scanned in %ds' $pkgs \
al@707 2355 "<c 32>$pkgs</c>" $time)")"
al@707 2356
pankso@598 2357 if [ "$upnb" != 0 ]; then
al@707 2358 blocked="$(_p \
al@744 2359 '%s blocked' \
al@744 2360 '%s blocked' $blocked_count \
al@707 2361 $blocked_count)"
al@707 2362
al@707 2363 boldify "$(_p \
al@707 2364 'You have %s available upgrade (%s)' \
al@707 2365 'You have %s available upgrades (%s)' $upnb \
al@707 2366 $upnb "$blocked")"
al@603 2367 newline
pankso@480 2368 fi
pankso@466 2369 # Pkgs to upgrade ? Skip, let install them all or ask user
pankso@466 2370 [ "$install" == "n" ] && exit 0
pankso@480 2371 if [ "$upnb" -gt 0 ]; then
pankso@466 2372 if [ "$install" == "y" ]; then
pankso@466 2373 continue
pankso@466 2374 else
al@707 2375 confirm "$(_ 'Do you wish to install them now? (y/N)')"
al@707 2376 answer=$?
pankso@466 2377 fi
al@707 2378 case "$answer" in
al@707 2379 0)
al@691 2380 for pkg in $(cat $UP_LIST); do
pankso@466 2381 echo 'y' | tazpkg get-install $pkg --forced
pankso@502 2382 done
paul@554 2383 # List is generated each time and must be cleaned so
paul@662 2384 # tazpkg-notify doesn't find upgrades anymore.
al@707 2385 rm $UP_LIST; touch $UP_LIST ;;
pankso@466 2386 *)
al@694 2387 _ 'Leaving without any upgrades installed.'
al@603 2388 newline
pankso@466 2389 exit 0 ;;
pankso@466 2390 esac
pankso@466 2391 fi
pankso@600 2392 newline ;;
al@694 2393
al@694 2394
pascal@152 2395 bugs)
pascal@152 2396 # Show known bugs in package(s)
pascal@152 2397 cd $INSTALLED
pascal@159 2398 shift
pascal@159 2399 LIST=$@
al@694 2400 [ -n "$LIST" ] || LIST=$(ls)
al@694 2401 MSG=$(_n 'No known bugs.')
pascal@152 2402 for PACKAGE in $LIST; do
pascal@152 2403 BUGS=""
pascal@154 2404 EXTRAVERSION=""
pascal@152 2405 . $PACKAGE/receipt
pascal@152 2406 if [ -n "$BUGS" ]; then
al@694 2407 MSG=$(_n 'Bug list completed')
pankso@600 2408 newline
al@707 2409 _ 'Bugs in package "%s" version %s:' $PACKAGE $VERSION$EXTRAVERSION
pascal@152 2410 cat <<EOT
pascal@152 2411 $BUGS
pascal@152 2412 EOT
pascal@152 2413 fi
pascal@152 2414 done
pankso@309 2415 echo "$MSG" ;;
al@694 2416
al@694 2417
pascal@25 2418 check)
MikeDSmith25@135 2419 # Check installed packages set.
al@603 2420 check_root $@
pankso@598 2421
gokhlayeh@386 2422 # Get repositories priority list.
gokhlayeh@386 2423 look_for_priority
pankso@598 2424
pascal@25 2425 cd $INSTALLED
al@694 2426 for PACKAGE in $(ls); do
al@707 2427
pascal@122 2428 if [ ! -f $PACKAGE/receipt ]; then
al@707 2429 _ 'The package "%s" installation has not completed' $PACKAGE
pascal@122 2430 continue
pascal@122 2431 fi
al@707 2432
pascal@29 2433 DEPENDS=""
pascal@114 2434 EXTRAVERSION=""
pascal@29 2435 . $PACKAGE/receipt
pascal@29 2436 if [ -s $PACKAGE/modifiers ]; then
al@707 2437 _ 'The package "%s" has been modified by:' $PACKAGE-$VERSION$EXTRAVERSION
pascal@29 2438 for i in $(cat $PACKAGE/modifiers); do
pascal@29 2439 echo " $i"
pascal@29 2440 done
pascal@29 2441 fi
al@707 2442
al@707 2443 MSG="$(_n 'Files lost from package "%s":' $PACKAGE-$VERSION$EXTRAVERSION)\n"
pascal@25 2444 while read file; do
pascal@25 2445 [ -e "$file" ] && continue
pascal@25 2446 if [ -L "$file" ]; then
al@694 2447 MSG="$MSG $(_n 'target of symlink')"
pascal@25 2448 fi
pascal@25 2449 echo -e "$MSG $file"
pascal@25 2450 MSG=""
pascal@25 2451 done < $PACKAGE/files.list
al@707 2452
al@707 2453 MSG="$(_n 'Missing dependencies for package "%s":' $PACKAGE-$VERSION$EXTRAVERSION)\n"
pascal@25 2454 for i in $DEPENDS; do
pascal@25 2455 [ -d $i ] && continue
pascal@290 2456 [ -d $(equivalent_pkg $i) ] && continue
pascal@25 2457 echo -e "$MSG $i"
pascal@25 2458 MSG=""
pascal@25 2459 done
al@707 2460
al@707 2461 MSG="$(_n 'Dependencies loop between "%s" and:' $PACKAGE)\n"
pascal@122 2462 ALL_DEPS=""
pascal@122 2463 check_for_deps_loop $PACKAGE $DEPENDS
pascal@25 2464 done
al@694 2465
al@694 2466 _ 'Looking for known bugs...'
pascal@152 2467 tazpkg bugs
al@694 2468
al@707 2469 if [ "$2" == "--full" ]; then
al@707 2470 separator
al@707 2471
slaxemulator@588 2472 for file in */$CHECKSUM; do
pascal@177 2473 CONFIG_FILES=""
pascal@177 2474 . $(dirname "$file")/receipt
pascal@106 2475 [ -s "$file" ] || continue
pascal@177 2476 while read md5 f; do
pascal@177 2477 [ -f $f ] || continue
pascal@177 2478 for i in $CONFIG_FILES; do
pascal@177 2479 case "$f" in
al@694 2480 $i|$i/*) continue 2;;
pascal@177 2481 esac
pascal@177 2482 done
pascal@177 2483 echo "$md5 $f"
slaxemulator@588 2484 done < "$file" | $CHECKSUM -c - 2> /dev/null | \
al@707 2485 grep -v OK$ | sed "s/FAILED$/$CHECKSUM MISMATCH/"
pascal@106 2486 done
al@707 2487
pascal@60 2488 FILES=" "
pascal@60 2489 for file in $(cat */files.list); do
pascal@60 2490 [ -d "$file" ] && continue
pascal@60 2491 case "$FILES" in *\ $file\ *) continue;; esac
pascal@377 2492 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
pascal@60 2493 wc -l) -gt 1 ] || continue
pascal@60 2494 FILES="$FILES$file "
al@707 2495 _ 'The following packages provide file "%s":' $file
al@694 2496 grep -l "^$(echo $file | grepesc)$" */files.list | \
al@694 2497 while read f; do
pascal@60 2498 pkg=${f%/files.list}
pascal@60 2499 if [ -f $pkg/modifiers ]; then
al@707 2500 overriders=$(_n '(overridden by %s)' "$(tr '\n' ' ' | sed 's| $||' < $pkg/modifiers)")
al@603 2501 else
al@633 2502 overriders=''
pascal@60 2503 fi
al@633 2504 echo -n " $pkg $overriders"
pankso@600 2505 newline
pascal@60 2506 done
pascal@60 2507 done
al@707 2508
al@694 2509 MSG="$(_n 'No package has installed the following files:')\n"
al@694 2510 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
al@694 2511 while read file; do
pascal@73 2512 case "$file" in *\[*) continue;; esac
pascal@377 2513 grep -q "^$(echo $file | grepesc)$" */files.list && continue
pascal@73 2514 echo -e "$MSG $file"
pascal@73 2515 MSG=""
pascal@73 2516 done
pascal@60 2517 fi
al@694 2518 _ 'Check completed.'; echo ;;
al@694 2519
al@694 2520
pankso@10 2521 block)
pankso@10 2522 # Add a pkg name to the list of blocked packages.
al@603 2523 check_root $@
pankso@10 2524 check_for_package_on_cmdline
pankso@600 2525 newline
pascal@223 2526 if grep -qs "^$PACKAGE" $BLOCKED; then
al@707 2527 _ 'Package "%s" is already in the blocked packages list.' $PACKAGE
pankso@10 2528 else
al@707 2529 action 'Add package "%s" to: %s...' $PACKAGE $BLOCKED
pankso@10 2530 echo $PACKAGE >> $BLOCKED
pankso@10 2531 status
pascal@183 2532 # Log this activity
pascal@183 2533 . $INSTALLED/$PACKAGE/receipt
al@603 2534 log_pkg Blocked
pankso@10 2535 fi
pankso@600 2536 newline ;;
al@694 2537
al@694 2538
pankso@10 2539 unblock)
MikeDSmith25@135 2540 # Remove a pkg name from the list of blocked packages.
al@603 2541 check_root $@
pankso@10 2542 check_for_package_on_cmdline
pankso@600 2543 newline
pascal@223 2544 if grep -qs "^$PACKAGE" $BLOCKED; then
al@707 2545 action 'Removing package "%s" from: %s...' $PACKAGE $BLOCKED
pankso@10 2546 sed -i s/$PACKAGE/''/ $BLOCKED
pankso@10 2547 sed -i '/^$/d' $BLOCKED
pankso@10 2548 status
pascal@183 2549 # Log this activity
pascal@183 2550 . $INSTALLED/$PACKAGE/receipt
al@603 2551 log_pkg Unblocked
pankso@10 2552 else
al@707 2553 _ 'Package "%s" is not in the blocked packages list.' $PACKAGE
pankso@10 2554 fi
pankso@600 2555 newline ;;
al@694 2556
al@694 2557
pankso@6 2558 get)
al@603 2559 # Download a package with wget.
al@603 2560 check_root $@
pankso@6 2561 check_for_package_on_cmdline
pankso@6 2562 check_for_packages_list
pankso@598 2563
slaxemulator@478 2564 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
slaxemulator@478 2565 if [ "$rootconfig" ]; then
slaxemulator@478 2566 if [ "$root" ]; then
slaxemulator@478 2567 CACHE_DIR=$root/$CACHE_DIR
slaxemulator@478 2568 SAVE_CACHE_DIR=$CACHE_DIR
al@700 2569 PKGS_DB=$root/$PKGS_DB
slaxemulator@478 2570 else
al@694 2571 _ 'rootconfig needs --root= option used.' >&2
slaxemulator@478 2572 exit 1
slaxemulator@478 2573 fi
slaxemulator@478 2574 fi
pankso@598 2575
gokhlayeh@386 2576 # Get repositories priority list.
gokhlayeh@386 2577 look_for_priority
pankso@598 2578
slaxemulator@478 2579 CURRENT_DIR=$PWD
pankso@6 2580 check_for_package_in_list
slaxemulator@478 2581 cd $CACHE_DIR
slaxemulator@478 2582 if [ -f "$PACKAGE.tazpkg" ]; then
al@707 2583 _ 'Package "%s" already in the cache' $PACKAGE
slaxemulator@478 2584 # Check package download was finished
slaxemulator@478 2585 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
al@707 2586 _ 'Continuing package "%s" download' $PACKAGE
slaxemulator@478 2587 download $PACKAGE.tazpkg
slaxemulator@478 2588 }
slaxemulator@588 2589 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
slaxemulator@378 2590 rm -f $PACKAGE.tazpkg
slaxemulator@378 2591 download $PACKAGE.tazpkg
slaxemulator@378 2592 fi
slaxemulator@378 2593 else
slaxemulator@378 2594 download $PACKAGE.tazpkg
slaxemulator@378 2595 fi
slaxemulator@478 2596 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
pankso@658 2597 cp -a $PACKAGE_FILE $CURRENT_DIR ;;
al@694 2598
al@694 2599
pankso@504 2600 get-install|-gi)
pankso@6 2601 # Download and install a package.
al@603 2602 check_root $@
pankso@6 2603 check_for_package_on_cmdline
pankso@6 2604 check_for_packages_list
pankso@598 2605
pascal@121 2606 DO_CHECK=""
gokhlayeh@406 2607 [ "$forced" ] && DO_CHECK=no
gokhlayeh@429 2608 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
gokhlayeh@406 2609 [ "$list" ] && INSTALL_LIST="$list"
gokhlayeh@431 2610 if [ "$rootconfig" ]; then
gokhlayeh@429 2611 if [ "$root" ]; then
gokhlayeh@429 2612 CACHE_DIR=$root/$CACHE_DIR
gokhlayeh@436 2613 SAVE_CACHE_DIR=$CACHE_DIR
al@700 2614 PKGS_DB=$root/$PKGS_DB
gokhlayeh@429 2615 else
al@694 2616 _ 'rootconfig needs --root= option used.' >&2
gokhlayeh@429 2617 exit 1
gokhlayeh@429 2618 fi
gokhlayeh@429 2619 fi
gokhlayeh@436 2620
gokhlayeh@436 2621 # Get repositories priority list.
gokhlayeh@436 2622 look_for_priority
gokhlayeh@436 2623
pascal@202 2624 AUTOEXEC="no"
gokhlayeh@416 2625 if ! check_for_package_in_list check; then
pascal@648 2626 CACHE_DIR="${CACHE_DIR%/*}/get"
pascal@648 2627 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
pascal@648 2628 if download_get_script $PACKAGE /tmp/$PACKAGE.$$ ; then
pascal@648 2629 install_package_from_get_script /tmp/$PACKAGE.$$ $ROOT
pascal@202 2630 exit 0
pascal@648 2631 else
pascal@648 2632 PACKAGE=get-$PACKAGE
pascal@648 2633 AUTOEXEC=$PACKAGE
pascal@648 2634 check_for_package_in_list
pascal@648 2635 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
pascal@648 2636 $AUTOEXEC $ROOT
pascal@648 2637 exit 0
pascal@648 2638 fi
pascal@202 2639 fi
gokhlayeh@416 2640 fi
pankso@6 2641 # Check if forced install.
gokhlayeh@423 2642 if ! [ "$forced" ]; then
pascal@121 2643 check_for_installed_package $ROOT
pankso@6 2644 fi
pankso@6 2645 cd $CACHE_DIR
pankso@6 2646 if [ -f "$PACKAGE.tazpkg" ]; then
al@707 2647 _ 'Package "%s" already in the cache' $PACKAGE
MikeDSmith25@135 2648 # Check package download was finished
gokhlayeh@409 2649 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
al@707 2650 _ 'Continuing package "%s" download' $PACKAGE
pascal@108 2651 download $PACKAGE.tazpkg
pascal@108 2652 }
slaxemulator@588 2653 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
slaxemulator@375 2654 rm -f $PACKAGE.tazpkg
pascal@374 2655 download $PACKAGE.tazpkg
pascal@374 2656 fi
pankso@6 2657 else
pankso@600 2658 newline
pascal@17 2659 download $PACKAGE.tazpkg
pankso@6 2660 fi
pankso@14 2661 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
al@700 2662 [ "$rootconfig" ] && PKGS_DB=${PKGS_DB#$root}
pascal@121 2663 install_package $ROOT
pankso@598 2664 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
pankso@598 2665 update_desktop_database $ROOT
slaxemulator@369 2666 update_mime_database $ROOT ;;
al@694 2667
al@694 2668
pankso@504 2669 clean-cache|-cc)
pankso@6 2670 # Remove all downloaded packages.
al@603 2671 check_root $@
pankso@499 2672 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
al@707 2673 size=$(du -hs $CACHE_DIR | cut -f1 | sed 's|\.0||'); [ $files == "0" ] && size="0K"
al@707 2674 title 'Path: %s' $CACHE_DIR
al@603 2675 action "Cleaning cache directory..."
pankso@6 2676 rm -rf $CACHE_DIR/*
al@603 2677 status
al@707 2678
al@707 2679 footer "$(_p \
al@707 2680 '%s file removed from cache (%s).' \
al@707 2681 '%s files removed from cache (%s).' $files \
al@707 2682 "$(colorize 32 "$files")" $size)"
al@694 2683 ;;
al@694 2684
al@694 2685
pascal@187 2686 list-undigest)
pascal@187 2687 # list undigest URLs.
pascal@187 2688 if [ "$2" = "--box" ]; then
al@700 2689 for i in $PKGS_DB/undigest/*/mirror; do
pascal@187 2690 [ -f $i ] || continue
pascal@187 2691 echo "$(basename $(dirname $i))|$(cat $i)"
pascal@187 2692 done
pascal@187 2693 else
al@603 2694 title 'Current undigest(s)'
al@700 2695 for i in $PKGS_DB/undigest/*/mirror; do
pascal@187 2696 if [ ! -f $i ]; then
al@694 2697 _ 'No undigest mirror found.'
pascal@187 2698 exit 1
pascal@187 2699 fi
pascal@187 2700 echo "$(basename $(dirname $i)) $(cat $i)"
pascal@187 2701 done
pankso@600 2702 newline
pankso@309 2703 fi ;;
al@694 2704
al@694 2705
pascal@187 2706 remove-undigest)
pascal@187 2707 # remove undigest URL.
al@603 2708 check_root $@
gokhlayeh@388 2709 undigest="$2"
al@700 2710 if [ -d $PKGS_DB/undigest/$2 ]; then
al@707 2711 confirm "$(_ 'Remove "%s" undigest? (y/N)' $undigest)"
al@603 2712 if [ $? = 0 ]; then
al@707 2713 action 'Removing "%s" undigest...' $undigest
al@700 2714 rm -rf $PKGS_DB/undigest/$2
pascal@187 2715 status
al@700 2716 rmdir $PKGS_DB/undigest 2> /dev/null
pascal@187 2717 fi
pascal@187 2718 else
al@707 2719 _ 'Undigest "%s" not found' $undigest
pankso@309 2720 fi ;;
al@694 2721
al@694 2722
pascal@187 2723 add-undigest|setup-undigest)
pascal@187 2724 # Add undigest URL.
al@603 2725 check_root $@
pascal@187 2726 undigest=$2
al@700 2727 [ -d $PKGS_DB/undigest ] || mkdir $PKGS_DB/undigest
pascal@187 2728 if [ -z "$undigest" ]; then
pascal@187 2729 i=1
al@700 2730 while [ -d $PKGS_DB/undigest/$i ]; do
pascal@187 2731 i=$(($i+1))
pascal@187 2732 done
pascal@187 2733 undigest=$i
pascal@187 2734 fi
al@700 2735 if [ ! -d $PKGS_DB/undigest/$undigest ]; then
al@707 2736 _ 'Creating new undigest "%s".' $undigest
al@700 2737 mkdir $PKGS_DB/undigest/$undigest
pascal@187 2738 fi
al@700 2739 setup_mirror $PKGS_DB/undigest/$undigest $3 ;;
al@694 2740
al@694 2741
pankso@600 2742 setup-mirror|-sm)
pankso@6 2743 # Change mirror URL.
al@603 2744 check_root $@
al@700 2745 setup_mirror $PKGS_DB $2 ;;
al@694 2746
al@694 2747
erjo@56 2748 reconfigure)
erjo@56 2749 # Replay post_install from receipt
erjo@56 2750 check_for_package_on_cmdline
al@603 2751 check_root $@
pascal@250 2752 ROOT=""
pascal@250 2753 while [ -n "$3" ]; do
pascal@250 2754 case "$3" in
al@694 2755 --root=*)
al@694 2756 ROOT="${3#--root=}/" ;;
al@694 2757 *)
al@694 2758 shift 2
al@694 2759 u_opt="$*"
al@694 2760 newline >&2
al@707 2761 _ 'Unknown option "%s".' $u_opt >&2
al@694 2762 exit 1 ;;
pascal@250 2763 esac
pascal@250 2764 shift
pascal@250 2765 done
pascal@250 2766 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
pascal@250 2767 check_for_receipt $ROOT
erjo@56 2768 # Check for post_install
pascal@250 2769 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@250 2770 . $ROOT$INSTALLED/$PACKAGE/receipt
pascal@250 2771 post_install $ROOT
pascal@183 2772 # Log this activity
al@603 2773 [ -n "$ROOT" ] || log_pkg Reconfigured
pankso@279 2774 else
pankso@600 2775 newline
al@707 2776 _ 'Nothing to do for package "%s".' $PACKAGE
erjo@56 2777 fi
erjo@56 2778 else
pankso@600 2779 newline
al@707 2780 _ 'Package "%s" is not installed.' $PACKAGE
al@707 2781 _ 'Install package with "%s" or "%s"' 'tazpkg install' 'tazpkg get-install'
pankso@600 2782 newline
pankso@309 2783 fi ;;
al@694 2784
al@694 2785
pankso@55 2786 shell)
pankso@653 2787 # TazPKG SHell
pankso@55 2788 if test $(id -u) = 0 ; then
pankso@55 2789 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
pankso@55 2790 else
pankso@55 2791 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
pankso@55 2792 fi
pankso@55 2793 if [ ! "$2" = "--noheader" ]; then
pankso@55 2794 clear
pankso@653 2795 title 'TazPKG SHell.'
al@694 2796 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
pankso@600 2797 newline
pankso@55 2798 fi
al@694 2799 while true; do
pankso@55 2800 echo -en "$PROMPT"; read cmd
pankso@55 2801 case $cmd in
pankso@55 2802 q|quit)
pankso@55 2803 break ;;
pankso@55 2804 shell)
al@694 2805 _ 'You are already running a TazPKG SHell.' ;;
pankso@55 2806 su)
pankso@55 2807 su -c 'exec tazpkg shell --noheader' && break ;;
pankso@55 2808 "")
pankso@55 2809 continue ;;
pankso@55 2810 *)
pankso@55 2811 tazpkg $cmd ;;
pankso@55 2812 esac
pankso@309 2813 done ;;
al@694 2814
al@694 2815
pascal@205 2816 depends)
paul@247 2817 # Display dependencies tree
pascal@205 2818 cd $INSTALLED
pascal@205 2819 ALL_DEPS=""
pascal@205 2820 if [ -f $2/receipt ]; then
pascal@205 2821 dep_scan $2 ""
pankso@309 2822 fi ;;
al@694 2823
al@694 2824
pascal@205 2825 rdepends)
paul@247 2826 # Display reverse dependencies tree
pascal@205 2827 cd $INSTALLED
pascal@205 2828 ALL_DEPS=""
pascal@205 2829 if [ -f $2/receipt ]; then
pascal@260 2830 rdep_scan $2
pankso@309 2831 fi ;;
al@694 2832
al@694 2833
psychomaniak@715 2834 list-suggested)
psychomaniak@715 2835 for i in $(ls -d $INSTALLED/*); do
psychomaniak@715 2836 . $i/receipt
psychomaniak@715 2837 if [ "$SUGGESTED" ]; then
psychomaniak@715 2838 if [ -z "$all" ]; then
psychomaniak@715 2839 for s in $SUGGESTED; do
psychomaniak@715 2840 [ -d $INSTALLED/$s ] && \
psychomaniak@715 2841 SUGGESTED=$(echo -n $SUGGESTED | sed "s/$s//")
psychomaniak@715 2842 done
psychomaniak@715 2843 fi
psychomaniak@715 2844 cat << EOT
psychomaniak@715 2845 $(boldify $(echo $PACKAGE):) $SUGGESTED
psychomaniak@715 2846 EOT
psychomaniak@715 2847 fi
psychomaniak@715 2848 SUGGESTED=""
psychomaniak@715 2849 done ;;
psychomaniak@715 2850
psychomaniak@715 2851
pankso@504 2852 convert|-c)
pascal@262 2853 # convert misc package format to .tazpkg
pascal@263 2854 check_for_package_file
al@695 2855 tazpkg-convert $@
al@695 2856 ;;
al@694 2857
al@694 2858
pascal@263 2859 link)
pascal@263 2860 # link a package from another slitaz installation
pascal@263 2861 PACKAGE=$2
pascal@263 2862 if [ ! -d "$TARGET_DIR" -o \
pascal@263 2863 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
al@707 2864 _ 'Usage: tazpkg link package_name slitaz_root'
al@707 2865 longline "$(
al@707 2866 _n 'Example:'
al@707 2867 echo -n ' '
al@707 2868 _ '"%s" will use less than 100k in your running system RAM.' \
al@707 2869 'tazpkg link openoffice /mnt')"
pascal@263 2870 exit 1
pascal@263 2871 fi
pascal@263 2872 if [ -e "$INSTALLED/$PACKAGE" ]; then
al@707 2873 _ 'Package "%s" is already installed.' $PACKAGE
pascal@263 2874 exit 1
pascal@263 2875 fi
pascal@263 2876 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
pascal@266 2877 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
pascal@266 2878 MISSING=""
pascal@266 2879 for i in $DEPENDS; do
pascal@266 2880 [ -e $INSTALLED/$i ] && continue
pascal@266 2881 MISSING="$MISSING$i "
al@707 2882 _ 'Missing: %s' $i
pascal@266 2883 done
pascal@266 2884 if [ -n "$MISSING" ]; then
pankso@600 2885 newline
al@696 2886 confirm "$(_ 'Link all missing dependencies? (y/N)')"
al@603 2887 answer=$?
pankso@600 2888 newline
al@603 2889 if [ $answer = 0 ]; then
pascal@266 2890 for i in $MISSING; do
pascal@266 2891 tazpkg link $i $TARGET_DIR
pascal@266 2892 done
pascal@266 2893 else
pankso@600 2894 newline
al@707 2895 _ 'Leaving dependencies unresolved for package "%s"' $PACKAGE
al@694 2896 _ 'The package is installed but probably will not work.'
pankso@600 2897 newline
pascal@266 2898 fi
pascal@266 2899 fi
pascal@266 2900 . $INSTALLED/$PACKAGE/receipt
pascal@266 2901 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2902 pre_install
pascal@266 2903 fi
pascal@263 2904 while read path; do
pascal@263 2905 [ -e $path ] && continue
pascal@263 2906 while true; do
pascal@263 2907 dir=$(dirname $path)
pascal@263 2908 [ -e $dir ] && break
pascal@263 2909 path=$dir
pascal@263 2910 done
pascal@263 2911 ln -s $TARGET_DIR$path $dir
pascal@263 2912 done < $INSTALLED/$PACKAGE/files.list
pascal@266 2913 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2914 post_install
pankso@309 2915 fi ;;
al@694 2916
al@694 2917
pankso@6 2918 usage|*)
pascal@119 2919 # Print a short help or give usage for an unknown or empty command.
pankso@279 2920 usage ;;
pankso@6 2921 esac
pankso@6 2922
pankso@6 2923 exit 0