tazpkg annotate tazpkg @ rev 762

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