tazpkg annotate tazpkg @ rev 704

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