tazpkg annotate tazpkg @ rev 697

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