tazpkg annotate tazpkg @ rev 702

Implement %s in translations (unfinished); "tazpkg search-file": speed up (~5 times) and colored output.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 05 03:09:58 2014 +0200 (2014-12-05)
parents 56a4afc8d5fa
children 1645f795bf68
rev   line source
pankso@6 1 #!/bin/sh
pankso@646 2 #
pankso@646 3 # TazPKG - Tiny autonomous zone packages manager.
pankso@6 4 #
paul@662 5 # This is a lightweight packages manager for *.tazpkg files written in SHell
pankso@646 6 # script. It works well with Busybox ash shell and bash. TazPKG lets you
pankso@646 7 # list, install, remove, download or get information about a package. You
pankso@646 8 # can use 'tazpkg usage' to get a list of commands with short descriptions.
pankso@646 9 # TazPKG also resolves dependencies and can upgrade packages from a mirror.
pankso@6 10 #
pankso@646 11 # (C) 2007-2014 SliTaz - GNU General Public License v3.
pankso@6 12 #
al@633 13 # Authors: See the AUTHORS files
pankso@27 14 #
pankso@6 15
pankso@6 16 ####################
pankso@6 17 # Script variables #
pankso@6 18 ####################
pankso@6 19
pankso@653 20 # TazPKG version
pascal@679 21 VERSION=5.3.2
pankso@586 22
slaxemulator@588 23 . /etc/slitaz/slitaz.conf
pankso@307 24 . /etc/slitaz/tazpkg.conf
pankso@6 25
pankso@590 26 . /lib/libtaz.sh
pankso@661 27 . /usr/lib/slitaz/libpkg.sh
al@695 28 . /usr/lib/tazpkg/tazpkg-find-depends
pankso@590 29
pankso@595 30 # Internationalization.
pankso@661 31 #. /usr/bin/gettext.sh
al@694 32 export TEXTDOMAIN='tazpkg'
al@694 33
pankso@343 34
al@603 35 #
al@603 36 # Functions set for translate categories
al@603 37 #
pankso@646 38
al@694 39
al@603 40 # No operations, only for xgettext collect
al@694 41
al@603 42 gettext_noop() {
al@694 43 _ 'base-system'; _ 'x-window'; _ 'utilities'; _ 'network'; _ 'graphics';
al@694 44 _ 'multimedia'; _ 'office'; _ 'development'; _ 'system-tools'; _ 'security';
al@694 45 _ 'games'; _ 'misc'; _ 'meta'; _ "non-free"
al@603 46 }
al@694 47
al@694 48
al@603 49 # Make array of pre-translated categories
al@694 50
al@603 51 cat_i18n=""
al@603 52 for c in "base-system" "x-window" "utilities" "network" "graphics" "multimedia" "office" "development" "system-tools" "security" "games" "misc" "meta" "non-free"; do
al@603 53 cat_i18n="$cat_i18n
al@603 54 $(gettext "$c") $c"
al@603 55 done
al@694 56
al@694 57
al@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@702 1546 lzcat $i | awk -F: -vP="$(gettext 'Package %s:')" '
al@603 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@702 1556 print $2
al@702 1557 }' | tee -a $TMPLIST
pascal@187 1558 done
pascal@98 1559
pascal@98 1560 else
pascal@98 1561
al@603 1562 # Check all pkg files.list in search match which specify the package
al@603 1563 # name and the full path to the file(s).
al@694 1564 for pkg in $INSTALLED/*; do
al@603 1565 if grep -qs "$2" $pkg/files.list; then
al@603 1566 . $pkg/receipt
al@603 1567 newline
al@702 1568 emsg "<c 33>$(_ 'Package %s:' $PACKAGE)</c>"
al@702 1569 awk '
al@702 1570 /'$2'/ {
al@702 1571 gsub(/'$2'/, "\e[0;32m'$2'\e[0;39m", $0);
al@702 1572 print " "$0
al@702 1573 }
al@702 1574 ' $pkg/files.list | tee -a $TMPLIST
al@603 1575 fi
al@603 1576 done
pascal@98 1577
pascal@98 1578 fi
al@702 1579
al@702 1580 match=$(sed '/^ /!d' $TMPLIST | wc -l)
al@702 1581 rm $TMPLIST
al@702 1582
pankso@344 1583 pkg=$2
al@702 1584 num=$(emsg "<c 32>$match</c>")
al@702 1585 footer "$(eval_ngettext \
al@702 1586 '$num file found for: $pkg' \
al@702 1587 '$num files found for: $pkg' $match)"
al@603 1588 ;;
al@694 1589
al@694 1590
pankso@598 1591 search-pkgname)
pankso@344 1592 # Search for a package name
jozee@318 1593 if [ -z "$2" ]; then
pankso@600 1594 newline
al@694 1595 _ 'Please specify a pattern or file name to search for.'
al@694 1596 echo "$(_ 'Example:') 'tazpkg search-pkgname libnss'"
pankso@600 1597 newline
jozee@318 1598 exit 0
jozee@318 1599 fi
al@702 1600 title 'Search result for package "%s"' $2
pankso@598 1601
pankso@503 1602 # Search for a file on mirror and output only the package name
jozee@318 1603 match=0
al@700 1604 for i in $PKGS_DB/files.list.lzma \
al@700 1605 $PKGS_DB/undigest/*/files.list.lzma; do
jozee@318 1606 [ -f $i ] || continue
jozee@318 1607 unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
jozee@318 1608 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
jozee@318 1609 done
pankso@344 1610 file=$2
al@603 1611 if [ "$match" = "0" ]; then
al@694 1612 _ 'No file found for: $file'
pankso@600 1613 newline
jozee@318 1614 else
al@633 1615 num=$(emsg "<c 32>$files</c>")
al@603 1616 footer "$(eval_ngettext \
al@633 1617 '$num package found with file: $file' \
al@633 1618 '$num packages found with file: $file' $match)"
jozee@318 1619 fi
jozee@318 1620 ;;
al@694 1621
al@694 1622
pankso@504 1623 install|-i)
pankso@6 1624 # Install .tazpkg packages.
al@603 1625 check_root $@
pankso@6 1626 check_for_package_on_cmdline
pankso@6 1627 check_for_package_file
al@701 1628 check_for_installed_info
pankso@598 1629
gokhlayeh@429 1630 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
gokhlayeh@429 1631 [ "$list" ] && INSTALL_LIST="$list"
slaxemulator@488 1632 if [ "$rootconfig" ]; then
slaxemulator@487 1633 if [ "$root" ]; then
slaxemulator@487 1634 CACHE_DIR=$root/$CACHE_DIR
slaxemulator@487 1635 SAVE_CACHE_DIR=$CACHE_DIR
al@700 1636 PKGS_DB=$root/$PKGS_DB
slaxemulator@487 1637 else
slaxemulator@487 1638 echo "rootconfig needs --root= option used." >&2
slaxemulator@487 1639 exit 1
slaxemulator@487 1640 fi
slaxemulator@487 1641 fi
gokhlayeh@436 1642
gokhlayeh@386 1643 # Get repositories priority list.
gokhlayeh@386 1644 look_for_priority
gokhlayeh@436 1645
pankso@6 1646 # Check if forced install.
gokhlayeh@423 1647 if ! [ "$forced" ]; then
pascal@121 1648 check_for_installed_package $ROOT
pankso@6 1649 fi
gokhlayeh@356 1650 install_package $ROOT
slaxemulator@369 1651 update_desktop_database $ROOT
pankso@598 1652 update_mime_database $ROOT
pankso@598 1653 update_icon_database $ROOT
slaxemulator@567 1654 compile_glib_schemas $ROOT ;;
al@694 1655
al@694 1656
erjo@59 1657 install-list|get-install-list)
pankso@6 1658 # Install a set of packages from a list.
al@603 1659 check_root $@
pankso@6 1660 if [ -z "$2" ]; then
pankso@600 1661 newline
al@694 1662 _ \
paul@349 1663 "Please change directory (cd) to the packages repository and specify the
al@603 1664 list of packages to install. Example: tazpkg install-list packages.list"
al@694 1665 exit 0
pankso@6 1666 fi
pankso@6 1667 # Check if the packages list exist.
pankso@344 1668 list_file=$2
pankso@344 1669 if [ ! -f "$list_file" ]; then
al@694 1670 _ 'Unable to find: $list_file'
pankso@6 1671 exit 0
pankso@6 1672 else
al@694 1673 LIST=$(cat $2)
pankso@6 1674 fi
pankso@279 1675
pascal@120 1676 # Remember processed list
pascal@121 1677 export INSTALL_LIST="$2"
pascal@120 1678
erjo@59 1679 # Set $COMMAND and install all packages.
erjo@59 1680 if [ "$1" = "get-install-list" ]; then
Eric@64 1681 COMMAND=get-install
erjo@59 1682 else
erjo@59 1683 COMMAND=install
erjo@59 1684 fi
pascal@121 1685 touch $2-processed
pascal@314 1686
pascal@314 1687 # Upgrade tazpkg first. It may handle new features/formats...
pascal@340 1688 # then upgrade essential packages early
pascal@341 1689 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
pascal@341 1690 slitaz-base-files tazpkg ; do
pascal@341 1691 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
pascal@341 1692 [ -n "$pkg" ] || continue
al@694 1693 _ 'Adding implicit depends $pkg...'
pascal@341 1694 LIST="$pkg
pascal@341 1695 $LIST"
pascal@340 1696 done
pascal@314 1697
al@694 1698 for pkg in $LIST; do
pascal@121 1699 grep -qs ^$pkg$ $2-processed && continue
pankso@658 1700 [ -d "$root/var/lib/tazpkg/installed" ] && continue
pankso@660 1701 tazpkg $COMMAND $pkg --list="$2" "$3" "$4" "$5"
pankso@6 1702 done
pankso@309 1703 rm -f $2-processed ;;
al@694 1704
al@694 1705
pankso@76 1706 add-flavor)
pascal@74 1707 # Install a set of packages from a flavor.
pankso@309 1708 install_flavor $2 ;;
al@694 1709
al@694 1710
pankso@76 1711 install-flavor)
pascal@74 1712 # Install a set of packages from a flavor and purge other ones.
pankso@309 1713 install_flavor $2 --purge ;;
al@694 1714
al@694 1715
pankso@76 1716 set-release)
paul@662 1717 # Change current release and upgrade packages.
pascal@74 1718 RELEASE=$2
pankso@76 1719 if [ -z "$RELEASE" ]; then
pankso@600 1720 newline
al@694 1721 _ 'Please specify the release you want on the command line.'
al@694 1722 echo "$(_ 'Example:') tazpkg set-release cooking"
pankso@600 1723 newline
pankso@76 1724 exit 0
pankso@76 1725 fi
al@700 1726 rm $PKGS_DB/mirror
pascal@74 1727 echo "$RELEASE" > /etc/slitaz-release
pascal@74 1728 tazpkg recharge && tazpkg upgrade
pascal@222 1729
pascal@222 1730 # Install missing depends
pascal@222 1731 cd $INSTALLED
pascal@222 1732 for i in * ; do
pascal@222 1733 DEPENDS=""
pascal@222 1734 . $i/receipt
pascal@222 1735 for j in $DEPENDS ; do
pascal@222 1736 [ -d $j ] || tazpkg get-install $j
pascal@222 1737 done
pankso@309 1738 done ;;
al@694 1739
al@694 1740
pankso@504 1741 remove|-r)
pankso@6 1742 # Remove packages.
al@603 1743 check_root $@
pankso@6 1744 check_for_package_on_cmdline
al@701 1745 check_for_installed_info
pankso@598 1746
al@694 1747 [ -n "$root" ] && ROOT="$root"
slaxemulator@370 1748 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
pankso@600 1749 newline
al@694 1750 _ '$PACKAGE is not installed.'
pankso@6 1751 exit 0
pankso@6 1752 else
pascal@30 1753 ALTERED=""
pascal@30 1754 THE_PACKAGE=$PACKAGE # altered by receipt
slaxemulator@370 1755 for i in $(cd $ROOT$INSTALLED ; ls); do
slaxemulator@370 1756 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
pankso@37 1757 DEPENDS=""
slaxemulator@370 1758 . $ROOT$INSTALLED/$i/receipt
pascal@30 1759 case " $(echo $DEPENDS) " in
pascal@30 1760 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
pascal@30 1761 esac
pascal@30 1762 done
pascal@114 1763 EXTRAVERSION=""
slaxemulator@370 1764 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
pankso@6 1765 fi
pankso@600 1766 newline
pascal@30 1767 if [ -n "$ALTERED" ]; then
al@694 1768 _ 'The following packages depend on $PACKAGE:'
pascal@30 1769 for i in $ALTERED; do
pascal@30 1770 echo " $i"
pascal@30 1771 done
pascal@30 1772 fi
slaxemulator@370 1773 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
pascal@163 1774 if [ -n "$REFRESH" ]; then
al@694 1775 _ 'The following packages have been modified by $PACKAGE:'
pascal@163 1776 for i in $REFRESH; do
pascal@170 1777 echo " ${i%/modifiers}"
pascal@163 1778 done
pascal@163 1779 fi
gokhlayeh@423 1780 if [ "$auto" ]; then
al@603 1781 answer=0
gokhlayeh@423 1782 else
al@696 1783 confirm "$(_ 'Remove $PACKAGE ($VERSION$EXTRAVERSION)? (y/N)')"
al@603 1784 answer=$?
gokhlayeh@423 1785 fi
al@603 1786 if [ $answer = 0 ]; then
al@603 1787 title 'Removing: $PACKAGE'
pankso@38 1788 # Pre remove commands.
slaxemulator@371 1789 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
slaxemulator@533 1790 pre_remove $ROOT
pankso@38 1791 fi
al@603 1792 action "Removing all files installed..."
slaxemulator@370 1793 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
al@694 1794 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
al@694 1795 for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do
al@603 1796 [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
al@603 1797 done
al@603 1798 remove_with_path $ROOT$file
pascal@206 1799 done
pascal@255 1800 else
al@694 1801 for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do
slaxemulator@371 1802 remove_with_path $ROOT$file
pascal@255 1803 done
pascal@255 1804 fi
pankso@6 1805 status
slaxemulator@370 1806 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
slaxemulator@533 1807 post_remove $ROOT
pankso@51 1808 fi
al@694 1809
pankso@6 1810 # Remove package receipt.
al@603 1811 action "Removing package receipt..."
slaxemulator@370 1812 rm -rf $ROOT$INSTALLED/$PACKAGE
pankso@6 1813 status
al@694 1814
pascal@253 1815 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
al@700 1816 $PKGS_DB/installed.$SUM 2> /dev/null
al@694 1817
al@701 1818 # Update installed.info
al@701 1819 sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info
al@701 1820
pascal@183 1821 # Log this activity
al@603 1822 log_pkg Removed
al@701 1823
gokhlayeh@423 1824 if [ "$ALTERED" ]; then
gokhlayeh@423 1825 if [ "$auto" ]; then
al@603 1826 answer=0
gokhlayeh@423 1827 else
al@696 1828 confirm "$(_ 'Remove packages depending on $PACKAGE? (y/N)')"
al@603 1829 answer=$?
gokhlayeh@423 1830 fi
al@603 1831 if [ $answer = 0 ]; then
pascal@30 1832 for i in $ALTERED; do
slaxemulator@370 1833 if [ -d "$ROOT$INSTALLED/$i" ]; then
slaxemulator@371 1834 tazpkg remove $i $ROOTOPTS
pankso@37 1835 fi
pascal@30 1836 done
pascal@30 1837 fi
pascal@30 1838 fi
gokhlayeh@423 1839 if [ "$REFRESH" ]; then
gokhlayeh@423 1840 if [ "$auto" ]; then
al@603 1841 answer=0
gokhlayeh@423 1842 else
al@696 1843 confirm "$(_ 'Reinstall packages modified by $PACKAGE? (y/N)')"
al@603 1844 answer=$?
gokhlayeh@423 1845 fi
al@603 1846 if [ $answer = 0 ]; then
pascal@163 1847 for i in $REFRESH; do
slaxemulator@370 1848 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
al@694 1849 _ 'Check $INSTALLED/$i for reinstallation'
pascal@163 1850 continue
pascal@163 1851 fi
slaxemulator@370 1852 rm -r $ROOT$INSTALLED/$i
slaxemulator@371 1853 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
pascal@163 1854 done
pascal@163 1855 fi
pascal@163 1856 fi
pankso@6 1857 else
pankso@600 1858 newline
al@694 1859 _ 'Uninstallation of $PACKAGE cancelled.'
pankso@6 1860 fi
pankso@600 1861 newline ;;
al@694 1862
al@694 1863
pankso@600 1864 extract|-e)
pankso@6 1865 # Extract .tazpkg cpio archive into a directory.
pankso@6 1866 check_for_package_on_cmdline
pankso@6 1867 check_for_package_file
al@603 1868 title 'Extracting: $PACKAGE'
al@694 1869
MikeDSmith25@135 1870 # If no directory destination is found on the cmdline
MikeDSmith25@135 1871 # we create one in the current dir using the package name.
pankso@6 1872 if [ -n "$TARGET_DIR" ]; then
pankso@6 1873 DESTDIR=$TARGET_DIR/$PACKAGE
pankso@6 1874 else
pankso@6 1875 DESTDIR=$PACKAGE
pankso@6 1876 fi
pankso@6 1877 mkdir -p $DESTDIR
al@694 1878
al@603 1879 action "Copying original package..."
pankso@9 1880 cp $PACKAGE_FILE $DESTDIR
pankso@6 1881 status
al@694 1882
pankso@6 1883 cd $DESTDIR
pankso@6 1884 extract_package
al@694 1885 [ -e "receipt" ] && footer "$(_ '$PACKAGE is extracted to: $DESTDIR')"
al@603 1886 ;;
al@694 1887
al@694 1888
pascal@297 1889 recompress)
pascal@297 1890 # Recompress .tazpkg cpio archive with lzma.
pascal@297 1891 check_for_package_on_cmdline
pascal@297 1892 check_for_package_file
al@603 1893 title 'Recompressing: $PACKAGE'
pascal@297 1894 mkdir -p $TMP_DIR
al@694 1895
al@603 1896 action "Copying original package..."
pascal@297 1897 cp $PACKAGE_FILE $TMP_DIR
pascal@297 1898 status
al@694 1899
pascal@297 1900 cd $TMP_DIR
pascal@297 1901 extract_package
al@694 1902
al@603 1903 action "Recompressing the fs..."
gokhlayeh@383 1904 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@297 1905 rm -rf fs
pascal@297 1906 status
al@694 1907
al@603 1908 action "Creating new package..."
gokhlayeh@383 1909 find . -print | cpio -o -H newc --quiet > \
pascal@297 1910 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
pascal@297 1911 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
pascal@297 1912 $TOP_DIR/$(basename $PACKAGE_FILE)
pascal@297 1913 status
al@694 1914
pascal@297 1915 cd $TOP_DIR
al@603 1916 rm -rf $TMP_DIR
al@603 1917 separator; newline ;;
al@694 1918
al@694 1919
pascal@139 1920 list-config)
pascal@139 1921 # List configuration files installed.
pascal@141 1922 if [ "$2" = "--box" ]; then
pascal@141 1923 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@210 1924 FILES="$INSTALLED/*/volatile.cpio.gz"
pascal@210 1925 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
pankso@279 1926 for i in $FILES; do
gokhlayeh@383 1927 zcat $i | cpio -idm --quiet > /dev/null
pascal@190 1928 find * -type f 2>/dev/null | while read file; do
pascal@190 1929 if [ ! -e /$file ]; then
al@694 1930 echo -n "----------|----|----|$(_n 'File lost')"
pascal@190 1931 else
al@694 1932 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
al@694 1933 cmp $file /$file > /dev/null 2>&1 || \
pascal@141 1934 echo -n "$(stat -c "%.16y" /$file)"
pascal@190 1935 fi
pascal@143 1936 echo "|/$file"
pascal@141 1937 done
pascal@141 1938 rm -rf *
pascal@146 1939 done
pascal@141 1940 cd $TOP_DIR
pascal@141 1941 rm -rf $TMP_DIR
pascal@141 1942 else
al@603 1943 title 'Configuration files'
pankso@279 1944 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@146 1945 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
pascal@146 1946 [ -f "$i" ] || continue
gokhlayeh@383 1947 zcat $i | cpio -t --quiet
pascal@146 1948 done | sed 's|^|/|' | sort
slaxemulator@475 1949 separator
pankso@600 1950 newline
pankso@309 1951 fi ;;
al@694 1952
al@694 1953
pascal@139 1954 repack-config)
pascal@137 1955 # Create SliTaz package archive from configuration files.
pascal@137 1956 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@137 1957 CONFIG_VERSION=1.0
pascal@137 1958 mkdir config-$CONFIG_VERSION
pascal@137 1959 cd config-$CONFIG_VERSION
pankso@279 1960 for i in $INSTALLED/*/volatile.cpio.gz; do
gokhlayeh@383 1961 zcat $i | cpio -t --quiet
pascal@137 1962 done > files.list
pascal@137 1963 mkdir fs
pascal@137 1964 cd fs
gokhlayeh@416 1965 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
pascal@137 1966 mkdir -p etc/tazlito
pankso@279 1967 for i in $INSTALLED/*/receipt; do
pascal@137 1968 EXTRAVERSION=""
pascal@137 1969 . $i
pascal@137 1970 echo "$PACKAGE-$VERSION$EXTRAVERSION"
pascal@137 1971 done > etc/tazlito/config-packages.list
pascal@137 1972 cd ..
pascal@137 1973 echo "etc/tazlito/config-packages.list" >> files.list
al@603 1974 pkg_date=$(date +"%x %X")
pascal@137 1975 cat > receipt <<EOT
pascal@137 1976 # SliTaz package receipt.
pascal@137 1977
pascal@137 1978 PACKAGE="config"
pascal@137 1979 VERSION="$CONFIG_VERSION"
pascal@137 1980 CATEGORY="base-system"
al@694 1981 SHORT_DESC="$(_n 'User configuration backup on $pkg_date')"
pascal@137 1982 DEPENDS="$(ls $INSTALLED)"
pascal@137 1983 EOT
pascal@137 1984 cd ..
pascal@137 1985 tazpkg pack config-$CONFIG_VERSION
pascal@137 1986 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
pascal@137 1987 cd $TOP_DIR
pascal@137 1988 rm -rf $TMP_DIR
pascal@137 1989 ;;
al@694 1990
al@694 1991
pascal@18 1992 repack)
MikeDSmith25@135 1993 # Create SliTaz package archive from an installed package.
pascal@18 1994 check_for_package_on_cmdline
pascal@18 1995 check_for_receipt
pascal@114 1996 EXTRAVERSION=""
pascal@114 1997 . $INSTALLED/$PACKAGE/receipt
al@603 1998 title 'Repacking: $PACKAGE-$VERSION$EXTRAVERSION.tazpkg'
pascal@24 1999 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
al@694 2000 _ "Can't repack \$PACKAGE"
pascal@24 2001 exit 1
pascal@24 2002 fi
pascal@21 2003 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
al@694 2004 _ "Can't repack, \$PACKAGE files have been modified by:"
pascal@21 2005 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
pascal@21 2006 echo " $i"
pascal@21 2007 done
pascal@21 2008 exit 1
pascal@21 2009 fi
pascal@18 2010 MISSING=""
pascal@63 2011 while read i; do
pascal@18 2012 [ -e "$i" ] && continue
pascal@63 2013 [ -L "$i" ] || MISSING="$MISSING\n $i"
pascal@63 2014 done < $INSTALLED/$PACKAGE/files.list
pascal@18 2015 if [ -n "$MISSING" ]; then
al@694 2016 _n "Can't repack, the following files are lost:"
pascal@63 2017 echo -e "$MISSING"
pascal@18 2018 exit 1
pascal@18 2019 fi
pascal@24 2020 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@298 2021 FILES="fs.cpio.lzma\n"
pascal@24 2022 for i in $(ls $INSTALLED/$PACKAGE) ; do
pascal@128 2023 [ "$i" = "volatile.cpio.gz" ] && continue
pascal@128 2024 [ "$i" = "modifiers" ] && continue
pascal@24 2025 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
pascal@24 2026 done
pascal@72 2027 ln -s / rootfs
pascal@72 2028 mkdir tmp
gokhlayeh@383 2029 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet |\
gokhlayeh@416 2030 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
pascal@72 2031 mv tmp/rootfs fs
pascal@145 2032 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
pascal@145 2033 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
gokhlayeh@416 2034 { cd fs; cpio -idm --quiet; cd ..; }
pascal@145 2035 fi
gokhlayeh@409 2036 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
pascal@107 2037 . $INSTALLED/$PACKAGE/receipt
pascal@107 2038 repack_cleanup fs
pascal@107 2039 fi
slaxemulator@588 2040 if [ -f $INSTALLED/$PACKAGE/$CHECKSUM ]; then
slaxemulator@588 2041 sed 's, , fs,' < $INSTALLED/$PACKAGE/$CHECKSUM | \
slaxemulator@588 2042 $CHECKSUM -s -c || {
al@694 2043 _ "Can't repack, \$CHECKSUM error."
pascal@107 2044 cd $TOP_DIR
pascal@214 2045 rm -rf $TMP_DIR
pascal@107 2046 exit 1
pascal@214 2047 }
pascal@107 2048 fi
gokhlayeh@383 2049 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
gokhlayeh@383 2050 echo -e "$FILES" | cpio -o -H newc --quiet > \
pascal@114 2051 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
pascal@74 2052 cd $TOP_DIR
pascal@18 2053 \rm -R $TMP_DIR
al@694 2054 _ 'Package $PACKAGE repacked successfully.'
al@603 2055 pkg_size=$(du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg)
al@694 2056 _ 'Size: $pkg_size'
pankso@600 2057 newline ;;
al@694 2058
al@694 2059
pankso@6 2060 pack)
pankso@600 2061 # Create SliTaz package archive using cpio and lzma.
pankso@600 2062 # TODO: Cook also pack packages, we should share code in libpkg.sh
pankso@6 2063 check_for_package_on_cmdline
pankso@6 2064 cd $PACKAGE
pankso@6 2065 if [ ! -f "receipt" ]; then
al@694 2066 _ 'Receipt is missing. Please read the documentation.'
pankso@6 2067 exit 0
pankso@6 2068 else
al@603 2069 title 'Packing: $PACKAGE'
MikeDSmith25@135 2070 # Create files.list with redirecting find outpout.
al@603 2071 action "Creating the list of files..."
al@603 2072 cd fs
pankso@6 2073 find . -type f -print > ../files.list
pankso@6 2074 find . -type l -print >> ../files.list
pankso@6 2075 cd .. && sed -i s/'^.'/''/ files.list
pankso@6 2076 status
al@694 2077 action 'Creating $CHECKSUM of files...'
pascal@138 2078 while read file; do
pascal@138 2079 [ -L "fs$file" ] && continue
pascal@138 2080 [ -f "fs$file" ] || continue
pascal@158 2081 case "$file" in
al@694 2082 /lib/modules/*/modules.*|*.pyc) continue;;
pascal@158 2083 esac
slaxemulator@588 2084 $CHECKSUM "fs$file" | sed 's/ fs/ /'
slaxemulator@588 2085 done < files.list > $CHECKSUM
pascal@138 2086 status
slaxemulator@588 2087 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
pascal@147 2088 description.txt 2> /dev/null | awk \
pascal@147 2089 '{ sz=$1 } END { print sz }')
pankso@6 2090 # Build cpio archives.
al@603 2091 action "Compressing the fs..."
gokhlayeh@383 2092 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@138 2093 rm -rf fs
pascal@147 2094 status
pascal@298 2095 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
slaxemulator@588 2096 $CHECKSUM description.txt 2> /dev/null | awk \
pascal@147 2097 '{ sz=$1 } END { print sz }')
al@603 2098 action "Updating receipt sizes..."
pankso@279 2099 sed -i s/^PACKED_SIZE.*$// receipt
pankso@279 2100 sed -i s/^UNPACKED_SIZE.*$// receipt
pascal@147 2101 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@147 2102 status
al@603 2103 action "Creating full cpio archive..."
gokhlayeh@383 2104 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
pascal@147 2105 status
al@603 2106 action "Restoring original package tree..."
gokhlayeh@383 2107 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pascal@147 2108 status
pascal@298 2109 rm fs.cpio.lzma && cd ..
al@694 2110 footer "$(_ 'Package $PACKAGE compressed successfully.')"
al@603 2111 pkg_size=$(du -sh $PACKAGE.tazpkg)
al@694 2112 _ 'Size: $pkg_size'
pankso@600 2113 newline
pankso@309 2114 fi ;;
al@694 2115
al@694 2116
pankso@6 2117 recharge)
pankso@6 2118 # Recharge packages.list from a mirror.
pankso@581 2119 #
al@694 2120 # WARNING: The 'mirrors' file has all SliTaz mirrors but 'mirror'
paul@607 2121 # must have only the chosen main mirror.
pankso@581 2122 #
al@603 2123 check_root $@
pankso@598 2124
gokhlayeh@448 2125 ARG=$2
gokhlayeh@448 2126 if [ "$root" ]; then
al@700 2127 PKGS_DB=$root$PKGS_DB
gokhlayeh@448 2128 [ "${2#--}" != "$2" ] && ARG=$3
gokhlayeh@448 2129 fi
gokhlayeh@448 2130 if [ "$ARG" = main ]; then
al@700 2131 repository_to_recharge=$PKGS_DB
gokhlayeh@448 2132 elif [ "$ARG" ]; then
al@700 2133 if [ -d "$PKGS_DB/undigest/$ARG" ]; then
al@700 2134 repository_to_recharge=$PKGS_DB/undigest/$ARG
gokhlayeh@430 2135 else
al@700 2136 repo="$PKGS_DB/undigest/$ARG"
al@694 2137 _ "\$repo doesn't exist." >&2
gokhlayeh@430 2138 exit 1
gokhlayeh@430 2139 fi
gokhlayeh@430 2140 else
al@700 2141 repository_to_recharge="$PKGS_DB $PKGS_DB/undigest/*"
pankso@598 2142 fi
gokhlayeh@430 2143 for path in $repository_to_recharge; do
pascal@187 2144 [ -f $path/mirror ] || continue
gokhlayeh@430 2145 cd $path
pankso@598 2146
gokhlayeh@430 2147 # Quietly check if recharging is needed.
gokhlayeh@430 2148 [ -f ID ] && mv ID ID.bak
mojo@575 2149 download_from "$(cat mirror)" ID >/dev/null 2>/dev/null
al@694 2150 if [ -f ID ] && fgrep -q $(cat ID.bak 2>/dev/null || echo "null") ID; then
al@700 2151 if [ "$path" = "$PKGS_DB" ]; then
gokhlayeh@430 2152 repository_name=Main
gokhlayeh@430 2153 else
al@603 2154 base_path="$(basename $path)"
al@694 2155 repository_name="$(_n 'Undigest $base_path')"
gokhlayeh@430 2156 fi
al@694 2157 _ '$repository_name is up to date.'
gokhlayeh@430 2158 rm ID.bak
gokhlayeh@430 2159 continue
gokhlayeh@430 2160 fi
gokhlayeh@432 2161
gokhlayeh@432 2162 # Don't let ID be a symlink when using local repository.
gokhlayeh@432 2163 if [ -f ID ]; then
gokhlayeh@432 2164 mv -f ID ID.bak
gokhlayeh@432 2165 cat ID.bak > ID
slaxemulator@576 2166 rm ID.bak
gokhlayeh@432 2167 fi
pankso@598 2168
pankso@600 2169 newline
al@700 2170 if [ "$path" != "$PKGS_DB" ]; then
al@603 2171 base_path="$(basename $path)"
al@694 2172 _ 'Recharging undigest $base_path:'
pascal@187 2173 fi
gokhlayeh@430 2174
pascal@187 2175 if [ -f "packages.list" ]; then
al@603 2176 action "Creating backup of the last packages list..."
slaxemulator@588 2177 for i in packages.desc packages.$SUM packages.txt \
pankso@580 2178 packages.list packages.equiv files.list.lzma \
al@699 2179 extra.list mirrors packages.info
pankso@580 2180 do
gokhlayeh@438 2181 mv -f $i $i.bak 2>/dev/null
gokhlayeh@438 2182 done
pascal@187 2183 status
pascal@187 2184 fi
gokhlayeh@546 2185
al@699 2186 for i in desc $SUM txt list equiv; do
mojo@575 2187 download_from "$(cat mirror)" packages.$i
gokhlayeh@438 2188 done
pankso@598 2189 download_from "$(cat mirror)" files.list.lzma
pascal@692 2190 download_from "$(cat mirror)" extra.list
al@699 2191 download_from "$(sed 's|packages/.*||' mirror)" mirrors
al@699 2192
al@699 2193 # packages.info
al@699 2194 download_from "$(cat mirror)" packages.info.lzma
al@699 2195 lzma d packages.info.lzma packages.info
al@699 2196 rm packages.info.lzma
pankso@598 2197
pascal@187 2198 if [ -f "packages.list.bak" ]; then
pascal@187 2199 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
pascal@692 2200 [ -f "extra.list.bak" ] &&
pascal@692 2201 diff -u extra.list.bak extra.list | grep ^+[a-z] >> packages.diff
pascal@187 2202 sed -i s/+// packages.diff
al@603 2203 title 'Mirrored packages diff'
pascal@187 2204 cat packages.diff
al@701 2205 new_pkgs=$(wc -l < packages.diff)
pankso@344 2206 if [ "$new_pkgs" != 0 ]; then
al@633 2207 num=$(emsg "<c 32>$new_pkgs</c>")
al@603 2208 footer "$(eval_ngettext \
al@633 2209 '$num new package on the mirror.' \
al@633 2210 '$num new packages on the mirror.' $new_pkgs)"
pascal@187 2211 else
al@694 2212 _ 'No new packages on the mirror.'
pankso@600 2213 newline
pascal@187 2214 fi
pankso@6 2215 else
al@694 2216 footer "$(_ \
al@603 2217 'Last packages.list is ready to use. Note that next time you recharge the
pankso@344 2218 list, a list of differences will be displayed to show new and upgradeable
al@603 2219 packages.')"
pascal@187 2220 fi
pankso@309 2221 done ;;
al@694 2222
al@694 2223
al@603 2224 help-up)
al@603 2225 # Options available for the command: up
al@603 2226 newline; usage_up; newline
pankso@645 2227 exit 1 ;;
al@694 2228
al@694 2229
al@603 2230 up|upgrade)
pankso@466 2231 #
paul@476 2232 # This is the new way to upgrade packages making 'upgrade' and
pankso@466 2233 # upgradeable out-of-date. This new way is much, much more faster!
paul@476 2234 # Look into installed packages and get data from receipt, it is fast
paul@476 2235 # and easy to handle vars after using only md5sum to compare packages
pankso@598 2236 #
al@691 2237 for opt in $@; do
pankso@466 2238 case "$opt" in
al@691 2239 --recharge|-r) tazpkg recharge ;;
al@691 2240 --install|-i) install="y" ;;
al@691 2241 --check|-c) install="n" ;;
pankso@466 2242 esac
pankso@466 2243 done
pankso@598 2244 time=$(date +%s)
al@700 2245 installed_sum=$PKGS_DB/installed.$SUM
gokhlayeh@536 2246 look_for_priority
gokhlayeh@536 2247 for repo in $priority; do
gokhlayeh@536 2248 pkg_list=$repo/packages.list
al@691 2249 mtime=$(find $pkg_list -mtime +7)
gokhlayeh@536 2250 if [ "$mtime" ]; then
al@700 2251 if [ "$repo" = "$PKGS_DB" ]; then
gokhlayeh@536 2252 repo_name=main
gokhlayeh@536 2253 else
gokhlayeh@536 2254 repo_name="${repo##*/}"
slaxemulator@516 2255 fi
al@694 2256 _ '$pkg_list is older than one week... recharging'
gokhlayeh@536 2257 tazpkg recharge $repo_name
gokhlayeh@536 2258 fi
gokhlayeh@536 2259 done
al@694 2260 emsg "<n><b>$(_ 'Package')</b><i 28> $(_ 'Version')<i 48> $(_ 'Status')<->"
slaxemulator@535 2261 cd $INSTALLED
pankso@600 2262 newline > $UP_LIST
ben@483 2263 blocked_count=0
al@691 2264 for pkg in *; do
al@691 2265 [ ! -d $pkg ] && continue
pankso@485 2266 unset VERSION EXTRAVERSION
pankso@466 2267 . $pkg/receipt
pankso@485 2268 md5=$(fgrep " $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" \
slaxemulator@588 2269 $installed_sum | awk '{print $1}')
gokhlayeh@536 2270 for repo in $priority; do
gokhlayeh@536 2271 pkg_desc=$repo/packages.desc
gokhlayeh@536 2272 pkg_list=$repo/packages.list
slaxemulator@588 2273 pkg_sum=$repo/packages.$SUM
gokhlayeh@536 2274
slaxemulator@588 2275 if ! fgrep -q "$md5 $PACKAGE-" $pkg_sum; then
paul@662 2276 # Jump to next repository in priority if pkg doesn't exist
gokhlayeh@536 2277 # in this one.
gokhlayeh@536 2278 grep -q ^$PACKAGE- $pkg_list || continue
gokhlayeh@536 2279
al@603 2280 emsg -n "$PACKAGE<i 28> $VERSION"
pankso@598 2281
al@700 2282 # Skip pkgs listed in $PKGS_DB/blocked-packages.list
gokhlayeh@536 2283 if $(grep -qs "^$PACKAGE" $BLOCKED); then
pankso@598 2284 blocked_count=$(($blocked_count + 1))
al@694 2285 emsg "<i 48><c 31> $(_ 'Blocked')</c>"
gokhlayeh@536 2286 break
gokhlayeh@536 2287 fi
pankso@598 2288
gokhlayeh@536 2289 new=$(grep "^$PACKAGE |" $pkg_desc | awk '{print $3}')
pankso@598 2290
ben@483 2291 if [ "$VERSION" == "$new" ]; then
al@694 2292 emsg "<i 48><c 34> $(_ 'New build')</c>"
ben@483 2293 else
al@694 2294 emsg "<i 48><c 32> $(_ 'New version $new')</c>"
ben@483 2295 fi
ben@483 2296 echo "$PACKAGE" >> $UP_LIST
gokhlayeh@536 2297 break
pankso@466 2298 fi
gokhlayeh@536 2299 done
pankso@466 2300 done
pankso@466 2301 sed -i /^$/d $UP_LIST
pascal@648 2302 upnb=$(wc -l < $UP_LIST)
pankso@496 2303 pkgs=$(ls | wc -l)
pankso@598 2304 time=$(($(date +%s) - $time))
pankso@480 2305 if [ "$upnb" = 0 ]; then
pankso@480 2306 install="n"
al@694 2307 _ 'System is up-to-date...'
pankso@598 2308 fi
pankso@645 2309 num=$(emsg "<c 32>$pkgs</c>")
al@603 2310 footer "$(eval_ngettext \
al@633 2311 '$num installed package scanned in ${time}s' \
al@633 2312 '$num installed packages scanned in ${time}s' $pkgs)"
pankso@598 2313 if [ "$upnb" != 0 ]; then
ben@483 2314 if [ "$blocked_count" -gt 0 ]; then
al@633 2315 num=$blocked_count
al@633 2316 blocked=$(eval_ngettext '$num blocked' '$num blocked' $num)
pankso@645 2317 else
al@694 2318 # FIXME
al@694 2319 blocked="$(_ '0 blocked')"
ben@483 2320 fi
al@633 2321 num=$upnb
al@603 2322 boldify "$(eval_ngettext \
al@633 2323 'You have $num available upgrade ($blocked)' \
al@633 2324 'You have $num available upgrades ($blocked)' $num)"
al@603 2325 newline
pankso@480 2326 fi
pankso@466 2327 # Pkgs to upgrade ? Skip, let install them all or ask user
pankso@466 2328 [ "$install" == "n" ] && exit 0
pankso@480 2329 if [ "$upnb" -gt 0 ]; then
pankso@466 2330 if [ "$install" == "y" ]; then
pankso@466 2331 continue
pankso@466 2332 else
al@694 2333 _n 'Do you wish to install them now: y/n ? '
pankso@466 2334 read install
pankso@466 2335 fi
pankso@466 2336 case "$install" in
pankso@466 2337 y|Y|yes|YES|Yes)
al@691 2338 for pkg in $(cat $UP_LIST); do
pankso@466 2339 echo 'y' | tazpkg get-install $pkg --forced
pankso@502 2340 done
paul@554 2341 # List is generated each time and must be cleaned so
paul@662 2342 # tazpkg-notify doesn't find upgrades anymore.
pankso@502 2343 rm $UP_LIST && touch $UP_LIST ;;
pankso@466 2344 *)
al@694 2345 _ 'Leaving without any upgrades installed.'
al@603 2346 newline
pankso@466 2347 exit 0 ;;
pankso@466 2348 esac
pankso@466 2349 fi
pankso@600 2350 newline ;;
al@694 2351
al@694 2352
pascal@152 2353 bugs)
pascal@152 2354 # Show known bugs in package(s)
pascal@152 2355 cd $INSTALLED
pascal@159 2356 shift
pascal@159 2357 LIST=$@
al@694 2358 [ -n "$LIST" ] || LIST=$(ls)
al@694 2359 MSG=$(_n 'No known bugs.')
pascal@152 2360 for PACKAGE in $LIST; do
pascal@152 2361 BUGS=""
pascal@154 2362 EXTRAVERSION=""
pascal@152 2363 . $PACKAGE/receipt
pascal@152 2364 if [ -n "$BUGS" ]; then
al@694 2365 MSG=$(_n 'Bug list completed')
pankso@600 2366 newline
al@694 2367 _ 'Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:'
pascal@152 2368 cat <<EOT
pascal@152 2369 $BUGS
pascal@152 2370 EOT
pascal@152 2371 fi
pascal@152 2372 done
pankso@309 2373 echo "$MSG" ;;
al@694 2374
al@694 2375
pascal@25 2376 check)
MikeDSmith25@135 2377 # Check installed packages set.
al@603 2378 check_root $@
pankso@598 2379
gokhlayeh@386 2380 # Get repositories priority list.
gokhlayeh@386 2381 look_for_priority
pankso@598 2382
pascal@25 2383 cd $INSTALLED
al@694 2384 for PACKAGE in $(ls); do
pascal@122 2385 if [ ! -f $PACKAGE/receipt ]; then
al@694 2386 _ 'The package $PACKAGE installation has not completed'
pascal@122 2387 continue
pascal@122 2388 fi
pascal@29 2389 DEPENDS=""
pascal@114 2390 EXTRAVERSION=""
pascal@29 2391 . $PACKAGE/receipt
pascal@29 2392 if [ -s $PACKAGE/modifiers ]; then
al@694 2393 _ 'The package $PACKAGE-$VERSION$EXTRAVERSION has been modified by:'
pascal@29 2394 for i in $(cat $PACKAGE/modifiers); do
pascal@29 2395 echo " $i"
pascal@29 2396 done
pascal@29 2397 fi
al@694 2398 MSG="$(_n 'Files lost from $PACKAGE-$VERSION$EXTRAVERSION:')\n"
pascal@25 2399 while read file; do
pascal@25 2400 [ -e "$file" ] && continue
pascal@25 2401 if [ -L "$file" ]; then
al@694 2402 MSG="$MSG $(_n 'target of symlink')"
pascal@25 2403 fi
pascal@25 2404 echo -e "$MSG $file"
pascal@25 2405 MSG=""
pascal@25 2406 done < $PACKAGE/files.list
al@694 2407 MSG="$(_n 'Missing dependencies for $PACKAGE-$VERSION$EXTRAVERSION:')\n"
pascal@25 2408 for i in $DEPENDS; do
pascal@25 2409 [ -d $i ] && continue
pascal@290 2410 [ -d $(equivalent_pkg $i) ] && continue
pascal@25 2411 echo -e "$MSG $i"
pascal@25 2412 MSG=""
pascal@25 2413 done
al@694 2414 MSG="$(_n 'Dependencies loop between $PACKAGE and:')\n"
pascal@122 2415 ALL_DEPS=""
pascal@122 2416 check_for_deps_loop $PACKAGE $DEPENDS
pascal@25 2417 done
al@694 2418
al@694 2419 _ 'Looking for known bugs...'
pascal@152 2420 tazpkg bugs
al@694 2421
pascal@60 2422 if [ "$PACKAGE_FILE" = "--full" ]; then
slaxemulator@588 2423 for file in */$CHECKSUM; do
pascal@177 2424 CONFIG_FILES=""
pascal@177 2425 . $(dirname "$file")/receipt
pascal@106 2426 [ -s "$file" ] || continue
pascal@177 2427 while read md5 f; do
pascal@177 2428 [ -f $f ] || continue
pascal@177 2429 for i in $CONFIG_FILES; do
pascal@177 2430 case "$f" in
al@694 2431 $i|$i/*) continue 2;;
pascal@177 2432 esac
pascal@177 2433 done
pascal@177 2434 echo "$md5 $f"
slaxemulator@588 2435 done < "$file" | $CHECKSUM -c - 2> /dev/null | \
slaxemulator@588 2436 grep -v OK$ | sed 's/FAILED$/$CHECKSUM MISMATCH/'
pascal@106 2437 done
pascal@60 2438 FILES=" "
pascal@60 2439 for file in $(cat */files.list); do
pascal@60 2440 [ -d "$file" ] && continue
pascal@60 2441 case "$FILES" in *\ $file\ *) continue;; esac
pascal@377 2442 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
pascal@60 2443 wc -l) -gt 1 ] || continue
pascal@60 2444 FILES="$FILES$file "
al@694 2445 _ 'The following packages provide $file:'
al@694 2446 grep -l "^$(echo $file | grepesc)$" */files.list | \
al@694 2447 while read f; do
pascal@60 2448 pkg=${f%/files.list}
pascal@60 2449 if [ -f $pkg/modifiers ]; then
al@633 2450 pkg_list="$(cat $pkg/modifiers)"
al@694 2451 overriders=$(_n '(overridden by $pkg_list)')
al@603 2452 else
al@633 2453 overriders=''
pascal@60 2454 fi
al@633 2455 echo -n " $pkg $overriders"
pankso@600 2456 newline
pascal@60 2457 done
pascal@60 2458 done
al@694 2459 MSG="$(_n 'No package has installed the following files:')\n"
al@694 2460 find /etc /bin /sbin /lib /usr /var/www -not -type d 2>/dev/null | \
al@694 2461 while read file; do
pascal@73 2462 case "$file" in *\[*) continue;; esac
pascal@377 2463 grep -q "^$(echo $file | grepesc)$" */files.list && continue
pascal@73 2464 echo -e "$MSG $file"
pascal@73 2465 MSG=""
pascal@73 2466 done
pascal@60 2467 fi
al@694 2468 _ 'Check completed.'; echo ;;
al@694 2469
al@694 2470
pankso@10 2471 block)
pankso@10 2472 # Add a pkg name to the list of blocked packages.
al@603 2473 check_root $@
pankso@10 2474 check_for_package_on_cmdline
pankso@600 2475 newline
pascal@223 2476 if grep -qs "^$PACKAGE" $BLOCKED; then
al@694 2477 _ '$PACKAGE is already in the blocked packages list.'
pankso@10 2478 else
al@694 2479 action 'Add $PACKAGE to: $BLOCKED...'
pankso@10 2480 echo $PACKAGE >> $BLOCKED
pankso@10 2481 status
pascal@183 2482 # Log this activity
pascal@183 2483 . $INSTALLED/$PACKAGE/receipt
al@603 2484 log_pkg Blocked
pankso@10 2485 fi
pankso@600 2486 newline ;;
al@694 2487
al@694 2488
pankso@10 2489 unblock)
MikeDSmith25@135 2490 # Remove a pkg name from the list of blocked packages.
al@603 2491 check_root $@
pankso@10 2492 check_for_package_on_cmdline
pankso@600 2493 newline
pascal@223 2494 if grep -qs "^$PACKAGE" $BLOCKED; then
al@694 2495 action 'Removing $PACKAGE from: $BLOCKED...'
pankso@10 2496 sed -i s/$PACKAGE/''/ $BLOCKED
pankso@10 2497 sed -i '/^$/d' $BLOCKED
pankso@10 2498 status
pascal@183 2499 # Log this activity
pascal@183 2500 . $INSTALLED/$PACKAGE/receipt
al@603 2501 log_pkg Unblocked
pankso@10 2502 else
al@694 2503 _ '$PACKAGE is not in the blocked packages list.'
pankso@10 2504 fi
pankso@600 2505 newline ;;
al@694 2506
al@694 2507
pankso@6 2508 get)
al@603 2509 # Download a package with wget.
al@603 2510 check_root $@
pankso@6 2511 check_for_package_on_cmdline
pankso@6 2512 check_for_packages_list
pankso@598 2513
slaxemulator@478 2514 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
slaxemulator@478 2515 if [ "$rootconfig" ]; then
slaxemulator@478 2516 if [ "$root" ]; then
slaxemulator@478 2517 CACHE_DIR=$root/$CACHE_DIR
slaxemulator@478 2518 SAVE_CACHE_DIR=$CACHE_DIR
al@700 2519 PKGS_DB=$root/$PKGS_DB
slaxemulator@478 2520 else
al@694 2521 _ 'rootconfig needs --root= option used.' >&2
slaxemulator@478 2522 exit 1
slaxemulator@478 2523 fi
slaxemulator@478 2524 fi
pankso@598 2525
gokhlayeh@386 2526 # Get repositories priority list.
gokhlayeh@386 2527 look_for_priority
pankso@598 2528
slaxemulator@478 2529 CURRENT_DIR=$PWD
pankso@6 2530 check_for_package_in_list
slaxemulator@478 2531 cd $CACHE_DIR
slaxemulator@478 2532 if [ -f "$PACKAGE.tazpkg" ]; then
al@694 2533 _ '$PACKAGE already in the cache'
slaxemulator@478 2534 # Check package download was finished
slaxemulator@478 2535 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
al@694 2536 _ 'Continuing $PACKAGE download'
slaxemulator@478 2537 download $PACKAGE.tazpkg
slaxemulator@478 2538 }
slaxemulator@588 2539 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
slaxemulator@378 2540 rm -f $PACKAGE.tazpkg
slaxemulator@378 2541 download $PACKAGE.tazpkg
slaxemulator@378 2542 fi
slaxemulator@378 2543 else
slaxemulator@378 2544 download $PACKAGE.tazpkg
slaxemulator@378 2545 fi
slaxemulator@478 2546 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
pankso@658 2547 cp -a $PACKAGE_FILE $CURRENT_DIR ;;
al@694 2548
al@694 2549
pankso@504 2550 get-install|-gi)
pankso@6 2551 # Download and install a package.
al@603 2552 check_root $@
pankso@6 2553 check_for_package_on_cmdline
pankso@6 2554 check_for_packages_list
pankso@598 2555
pascal@121 2556 DO_CHECK=""
gokhlayeh@406 2557 [ "$forced" ] && DO_CHECK=no
gokhlayeh@429 2558 [ "$root" ] && ROOT="$root" && check_base_dir "$root"
gokhlayeh@406 2559 [ "$list" ] && INSTALL_LIST="$list"
gokhlayeh@431 2560 if [ "$rootconfig" ]; then
gokhlayeh@429 2561 if [ "$root" ]; then
gokhlayeh@429 2562 CACHE_DIR=$root/$CACHE_DIR
gokhlayeh@436 2563 SAVE_CACHE_DIR=$CACHE_DIR
al@700 2564 PKGS_DB=$root/$PKGS_DB
gokhlayeh@429 2565 else
al@694 2566 _ 'rootconfig needs --root= option used.' >&2
gokhlayeh@429 2567 exit 1
gokhlayeh@429 2568 fi
gokhlayeh@429 2569 fi
gokhlayeh@436 2570
gokhlayeh@436 2571 # Get repositories priority list.
gokhlayeh@436 2572 look_for_priority
gokhlayeh@436 2573
pascal@202 2574 AUTOEXEC="no"
gokhlayeh@416 2575 if ! check_for_package_in_list check; then
pascal@648 2576 CACHE_DIR="${CACHE_DIR%/*}/get"
pascal@648 2577 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
pascal@648 2578 if download_get_script $PACKAGE /tmp/$PACKAGE.$$ ; then
pascal@648 2579 install_package_from_get_script /tmp/$PACKAGE.$$ $ROOT
pascal@202 2580 exit 0
pascal@648 2581 else
pascal@648 2582 PACKAGE=get-$PACKAGE
pascal@648 2583 AUTOEXEC=$PACKAGE
pascal@648 2584 check_for_package_in_list
pascal@648 2585 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
pascal@648 2586 $AUTOEXEC $ROOT
pascal@648 2587 exit 0
pascal@648 2588 fi
pascal@202 2589 fi
gokhlayeh@416 2590 fi
pankso@6 2591 # Check if forced install.
gokhlayeh@423 2592 if ! [ "$forced" ]; then
pascal@121 2593 check_for_installed_package $ROOT
pankso@6 2594 fi
pankso@6 2595 cd $CACHE_DIR
pankso@6 2596 if [ -f "$PACKAGE.tazpkg" ]; then
al@694 2597 _ '$PACKAGE already in the cache: $CACHE_DIR'
MikeDSmith25@135 2598 # Check package download was finished
gokhlayeh@409 2599 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
al@694 2600 _ 'Continuing $PACKAGE download'
pascal@108 2601 download $PACKAGE.tazpkg
pascal@108 2602 }
slaxemulator@588 2603 if [ "$($CHECKSUM $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.$SUM)" ]; then
slaxemulator@375 2604 rm -f $PACKAGE.tazpkg
pascal@374 2605 download $PACKAGE.tazpkg
pascal@374 2606 fi
pankso@6 2607 else
pankso@600 2608 newline
pascal@17 2609 download $PACKAGE.tazpkg
pankso@6 2610 fi
pankso@14 2611 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
al@700 2612 [ "$rootconfig" ] && PKGS_DB=${PKGS_DB#$root}
pascal@121 2613 install_package $ROOT
pankso@598 2614 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
pankso@598 2615 update_desktop_database $ROOT
slaxemulator@369 2616 update_mime_database $ROOT ;;
al@694 2617
al@694 2618
pankso@504 2619 clean-cache|-cc)
pankso@6 2620 # Remove all downloaded packages.
al@603 2621 check_root $@
pankso@499 2622 files=$(find $CACHE_DIR -name *.tazpkg | wc -l)
pankso@653 2623 title 'Path: $CACHE_DIR'
al@603 2624 action "Cleaning cache directory..."
pankso@6 2625 rm -rf $CACHE_DIR/*
al@603 2626 status
pankso@653 2627 num=$(colorize 32 "$files")
al@694 2628
al@694 2629 footer "$(eval_ngettext \
al@694 2630 '$num file removed from cache.' \
al@694 2631 '$num files removed from cache.' \
al@694 2632 $files)"
al@694 2633 ;;
al@694 2634
al@694 2635
pascal@187 2636 list-undigest)
pascal@187 2637 # list undigest URLs.
pascal@187 2638 if [ "$2" = "--box" ]; then
al@700 2639 for i in $PKGS_DB/undigest/*/mirror; do
pascal@187 2640 [ -f $i ] || continue
pascal@187 2641 echo "$(basename $(dirname $i))|$(cat $i)"
pascal@187 2642 done
pascal@187 2643 else
al@603 2644 title 'Current undigest(s)'
al@700 2645 for i in $PKGS_DB/undigest/*/mirror; do
pascal@187 2646 if [ ! -f $i ]; then
al@694 2647 _ 'No undigest mirror found.'
pascal@187 2648 exit 1
pascal@187 2649 fi
pascal@187 2650 echo "$(basename $(dirname $i)) $(cat $i)"
pascal@187 2651 done
pankso@600 2652 newline
pankso@309 2653 fi ;;
al@694 2654
al@694 2655
pascal@187 2656 remove-undigest)
pascal@187 2657 # remove undigest URL.
al@603 2658 check_root $@
gokhlayeh@388 2659 undigest="$2"
al@700 2660 if [ -d $PKGS_DB/undigest/$2 ]; then
al@696 2661 confirm "$(_ 'Remove $undigest undigest? (y/N)')"
al@603 2662 if [ $? = 0 ]; then
al@694 2663 action 'Removing $undigest undigest...'
al@700 2664 rm -rf $PKGS_DB/undigest/$2
pascal@187 2665 status
al@700 2666 rmdir $PKGS_DB/undigest 2> /dev/null
pascal@187 2667 fi
pascal@187 2668 else
al@694 2669 _ 'Undigest $undigest not found'
pankso@309 2670 fi ;;
al@694 2671
al@694 2672
pascal@187 2673 add-undigest|setup-undigest)
pascal@187 2674 # Add undigest URL.
al@603 2675 check_root $@
pascal@187 2676 undigest=$2
al@700 2677 [ -d $PKGS_DB/undigest ] || mkdir $PKGS_DB/undigest
pascal@187 2678 if [ -z "$undigest" ]; then
pascal@187 2679 i=1
al@700 2680 while [ -d $PKGS_DB/undigest/$i ]; do
pascal@187 2681 i=$(($i+1))
pascal@187 2682 done
pascal@187 2683 undigest=$i
pascal@187 2684 fi
al@700 2685 if [ ! -d $PKGS_DB/undigest/$undigest ]; then
al@694 2686 _ 'Creating new undigest $undigest.'
al@700 2687 mkdir $PKGS_DB/undigest/$undigest
pascal@187 2688 fi
al@700 2689 setup_mirror $PKGS_DB/undigest/$undigest $3 ;;
al@694 2690
al@694 2691
pankso@600 2692 setup-mirror|-sm)
pankso@6 2693 # Change mirror URL.
al@603 2694 check_root $@
al@700 2695 setup_mirror $PKGS_DB $2 ;;
al@694 2696
al@694 2697
erjo@56 2698 reconfigure)
erjo@56 2699 # Replay post_install from receipt
erjo@56 2700 check_for_package_on_cmdline
al@603 2701 check_root $@
pascal@250 2702 ROOT=""
pascal@250 2703 while [ -n "$3" ]; do
pascal@250 2704 case "$3" in
al@694 2705 --root=*)
al@694 2706 ROOT="${3#--root=}/" ;;
al@694 2707 *)
al@694 2708 shift 2
al@694 2709 u_opt="$*"
al@694 2710 newline >&2
al@694 2711 _ 'Unknown option $u_opt.' >&2
al@694 2712 exit 1 ;;
pascal@250 2713 esac
pascal@250 2714 shift
pascal@250 2715 done
pascal@250 2716 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
pascal@250 2717 check_for_receipt $ROOT
erjo@56 2718 # Check for post_install
pascal@250 2719 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@250 2720 . $ROOT$INSTALLED/$PACKAGE/receipt
pascal@250 2721 post_install $ROOT
pascal@183 2722 # Log this activity
al@603 2723 [ -n "$ROOT" ] || log_pkg Reconfigured
pankso@279 2724 else
pankso@600 2725 newline
al@694 2726 _ 'Nothing to do for $PACKAGE.'
erjo@56 2727 fi
erjo@56 2728 else
pankso@600 2729 newline
al@694 2730 _ 'Package $PACKAGE is not installed.'
al@694 2731 _ "Install package with 'tazpkg install' or 'tazpkg get-install'"
pankso@600 2732 newline
pankso@309 2733 fi ;;
al@694 2734
al@694 2735
pankso@55 2736 shell)
pankso@653 2737 # TazPKG SHell
pankso@55 2738 if test $(id -u) = 0 ; then
pankso@55 2739 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
pankso@55 2740 else
pankso@55 2741 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
pankso@55 2742 fi
pankso@55 2743 if [ ! "$2" = "--noheader" ]; then
pankso@55 2744 clear
pankso@653 2745 title 'TazPKG SHell.'
al@694 2746 _ "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
pankso@600 2747 newline
pankso@55 2748 fi
al@694 2749 while true; do
pankso@55 2750 echo -en "$PROMPT"; read cmd
pankso@55 2751 case $cmd in
pankso@55 2752 q|quit)
pankso@55 2753 break ;;
pankso@55 2754 shell)
al@694 2755 _ 'You are already running a TazPKG SHell.' ;;
pankso@55 2756 su)
pankso@55 2757 su -c 'exec tazpkg shell --noheader' && break ;;
pankso@55 2758 "")
pankso@55 2759 continue ;;
pankso@55 2760 *)
pankso@55 2761 tazpkg $cmd ;;
pankso@55 2762 esac
pankso@309 2763 done ;;
al@694 2764
al@694 2765
pascal@205 2766 depends)
paul@247 2767 # Display dependencies tree
pascal@205 2768 cd $INSTALLED
pascal@205 2769 ALL_DEPS=""
pascal@205 2770 if [ -f $2/receipt ]; then
pascal@205 2771 dep_scan $2 ""
pankso@309 2772 fi ;;
al@694 2773
al@694 2774
pascal@205 2775 rdepends)
paul@247 2776 # Display reverse dependencies tree
pascal@205 2777 cd $INSTALLED
pascal@205 2778 ALL_DEPS=""
pascal@205 2779 if [ -f $2/receipt ]; then
pascal@260 2780 rdep_scan $2
pankso@309 2781 fi ;;
al@694 2782
al@694 2783
pankso@504 2784 convert|-c)
pascal@262 2785 # convert misc package format to .tazpkg
pascal@263 2786 check_for_package_file
al@695 2787 tazpkg-convert $@
al@695 2788 ;;
al@694 2789
al@694 2790
pascal@263 2791 link)
pascal@263 2792 # link a package from another slitaz installation
pascal@263 2793 PACKAGE=$2
pascal@263 2794 if [ ! -d "$TARGET_DIR" -o \
pascal@263 2795 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
al@694 2796 _n "
pascal@263 2797 usage: tazpkg link package_name slitaz_root
paul@272 2798 example: 'tazpkg link openoffice /mnt' will use less than 100k in
paul@437 2799 your running system ram.
al@603 2800 "
pascal@263 2801 exit 1
pascal@263 2802 fi
pascal@263 2803 if [ -e "$INSTALLED/$PACKAGE" ]; then
al@694 2804 _ '$PACKAGE is already installed.'
pascal@263 2805 exit 1
pascal@263 2806 fi
pascal@263 2807 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
pascal@266 2808 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
pascal@266 2809 MISSING=""
pascal@266 2810 for i in $DEPENDS; do
pascal@266 2811 [ -e $INSTALLED/$i ] && continue
pascal@266 2812 MISSING="$MISSING$i "
al@694 2813 _ 'Missing: $i'
pascal@266 2814 done
pascal@266 2815 if [ -n "$MISSING" ]; then
pankso@600 2816 newline
al@696 2817 confirm "$(_ 'Link all missing dependencies? (y/N)')"
al@603 2818 answer=$?
pankso@600 2819 newline
al@603 2820 if [ $answer = 0 ]; then
pascal@266 2821 for i in $MISSING; do
pascal@266 2822 tazpkg link $i $TARGET_DIR
pascal@266 2823 done
pascal@266 2824 else
pankso@600 2825 newline
al@694 2826 _ 'Leaving dependencies unresolved for: $PACKAGE'
al@694 2827 _ 'The package is installed but probably will not work.'
pankso@600 2828 newline
pascal@266 2829 fi
pascal@266 2830 fi
pascal@266 2831 . $INSTALLED/$PACKAGE/receipt
pascal@266 2832 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2833 pre_install
pascal@266 2834 fi
pascal@263 2835 while read path; do
pascal@263 2836 [ -e $path ] && continue
pascal@263 2837 while true; do
pascal@263 2838 dir=$(dirname $path)
pascal@263 2839 [ -e $dir ] && break
pascal@263 2840 path=$dir
pascal@263 2841 done
pascal@263 2842 ln -s $TARGET_DIR$path $dir
pascal@263 2843 done < $INSTALLED/$PACKAGE/files.list
pascal@266 2844 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2845 post_install
pankso@309 2846 fi ;;
al@694 2847
al@694 2848
pankso@6 2849 usage|*)
pascal@119 2850 # Print a short help or give usage for an unknown or empty command.
pankso@279 2851 usage ;;
pankso@6 2852 esac
pankso@6 2853
pankso@6 2854 exit 0