tazpkg annotate tazpkg @ rev 791

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