tazpkg annotate tazpkg @ rev 714

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