tazpkg annotate tazpkg @ rev 780

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