tazpkg annotate tazpkg @ rev 794

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