tazpkg annotate tazpkg @ rev 709

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