tazpkg annotate tazpkg @ rev 700

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