tazpkg annotate tazpkg @ rev 694

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