tazpkg annotate tazpkg @ rev 187

Add undigest support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Oct 27 23:12:36 2008 +0000 (2008-10-27)
parents 7e9bd92fa8b5
children cf614e32ecb9
rev   line source
pankso@6 1 #!/bin/sh
pankso@6 2 # Tazpkg - Tiny autonomus zone packages manager.
pankso@6 3 #
pankso@6 4 # This is a lightwight packages manager for *.tazpkg files, all written in
MikeDSmith25@135 5 # SHell script. It works well with Busybox ash shell and bash. Tazpkg lets you
MikeDSmith25@135 6 # list, install, remove, download or get information about a package. You can
MikeDSmith25@135 7 # use 'tazpkg usage' to get a list of commands with short descriptions. Tazpkg
pascal@119 8 # also resolves dependencies and can upgrade packages from a mirror.
pankso@6 9 #
pankso@33 10 # (C) 2007-2008 SliTaz - GNU General Public License v3.
pankso@6 11 #
pankso@27 12 # Authors : Christophe Lincoln <pankso@slitaz.org>
pankso@31 13 # Pascal Bellard <pascal.bellard@slitaz.org>
pankso@57 14 # Eric Joseph-Alexandre <erjo@slitaz.org>
pankso@27 15 #
pascal@187 16 VERSION=2.5
pankso@6 17
pankso@6 18 ####################
pankso@6 19 # Script variables #
pankso@6 20 ####################
pankso@6 21
pankso@6 22 # Packages categories.
pankso@39 23 CATEGORIES="
pankso@39 24 base-system
pascal@160 25 x-window
pankso@39 26 utilities
pankso@39 27 network
pankso@39 28 graphics
pankso@39 29 multimedia
pankso@39 30 office
pankso@39 31 development
pankso@39 32 system-tools
pankso@39 33 security
pankso@39 34 games
pankso@39 35 misc
pankso@57 36 meta
pankso@57 37 non-free"
pankso@6 38
pankso@6 39 # Initialize some variables to use words
pascal@119 40 # rather than numbers for functions and actions.
pankso@6 41 COMMAND=$1
pankso@34 42 if [ -f "$2" ]; then
pankso@10 43 # Set pkg basename for install, extract
pankso@10 44 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
pankso@10 45 else
pankso@10 46 # Pkg name for remove, search and all other cmds
pankso@10 47 PACKAGE=${2%.tazpkg}
pankso@10 48 fi
pankso@9 49 PACKAGE_FILE=$2
pankso@6 50 TARGET_DIR=$3
pankso@6 51 TOP_DIR=`pwd`
pankso@6 52 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
pankso@6 53
pankso@6 54 # Path to tazpkg used dir and configuration files
pankso@6 55 LOCALSTATE=/var/lib/tazpkg
pankso@6 56 INSTALLED=$LOCALSTATE/installed
pankso@6 57 CACHE_DIR=/var/cache/tazpkg
pankso@6 58 MIRROR=$LOCALSTATE/mirror
pankso@6 59 PACKAGES_LIST=$LOCALSTATE/packages.list
pankso@10 60 BLOCKED=$LOCALSTATE/blocked-packages.list
pankso@117 61 DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
pascal@120 62 INSTALL_LIST=""
pascal@183 63 LOG=/var/log/tazpkg.log
pankso@6 64
pascal@119 65 # Bold red warning for upgrade.
pankso@10 66 WARNING="\\033[1;31mWARNING\\033[0;39m"
pankso@6 67
pankso@6 68 # Check if the directories and files used by Tazpkg
MikeDSmith25@135 69 # exist. If not and user is root we create them.
pankso@6 70 if test $(id -u) = 0 ; then
pankso@6 71 if [ ! -d "$CACHE_DIR" ]; then
pankso@6 72 mkdir -p $CACHE_DIR
pankso@6 73 fi
pankso@6 74 if [ ! -d "$INSTALLED" ]; then
pankso@55 75 mkdir -p $INSTALLED
pankso@6 76 fi
pankso@6 77 if [ ! -f "$LOCALSTATE/mirror" ]; then
pankso@55 78 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
pankso@6 79 fi
pankso@6 80 fi
pankso@6 81
pankso@6 82 ####################
pankso@6 83 # Script functions #
pankso@6 84 ####################
pankso@6 85
pankso@6 86 # Print the usage.
pankso@6 87 usage ()
pankso@6 88 {
MikeDSmith25@135 89 echo -e "SliTaz package manager - Version: $VERSION\n
pankso@55 90 \033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
pankso@55 91 tazpkg shell\n
pankso@6 92 \033[1mCommands: \033[0m
erjo@59 93 usage Print this short usage.
pascal@152 94 bugs Show known bugs in packages
erjo@59 95 list List installed packages on the system by category or all.
MikeDSmith25@135 96 xhtml-list Create a xHTML list of installed packges.
erjo@59 97 list-mirror List all available packages on the mirror (--diff for new).
MikeDSmith25@135 98 info Print information about a package.
MikeDSmith25@135 99 desc Print description of a package (if it exists).
MikeDSmith25@135 100 list-files List the files installed with a package.
pascal@139 101 list-config List the configuration files.
erjo@59 102 search Search for a package by pattern or name (options: -i|-l|-m).
erjo@59 103 search-file Search for file(s) in all installed packages files.
erjo@59 104 install Install a local (*.tazpkg) package (--forced to force).
erjo@59 105 install-list Install all packages from a list of packages.
erjo@59 106 remove Remove the specified package and all installed files.
erjo@59 107 extract Extract a (*.tazpkg) package into a directory.
erjo@59 108 pack Pack an unpacked or prepared package tree.
erjo@59 109 recharge Recharge your packages.list from the mirror.
MikeDSmith25@157 110 repack Create a package archive from an installed package.
MikeDSmith25@157 111 repack-config Create a package archive with configuration files.
erjo@59 112 upgrade Upgrade all installed and listed packages on the mirror.
erjo@59 113 block|unblock Block an installed package version or unblock it for upgrade.
erjo@59 114 get Download a package into the current directory.
erjo@59 115 get-install Download and install a package from the mirror.
erjo@59 116 get-install-list Download and install a list of packages from the mirror.
MikeDSmith25@135 117 check Verify consistency of installed packages.
pascal@74 118 add-flavor Install the flavor list of packages.
pascal@74 119 install-flavor Install the flavor list of packages and remove other ones.
pascal@74 120 set-release Change release and update packages
erjo@59 121 clean-cache Clean all packages downloaded in cache directory.
erjo@59 122 setup-mirror Change the mirror url configuration.
pascal@187 123 list-undigest List undigest mirrors.
pascal@187 124 remove-undigest Remove an undigest mirror.
pascal@187 125 add-undigest Add an undigest mirror.
pascal@187 126 setup-undigest Update an undigest mirror.
pascal@187 127 reconfigure Replay post install script from package."
pankso@6 128 }
pankso@6 129
pankso@6 130 # Status function with color (supported by Ash).
pankso@6 131 status()
pankso@6 132 {
pankso@6 133 local CHECK=$?
pankso@6 134 echo -en "\\033[70G[ "
pankso@6 135 if [ $CHECK = 0 ]; then
pankso@6 136 echo -en "\\033[1;33mOK"
pankso@6 137 else
pankso@6 138 echo -en "\\033[1;31mFailed"
pankso@6 139 fi
pankso@6 140 echo -e "\\033[0;39m ]"
pascal@20 141 return $CHECK
pankso@6 142 }
pankso@6 143
pankso@6 144 # Check if user is root to install, or remove packages.
pankso@6 145 check_root()
pankso@6 146 {
pankso@6 147 if test $(id -u) != 0 ; then
pankso@6 148 echo -e "\nYou must be root to run `basename $0` with this option."
pankso@55 149 echo -e "Please use 'su' and root password to become super-user.\n"
pankso@6 150 exit 0
pankso@6 151 fi
pankso@6 152 }
pankso@6 153
pankso@6 154 # Check for a package name on cmdline.
pankso@6 155 check_for_package_on_cmdline()
pankso@6 156 {
pankso@6 157 if [ -z "$PACKAGE" ]; then
pankso@6 158 echo -e "\nPlease specify a package name on the command line.\n"
pankso@6 159 exit 0
pankso@6 160 fi
pankso@6 161 }
pankso@6 162
pankso@9 163 # Check if the package (*.tazpkg) exist before installing or extracting.
pankso@6 164 check_for_package_file()
pankso@6 165 {
pankso@9 166 if [ ! -f "$PACKAGE_FILE" ]; then
pankso@6 167 echo -e "
pankso@9 168 Unable to find : $PACKAGE_FILE\n"
pankso@6 169 exit 0
pankso@6 170 fi
pankso@6 171 }
pankso@6 172
pankso@6 173 # Check for the receipt of an installed package.
pankso@6 174 check_for_receipt()
pankso@6 175 {
pankso@6 176 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
pankso@6 177 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
pankso@6 178 exit 0
pankso@6 179 fi
pankso@6 180 }
pankso@6 181
pascal@110 182 # Get package name in a directory
pascal@110 183 package_fullname_in_dir()
pascal@110 184 {
pascal@123 185 [ -f $2$1/receipt ] || return
pascal@114 186 EXTRAVERSION=""
pascal@121 187 . $2$1/receipt
pascal@110 188 echo $PACKAGE-$VERSION$EXTRAVERSION
pascal@110 189 }
pascal@110 190
pascal@110 191 # Get package name that is already installed.
pascal@110 192 get_installed_package_pathname()
pascal@110 193 {
pascal@121 194 for i in $2$INSTALLED/${1%%-*}*; do
pascal@115 195 [ -d $i ] || continue
pascal@121 196 if [ "$1" = "$(package_fullname_in_dir $i $2)" ]; then
pascal@110 197 echo $i
pascal@110 198 return
pascal@110 199 fi
pascal@110 200 done
pascal@110 201 }
pascal@110 202
pankso@6 203 # Check if a package is already installed.
pankso@6 204 check_for_installed_package()
pankso@6 205 {
pascal@121 206 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
pankso@6 207 echo -e "
pankso@6 208 $PACKAGE is already installed. You can use the --forced option to force
pankso@6 209 installation or remove it and reinstall.\n"
pankso@6 210 exit 0
pankso@6 211 fi
pankso@6 212 }
pankso@6 213
pankso@6 214 # Check for packages.list to download and install packages.
pankso@6 215 check_for_packages_list()
pankso@6 216 {
pankso@6 217 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@71 218 if test $(id -u) = 0 ; then
pankso@71 219 tazpkg recharge
pankso@71 220 else
pankso@71 221 echo -e "
pankso@6 222 Unable to find the list : $LOCALSTATE/packages.list\n
MikeDSmith25@135 223 You should probably run 'tazpkg recharge' as root to get the latest list of
MikeDSmith25@135 224 packages available on the mirror.\n"
pankso@71 225 exit 0
pankso@71 226 fi
pankso@6 227 fi
pankso@6 228 }
pankso@6 229
pankso@6 230 # Check for a package in packages.list. Used by get and get-install to grep
pankso@6 231 # package basename.
pankso@6 232 check_for_package_in_list()
pankso@6 233 {
pascal@110 234 local pkg
pascal@187 235 pkg=$(grep -sh "^$PACKAGE-[0-9]" $LOCALSTATE/packages.list \
pascal@187 236 $LOCALSTATE/undigest/*/packages.list | head -1)
pascal@187 237 [ -n "$pkg" ] || pkg=$(grep -sh "^$PACKAGE-.[\.0-9]" \
pascal@187 238 $LOCALSTATE/packages.list \
pascal@187 239 $LOCALSTATE/undigest/*/packages.list | head -1)
pascal@110 240 if [ -n "$pkg" ]; then
pascal@110 241 PACKAGE=$pkg
pankso@6 242 else
pankso@6 243 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
pankso@6 244 exit 0
pankso@6 245 fi
pankso@6 246 }
pankso@6 247
pascal@183 248 # Log this activity
pascal@183 249 log()
pascal@183 250 {
pascal@183 251 [ -e $LOG ] || touch $LOG
pascal@183 252 DATE=`date +'%F %T'`
pascal@183 253 [ -w $LOG ] &&
pascal@183 254 echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)" >> $LOG
pascal@183 255 }
pascal@183 256
pascal@187 257 # Download a file from this mirror
pascal@187 258 download_from()
pascal@187 259 {
pascal@187 260 local i
pascal@187 261 local mirrors
pascal@187 262 mirrors="$1"
pascal@187 263 shift
pascal@187 264 for i in $mirrors; do
pascal@187 265 case "$i" in
pascal@187 266 http://*|ftp://*) wget -c $i$@ && break;;
pascal@187 267 *) cp $i/$1 . && break;;
pascal@187 268 esac
pascal@187 269 done
pascal@187 270 }
pascal@187 271
pascal@17 272 # Download a file trying all mirrors
pascal@17 273 download()
pascal@17 274 {
pascal@187 275 local i
pascal@187 276 for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
pascal@187 277 download_from "$i" "$@"
pascal@17 278 done
pascal@17 279 }
pascal@17 280
pankso@6 281 # Extract a package with cpio and gzip.
pankso@6 282 extract_package()
pankso@6 283 {
pankso@52 284 echo -n "Extracting $PACKAGE... "
pankso@6 285 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
pankso@6 286 gzip -d fs.cpio.gz
pankso@6 287 echo -n "Extracting the pseudo fs... "
pankso@6 288 cpio -id < fs.cpio && rm fs.cpio
pankso@6 289 }
pankso@6 290
MikeDSmith25@135 291 # This function installs a package in the rootfs.
pankso@6 292 install_package()
pankso@6 293 {
pascal@20 294 ROOT=$1
pascal@20 295 if [ -n "$ROOT" ]; then
MikeDSmith25@135 296 # Get absolute path
pascal@20 297 ROOT=$(cd $ROOT; pwd)
pascal@20 298 fi
pascal@122 299 (
MikeDSmith25@134 300 # Create package path early to avoid dependencies loop
pascal@122 301 mkdir -p $TMP_DIR
pascal@122 302 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $PACKAGE_FILE
pascal@122 303 . $TMP_DIR/receipt
pascal@122 304 rm -rf $TMP_DIR
pascal@122 305 # Make the installed package data dir to store
pascal@122 306 # the receipt and the files list.
pascal@122 307 mkdir -p $ROOT$INSTALLED/$PACKAGE
pascal@122 308 )
MikeDSmith25@134 309 # Resolve package deps.
pascal@120 310 check_for_deps $ROOT
pascal@120 311 if [ ! "$MISSING_PACKAGE" = "" ]; then
pascal@120 312 install_deps $ROOT
pascal@120 313 fi
pankso@6 314 mkdir -p $TMP_DIR
pascal@121 315 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $INSTALL_LIST-processed
pankso@6 316 echo ""
pankso@6 317 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
pankso@6 318 echo "================================================================================"
pankso@6 319 echo -n "Copying $PACKAGE... "
pankso@9 320 cp $PACKAGE_FILE $TMP_DIR
pankso@6 321 status
pankso@6 322 cd $TMP_DIR
pankso@6 323 extract_package
pascal@20 324 SELF_INSTALL=0
pascal@114 325 EXTRAVERSION=""
pascal@144 326 CONFIG_FILES=""
pankso@6 327 # Include temporary receipt to get the right variables.
pankso@6 328 . $PWD/receipt
pascal@20 329 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
pascal@20 330 echo -n "Checking post install dependencies... "
pascal@125 331 [ -f $INSTALLED/$PACKAGE/receipt ]
pascal@20 332 if ! status; then
pascal@110 333 echo "Please run 'tazpkg install $PACKAGE_FILE' in / and retry."
pascal@20 334 cd .. && rm -rf $TMP_DIR
pascal@20 335 exit 1
pascal@20 336 fi
pascal@20 337 fi
pascal@21 338 # Remember modified packages
pascal@69 339 for i in $(grep -v '\[' files.list); do
pascal@69 340 [ -e "$ROOT$i" ] || continue
pascal@69 341 [ -d "$ROOT$i" ] && continue
pascal@70 342 for j in $(grep -l "^$i$" $ROOT$INSTALLED/*/files.list); do
pascal@67 343 [ "$j" = "$ROOT$INSTALLED/$PACKAGE/files.list" ] && continue
pascal@65 344 grep -qs ^$PACKAGE$ $(dirname $j)/modifiers && continue
pascal@128 345 if [ -s "$(dirname $j)/volatile.cpio.gz" ]; then
MikeDSmith25@134 346 # We can modify backed up files
pascal@128 347 zcat $(dirname $j)/volatile.cpio.gz | \
pascal@128 348 cpio -t 2> /dev/null | \
pascal@128 349 grep -q "^${i#/}$" && continue
pascal@128 350 fi
pascal@65 351 echo "$PACKAGE" >> $(dirname $j)/modifiers
pascal@65 352 done
pascal@21 353 done
pascal@20 354 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
pascal@20 355 # Copy the description if found.
pankso@6 356 if [ -f "description.txt" ]; then
pascal@20 357 cp description.txt $ROOT$INSTALLED/$PACKAGE
pankso@6 358 fi
pascal@128 359 # Copy the md5sum if found.
pascal@128 360 if [ -f "md5sum" ]; then
pascal@128 361 cp md5sum $ROOT$INSTALLED/$PACKAGE
pascal@128 362 fi
pankso@38 363 # Pre install commands.
pankso@38 364 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 365 pre_install $ROOT
pankso@6 366 fi
pascal@144 367 if [ -n "$CONFIG_FILES" ]; then
pascal@144 368 # save 'official' configuration files
pascal@144 369 echo -n "Save configuration files for $PACKAGE... "
pascal@144 370 for i in $CONFIG_FILES; do
pascal@148 371 ( cd fs ; find ${i#/} -type f )
pascal@144 372 done | ( cd fs ; cpio -o -H newc | gzip -9 ) > \
pascal@144 373 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
pascal@144 374 # keep user configuration files
pascal@144 375 for i in $CONFIG_FILES; do
pascal@148 376 ( cd fs ; find ${i#/} -type f )
pascal@148 377 done | while read i; do
pascal@148 378 [ -e $ROOT/$i ] || continue
pascal@148 379 cp -a $ROOT/$i fs/$i
pascal@144 380 done
pascal@144 381 status
pascal@144 382 fi
pankso@6 383 echo -n "Installing $PACKAGE... "
pascal@20 384 cp -a fs/* $ROOT/
pankso@6 385 status
pankso@6 386 # Remove the temporary random directory.
pankso@6 387 echo -n "Removing all tmp files... "
pankso@6 388 cd .. && rm -rf $TMP_DIR
pankso@6 389 status
pankso@38 390 # Post install commands.
pankso@38 391 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 392 post_install $ROOT
pankso@6 393 fi
pankso@6 394 cd $TOP_DIR
pankso@6 395 echo "================================================================================"
pascal@114 396 echo "$PACKAGE ($VERSION$EXTRAVERSION) is installed."
pankso@6 397 echo ""
pascal@183 398 # Log this activity
pascal@184 399 [ -n "$ROOT" ] || log Installed
pascal@183 400
pankso@6 401 }
pankso@6 402
pascal@122 403 # Check for loop in deps tree.
pascal@122 404 check_for_deps_loop()
pascal@122 405 {
pascal@122 406 local list
pascal@122 407 local pkg
pascal@122 408 local deps
pascal@122 409 pkg=$1
pascal@122 410 shift
pascal@122 411 [ -n "$1" ] || return
pascal@122 412 list=""
pascal@122 413 # Filter out already processed deps
pascal@122 414 for i in $@; do
pascal@122 415 case " $ALL_DEPS" in
pascal@122 416 *\ $i\ *);;
pascal@122 417 *) list="$list $i";;
pascal@122 418 esac
pascal@122 419 done
pascal@122 420 ALL_DEPS="$ALL_DEPS$list "
pascal@122 421 for i in $list; do
pascal@122 422 [ -f $i/receipt ] || continue
pascal@122 423 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@122 424 case " $deps " in
pascal@122 425 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
pascal@122 426 *) check_for_deps_loop $pkg $deps;;
pascal@122 427 esac
pascal@122 428 done
pascal@122 429 }
pascal@122 430
pascal@164 431 # get package from packages.equiv
pascal@164 432 equivalent_pkg()
pascal@164 433 {
pascal@164 434 for i in $(grep -s "^$1=" $2$LOCALSTATE/packages.equiv | sed "s/^$1=//"); do
pascal@164 435 if echo $i | grep -q : ; then
pascal@164 436 # format 'alternative:newname'
pascal@164 437 # if alternative is installed then substitute newname
pascal@164 438 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
pascal@164 439 # substitute package dependancy
pascal@164 440 echo ${i#*:}
pascal@164 441 return
pascal@164 442 fi
pascal@164 443 else
pascal@164 444 # if alternative is installed then nothing to install
pascal@164 445 if [ -f $2$INSTALLED/$i/receipt ]; then
pascal@164 446 # substitute installed package
pascal@164 447 echo $i
pascal@164 448 return
pascal@164 449 fi
pascal@164 450 fi
pascal@164 451 done
pascal@164 452 # if not found in packages.equiv then no substitution
pascal@164 453 echo $1
pascal@164 454 }
pascal@164 455
pankso@6 456 # Check for missing deps listed in a receipt packages.
pankso@6 457 check_for_deps()
pankso@6 458 {
pascal@116 459 local saved;
pascal@116 460 saved=$PACKAGE
pascal@116 461 mkdir -p $TMP_DIR
pascal@122 462 ( cd $TMP_DIR ; cpio -i receipt > /dev/null ) < $PACKAGE_FILE
pascal@116 463 . $TMP_DIR/receipt
pascal@116 464 PACKAGE=$saved
pascal@116 465 rm -rf $TMP_DIR
pascal@164 466 for pkgorg in $DEPENDS
pankso@6 467 do
pascal@164 468 i=$(equivalent_pkg $pkgorg $1)
pascal@120 469 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 470 MISSING_PACKAGE=$i
pankso@6 471 deps=$(($deps+1))
pascal@122 472 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
MikeDSmith25@134 473 echo -e "$WARNING Dependency loop between $PACKAGE and $i."
pankso@6 474 fi
pankso@6 475 done
pankso@6 476 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@6 477 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
pankso@6 478 echo "================================================================================"
pascal@164 479 for pkgorg in $DEPENDS
pankso@6 480 do
pascal@164 481 i=$(equivalent_pkg $pkgorg $1)
pascal@120 482 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 483 MISSING_PACKAGE=$i
pankso@6 484 echo "Missing : $MISSING_PACKAGE"
pankso@6 485 fi
pankso@6 486 done
pankso@6 487 echo "================================================================================"
pankso@6 488 echo "$deps missing package(s) to install."
pankso@6 489 fi
pankso@6 490 }
pankso@6 491
pankso@6 492 # Install all missing deps. First ask user then install all missing deps
pankso@6 493 # from local dir, cdrom, media or from the mirror. In case we want to
pankso@6 494 # install packages from local, we need a packages.list to find the version.
pankso@6 495 install_deps()
pankso@6 496 {
pascal@120 497 local root
pascal@120 498 root=""
pascal@121 499 [ -n "$1" ] && root="--root=$1"
pankso@6 500 echo ""
pankso@10 501 echo -n "Install all missing dependencies (y/N) ? "; read anser
pascal@121 502 echo ""
pankso@6 503 if [ "$anser" = "y" ]; then
pascal@164 504 for pkgorg in $DEPENDS
pankso@6 505 do
pascal@164 506 pkg=$(equivalent_pkg $pkgorg $1)
pascal@120 507 if [ ! -d "$1$INSTALLED/$pkg" ]; then
pascal@121 508 local list
pascal@121 509 list="$INSTALL_LIST"
pascal@121 510 [ -n "$list" ] || list="$TOP_DIR/packages.list"
pankso@6 511 # We can install packages from a local dir by greping
pankso@6 512 # the TAZPKG_BASENAME in the local packages.list.
pascal@153 513 found=0
pascal@121 514 if [ -f "$list" ]; then
pankso@6 515 echo "Checking if $pkg exist in local list... "
pascal@110 516 mkdir $TMP_DIR
pascal@110 517 for i in $pkg-*.tazpkg; do
pascal@124 518 [ -f $i ] || continue
pascal@121 519 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $i
pascal@153 520 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
pascal@121 521 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
pascal@110 522 then
pascal@153 523 found=1
pascal@121 524 tazpkg install $i $root --list=$list
pascal@110 525 break
pascal@110 526 fi
pascal@110 527 done
pascal@110 528 rm -rf $TMP_DIR
pascal@153 529 fi
pankso@6 530 # Install deps from the mirror.
pascal@153 531 if [ $found -eq 0 ]; then
pascal@121 532 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@6 533 tazpkg recharge
pankso@6 534 fi
pascal@120 535 tazpkg get-install $pkg $root
pankso@6 536 fi
pankso@6 537 fi
pankso@6 538 done
pankso@6 539 else
pankso@6 540 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
pankso@6 541 echo -e "The package is installed but will probably not work.\n"
pankso@6 542 fi
pankso@6 543 }
pankso@6 544
pankso@37 545 # xHTML packages list header.
pankso@37 546 xhtml_header()
pankso@37 547 {
pankso@37 548 cat > $XHTML_LIST << _EOT_
pankso@37 549 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
pankso@37 550 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
pankso@37 551 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
pankso@37 552 <head>
pankso@37 553 <title>Installed packages list</title>
pankso@37 554 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
pankso@37 555 <meta name="modified" content="$DATE" />
pankso@37 556 <meta name="generator" content="Tazpkg" />
pankso@37 557 <style type="text/css"><!--
pankso@37 558 body { font: 12px sans-serif, vernada, arial; margin: 0; }
pankso@37 559 #header { background: #f0ba08; color: black; height: 50px;
pankso@37 560 border-top: 1px solid black; border-bottom: 1px solid black; }
pankso@37 561 #content { margin: 0px 50px 26px 50px; }
pankso@37 562 #footer { border-top: 1px solid black; padding-top: 10px;}
pankso@37 563 h1 { margin: 14px 0px 0px 16px; }
pankso@37 564 pre { padding-left: 5px; }
pankso@37 565 hr { color: white; background: white; height: 1px; border: 0; }
pankso@37 566 --></style>
pankso@37 567 </head>
pankso@37 568 <body bgcolor="#ffffff">
pankso@37 569 <div id="header">
pankso@37 570 <h1><font color="#3e1220">Installed packages list</font></h1>
pankso@37 571 </div>
pankso@37 572 <hr />
pankso@37 573 <!-- Start content -->
pankso@37 574 <div id="content">
pankso@37 575
pankso@37 576 <p>
pankso@37 577 _packages_ packages installed - List generated on : $DATE
pankso@37 578 <p>
pankso@37 579
pankso@37 580 _EOT_
pankso@37 581 }
pankso@37 582
MikeDSmith25@135 583 # xHTML content with packages info.
pankso@37 584 xhtml_pkg_info()
pankso@37 585 {
pankso@37 586 cat >> $XHTML_LIST << _EOT_
pankso@37 587 <h3>$PACKAGE</h3>
pankso@37 588 <pre>
pascal@114 589 Version : $VERSION$EXTRAVERSION
pankso@37 590 Short desc : $SHORT_DESC
pankso@37 591 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
pankso@37 592 </pre>
pankso@37 593
pankso@37 594 _EOT_
pankso@37 595 }
pankso@37 596
pankso@37 597 # xHTML packages list footer.
pankso@37 598 xhtml_footer()
pankso@37 599 {
pankso@37 600 cat >> $XHTML_LIST << _EOT_
pankso@37 601 <hr />
pankso@37 602 <p id="footer">
pankso@37 603 $packages packages installed - List generated on : $DATE
pankso@37 604 </p>
pankso@37 605
pankso@37 606 <!-- End content -->
pankso@37 607 </div>
pankso@37 608 </body>
pankso@37 609 </html>
pankso@37 610 _EOT_
pankso@37 611 }
pankso@37 612
pankso@54 613 # Search pattern in installed packages.
pankso@54 614 search_in_installed_packages()
pankso@54 615 {
pankso@54 616 echo "Installed packages"
pankso@54 617 echo "================================================================================"
erjo@62 618 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
pankso@54 619 for pkg in $list
pankso@54 620 do
pascal@114 621 EXTRAVERSION=""
pascal@122 622 [ -f $INSTALLED/$pkg/receipt ] || continue
pankso@54 623 . $INSTALLED/$pkg/receipt
pankso@54 624 echo -n "$PACKAGE "
pascal@114 625 echo -en "\033[24G $VERSION$EXTRAVERSION"
pankso@54 626 echo -e "\033[42G $CATEGORY"
pankso@54 627 packages=$(($packages+1))
pankso@54 628 done
pankso@54 629 # Set correct ending messages.
pankso@54 630 if [ "$packages" = "" ]; then
pankso@54 631 echo "0 installed packages found for : $PATTERN"
pankso@54 632 echo ""
pankso@54 633 else
pankso@54 634 echo "================================================================================"
pankso@54 635 echo "$packages installed package(s) found for : $PATTERN"
pankso@54 636 echo ""
pankso@54 637 fi
pankso@54 638 }
pankso@54 639
MikeDSmith25@135 640 # Search in packages.list for available pkgs.
pankso@54 641 search_in_packages_list()
pankso@54 642 {
pankso@54 643 echo "Available packages name-version"
pankso@54 644 echo "================================================================================"
pascal@187 645 packages=0
pascal@187 646 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
pascal@187 647 grep -is "$PATTERN" $i
pascal@187 648 packages=$(($packages + `grep -is "$PATTERN" $i | wc -l`))
pascal@187 649 done
pascal@187 650 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@54 651 echo -e "
pankso@54 652 No 'packages.list' found to check for mirrored packages. For more results,
MikeDSmith25@135 653 please run 'tazpkg recharge' once as root before searching.\n"
pankso@54 654 fi
pankso@54 655 if [ "$packages" = "0" ]; then
pankso@54 656 echo "0 available packages found for : $PATTERN"
pankso@54 657 echo ""
pankso@54 658 else
pankso@54 659 echo "================================================================================"
pankso@54 660 echo "$packages available package(s) found for : $PATTERN"
pankso@54 661 echo ""
pankso@54 662 fi
pankso@54 663 }
pankso@54 664
MikeDSmith25@135 665 # search --mirror: Search in packages.txt for available pkgs and give more
MikeDSmith25@135 666 # info than --list or default.
pankso@54 667 search_in_packages_txt()
pankso@54 668 {
pankso@54 669 echo "Matching packages name with version and desc"
pankso@54 670 echo "================================================================================"
pascal@187 671 packages=0
pascal@187 672 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
pascal@187 673 grep -is -A 2 "^$PATTERN" $i
pascal@187 674 packages=$(($packages + `grep -is "^$PATTERN" $i | wc -l`))
pascal@187 675 done
pascal@187 676 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
pankso@54 677 echo -e "
pankso@54 678 No 'packages.txt' found to check for mirrored packages. For more results,
MikeDSmith25@135 679 please run 'tazpkg recharge' once as root before searching.\n"
pankso@54 680 fi
pankso@54 681 if [ "$packages" = "0" ]; then
pankso@54 682 echo "0 available packages found for : $PATTERN"
pankso@54 683 echo ""
pankso@54 684 else
pankso@54 685 echo "================================================================================"
pankso@54 686 echo "$packages available package(s) found for : $PATTERN"
pankso@54 687 echo ""
pankso@54 688 fi
pankso@54 689 }
pankso@54 690
pascal@74 691 # Install package-list from a flavor
pascal@74 692 install_flavor()
pascal@74 693 {
pascal@74 694 check_root
pascal@74 695 FLAVOR=$1
pascal@74 696 ARG=$2
pascal@74 697 mkdir -p $TMP_DIR
pascal@74 698 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
pascal@74 699 cd $TMP_DIR
pascal@74 700 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
pascal@74 701 zcat $FLAVOR.flavor | cpio -i 2>/dev/null
pascal@74 702 while read file; do
pascal@74 703 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
pascal@122 704 [ -f $pkg/receipt ] || continue
pascal@114 705 EXTRAVERSION=""
pascal@74 706 . $pkg/receipt
pascal@114 707 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
pascal@74 708 done
pascal@114 709 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
pascal@74 710 cd $CACHE_DIR
pascal@74 711 download $file.tazpkg
pascal@74 712 cd $TMP_DIR
pascal@74 713 tazpkg install $CACHE_DIR/$file.tazpkg --forced
pascal@74 714 done < $FLAVOR.pkglist
pascal@75 715 [ -f $FLAVOR.nonfree ] && while read pkg; do
pascal@75 716 [ -d $INSTALLED/$pkg ] || continue
pascal@75 717 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
pascal@75 718 get-$pkg
pascal@75 719 done < $FLAVOR.nonfree
pascal@74 720 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
pascal@122 721 [ -f $INSTALLED/$pkg/receipt ] || continue
pascal@114 722 EXTRAVERSION=""
pascal@74 723 . $INSTALLED/$pkg/receipt
pascal@114 724 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
pascal@75 725 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
pascal@74 726 tazpkg remove $PACKAGE
pascal@74 727 done
pascal@74 728 else
pascal@74 729 echo "Can't find flavor $FLAVOR Abort."
pascal@74 730 fi
pascal@74 731 cd $TOP_DIR
pascal@74 732 rm -rf $TMP_DIR
pascal@74 733 }
pascal@74 734
pascal@187 735 # Update mirror urls
pascal@187 736 setup_mirror()
pascal@187 737 {
pascal@187 738 # Backup old list.
pascal@187 739 if [ -f "$1/mirror" ]; then
pascal@187 740 cp -f $1/mirror $1/mirror.bak
pascal@187 741 fi
pascal@187 742 echo ""
pascal@187 743 echo -e "\033[1mCurrent mirror(s)\033[0m"
pascal@187 744 echo "================================================================================"
pascal@187 745 echo " `cat $1/mirror 2> /dev/null`"
pascal@187 746 echo "
pascal@187 747 Please enter URL of the new mirror (http, ftp or local path). You must specify
pascal@187 748 the complete address to the directory of the packages and packages.list file."
pascal@187 749 echo ""
pascal@187 750 echo -n "New mirror(s) URL : "
pascal@187 751 NEW_MIRROR_URL=$2
pascal@187 752 if [ -n "$NEW_MIRROR_URL" ]; then
pascal@187 753 echo $NEW_MIRROR_URL
pascal@187 754 else
pascal@187 755 read NEW_MIRROR_URL
pascal@187 756 fi
pascal@187 757 if [ "$NEW_MIRROR_URL" = "" ]; then
pascal@187 758 echo "Nothing has been changed."
pascal@187 759 else
pascal@187 760 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
pascal@187 761 rm -f $1/mirror
pascal@187 762 for i in $NEW_MIRROR_URL; do
pascal@187 763 echo "$i" >> $1/mirror
pascal@187 764 done
pascal@187 765 fi
pascal@187 766 echo ""
pascal@187 767 }
pascal@187 768
pankso@6 769 ###################
pankso@6 770 # Tazpkg commands #
pankso@6 771 ###################
pankso@6 772
pankso@6 773 case "$COMMAND" in
pankso@6 774 list)
pankso@6 775 # List all installed packages or a specific category.
pankso@6 776 #
pankso@45 777 if [ "$2" = "blocked" ]; then
pankso@45 778 echo ""
pankso@45 779 echo -e "\033[1mBlocked packages\033[0m"
pankso@45 780 echo "================================================================================"
pascal@183 781 if [ -s "$BLOCKED" ];then
pascal@183 782 cat $BLOCKED
pankso@45 783 echo ""
pankso@45 784 else
pankso@45 785 echo -e "No blocked packages found.\n"
pankso@45 786 fi
pankso@45 787 exit 0
pankso@45 788 fi
pankso@45 789 # Display the list of categories.
pankso@46 790 if [ "$2" = "cat" -o "$2" = "categories" ]; then
pankso@45 791 echo ""
pankso@45 792 echo -e "\033[1mPackages categories :\033[0m"
pankso@45 793 echo "================================================================================"
pankso@45 794 for i in $CATEGORIES
pankso@45 795 do
pankso@45 796 echo $i
pankso@45 797 categories=$(($categories+1))
pankso@45 798 done
pankso@45 799 echo "================================================================================"
pankso@45 800 echo "$categories categories"
pankso@45 801 echo ""
pankso@6 802 exit 0
pankso@6 803 fi
pankso@6 804 # Check for an asked category.
pankso@6 805 if [ -n "$2" ]; then
pankso@6 806 ASKED_CATEGORY=$2
pankso@6 807 echo ""
pankso@6 808 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
pankso@6 809 echo "================================================================================"
pankso@6 810 for pkg in $INSTALLED/*
pankso@6 811 do
pascal@122 812 [ -f $pkg/receipt ] || continue
pascal@114 813 EXTRAVERSION=""
pankso@6 814 . $pkg/receipt
pankso@6 815 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@6 816 echo -n "$PACKAGE"
pascal@114 817 echo -e "\033[24G $VERSION$EXTRAVERSION"
pankso@6 818 packages=$(($packages+1))
pankso@6 819 fi
pankso@6 820 done
pankso@6 821 echo "================================================================================"
pankso@6 822 echo -e "$packages packages installed of category $ASKED_CATEGORY."
pankso@6 823 echo ""
pankso@6 824 else
MikeDSmith25@135 825 # By default list all packages and versions.
pankso@6 826 echo ""
pankso@6 827 echo -e "\033[1mList of all installed packages\033[0m"
pankso@6 828 echo "================================================================================"
pankso@6 829 for pkg in $INSTALLED/*
pankso@6 830 do
pascal@122 831 [ -f $pkg/receipt ] || continue
pascal@114 832 EXTRAVERSION=""
pankso@6 833 . $pkg/receipt
pankso@6 834 echo -n "$PACKAGE"
pascal@114 835 echo -en "\033[24G $VERSION$EXTRAVERSION"
pankso@6 836 echo -e "\033[42G $CATEGORY"
pankso@6 837 packages=$(($packages+1))
pankso@6 838 done
pankso@6 839 echo "================================================================================"
pankso@6 840 echo "$packages packages installed."
pankso@6 841 echo ""
pankso@6 842 fi
pankso@6 843 ;;
pankso@37 844 xhtml-list)
MikeDSmith25@135 845 # Get info in receipts and build list.
pankso@37 846 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
pankso@37 847 if [ -n "$2" ]; then
pankso@37 848 XHTML_LIST=$2
pankso@37 849 else
pankso@38 850 XHTML_LIST=installed-packages.html
pankso@37 851 fi
pankso@37 852 echo ""
pankso@37 853 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
pankso@37 854 echo "================================================================================"
pankso@37 855 echo -n "Generating xHTML header..."
pankso@37 856 xhtml_header
pankso@37 857 status
pankso@37 858 # Packages
MikeDSmith25@135 859 echo -n "Creating packages information..."
pankso@37 860 for pkg in $INSTALLED/*
pankso@37 861 do
pascal@122 862 [ -f $pkg/receipt ] || continue
pascal@114 863 EXTRAVERSION=""
pankso@37 864 . $pkg/receipt
pankso@37 865 xhtml_pkg_info
pankso@37 866 packages=$(($packages+1))
pankso@37 867 done
pankso@37 868 status
pankso@37 869 echo -n "Generating xHTML footer..."
pankso@37 870 xhtml_footer
pankso@37 871 status
pankso@37 872 # sed pkgs nb in header.
pankso@37 873 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
pankso@37 874 echo "================================================================================"
pankso@37 875 echo "$XHTML_LIST created - $packages packages."
pankso@37 876 echo ""
pankso@37 877 ;;
pankso@6 878 list-mirror)
pankso@6 879 # List all available packages on the mirror. Option --diff display
pankso@6 880 # last mirrored packages diff (see recharge).
pankso@6 881 check_for_packages_list
pankso@53 882 case $2 in
pankso@53 883 --diff)
pankso@53 884 if [ -f "$LOCALSTATE/packages.diff" ]; then
pankso@53 885 echo ""
pankso@53 886 echo -e "\033[1mMirrored packages diff\033[0m"
pankso@53 887 echo "================================================================================"
pankso@53 888 cat $LOCALSTATE/packages.diff
pankso@53 889 echo "================================================================================"
pankso@53 890 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
pankso@53 891 echo "$pkgs new packages listed on the mirror."
pankso@53 892 echo ""
pankso@53 893 else
pankso@53 894 echo -e "\nUnable to list anything, no packages.diff found."
MikeDSmith25@135 895 echo -e "Recharge your current list to create a first diff.\n"
pankso@53 896 fi && exit 0 ;;
pankso@53 897 --text|--txt)
pankso@6 898 echo ""
pankso@53 899 echo -e "\033[1mList of available packages on the mirror\033[0m"
pankso@6 900 echo "================================================================================"
pankso@53 901 cat $LOCALSTATE/packages.txt ;;
pankso@53 902 --raw|*)
pankso@53 903 echo ""
pankso@53 904 echo -e "\033[1mList of available packages on the mirror\033[0m"
pankso@6 905 echo "================================================================================"
pankso@53 906 cat $LOCALSTATE/packages.list ;;
pankso@53 907 esac
pankso@53 908 echo "================================================================================"
pankso@53 909 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
pankso@53 910 echo "$pkgs packages in the last recharged list."
pankso@53 911 echo ""
pankso@6 912 ;;
pankso@6 913 list-files)
pankso@6 914 # List files installed with the package.
pankso@6 915 #
pankso@6 916 check_for_package_on_cmdline
pankso@6 917 check_for_receipt
pankso@6 918 echo ""
pankso@6 919 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
pankso@6 920 echo "================================================================================"
pankso@6 921 cat $INSTALLED/$PACKAGE/files.list | sort
pankso@6 922 echo "================================================================================"
pankso@6 923 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
pankso@6 924 echo "$files files installed with $PACKAGE."
pankso@6 925 echo ""
pankso@6 926 ;;
pankso@6 927 info)
pascal@119 928 # Information about package.
pankso@6 929 #
pankso@6 930 check_for_package_on_cmdline
pankso@6 931 check_for_receipt
pascal@114 932 EXTRAVERSION=""
pankso@6 933 . $INSTALLED/$PACKAGE/receipt
pankso@6 934 echo ""
MikeDSmith25@135 935 echo -e "\033[1mTazpkg information\033[0m
pankso@6 936 ================================================================================
pankso@6 937 Package : $PACKAGE
pascal@114 938 Version : $VERSION$EXTRAVERSION
pankso@6 939 Category : $CATEGORY
pankso@6 940 Short desc : $SHORT_DESC
pankso@6 941 Maintainer : $MAINTAINER"
pankso@6 942 if [ ! "$DEPENDS" = "" ]; then
pankso@6 943 echo -e "Depends : $DEPENDS"
pankso@6 944 fi
pankso@38 945 if [ ! "$SUGGESTED" = "" ]; then
pankso@38 946 echo -e "Suggested : $SUGGESTED"
pankso@38 947 fi
pankso@38 948 if [ ! "$BUILD_DEPENDS" = "" ]; then
pankso@38 949 echo -e "Build deps : $BUILD_DEPENDS"
pankso@38 950 fi
pankso@6 951 if [ ! "$WANTED" = "" ]; then
pankso@6 952 echo -e "Wanted src : $WANTED"
pankso@6 953 fi
pankso@6 954 if [ ! "$WEB_SITE" = "" ]; then
pankso@6 955 echo -e "Web site : $WEB_SITE"
pankso@6 956 fi
pankso@6 957 echo "================================================================================"
pankso@6 958 echo ""
pankso@6 959 ;;
pankso@6 960 desc)
pankso@6 961 # Display package description.txt if available.
pankso@6 962 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
pankso@6 963 echo ""
pankso@6 964 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
pankso@6 965 echo "================================================================================"
pankso@6 966 cat $INSTALLED/$PACKAGE/description.txt
pankso@6 967 echo "================================================================================"
pankso@6 968 echo ""
pankso@6 969 else
pankso@6 970 echo -e "\nSorry, no description available for this package.\n"
pankso@6 971 fi
pankso@6 972 ;;
pankso@6 973 search)
pankso@6 974 # Search for a package by pattern or name.
pankso@6 975 #
pankso@54 976 PATTERN="$2"
pankso@54 977 if [ -z "$PATTERN" ]; then
MikeDSmith25@135 978 echo -e "\nPlease specify a pattern or package name to search for."
pankso@54 979 echo -e "Example : 'tazpkg search paint'.\n"
pankso@6 980 exit 0
pankso@6 981 fi
pankso@6 982 echo ""
pankso@54 983 echo -e "\033[1mSearch result for :\033[0m $PATTERN"
pankso@6 984 echo ""
pankso@54 985 # Default is to search in installed pkgs and the raw list.
pankso@54 986 case $3 in
pankso@54 987 -i|--installed)
pankso@54 988 search_in_installed_packages ;;
pankso@54 989 -l|--list)
pankso@54 990 search_in_packages_list ;;
pankso@54 991 -m|--mirror)
pankso@54 992 search_in_packages_txt ;;
pankso@54 993 *)
pankso@54 994 search_in_installed_packages
pankso@54 995 search_in_packages_list ;;
pankso@54 996 esac
pankso@12 997 ;;
pankso@12 998 search-file)
pankso@12 999 # Search for a file by pattern or name in all files.list.
pankso@12 1000 #
pankso@12 1001 if [ -z "$2" ]; then
MikeDSmith25@135 1002 echo -e "\nPlease specify a pattern or file name to search for."
pankso@12 1003 echo -e "Example : 'tazpkg search-file libnss'. \n"
pankso@12 1004 exit 0
pankso@12 1005 fi
pankso@12 1006 echo ""
pankso@12 1007 echo -e "\033[1mSearch result for file :\033[0m $2"
pankso@6 1008 echo "================================================================================"
pascal@98 1009
pascal@98 1010 if [ "$3" == "--mirror" ]; then
pascal@98 1011
pascal@187 1012 match=0
pascal@187 1013 for i in $LOCALSTATE/files.list.lzma \
pascal@187 1014 $LOCALSTATE/undigest/*/files.list.lzma; do
pascal@187 1015 [ -f $i ] || continue
pascal@187 1016 unlzma -c $i | grep -- ".*:.*$2" | awk '
pascal@98 1017 BEGIN { last="" }
pascal@98 1018 {
pascal@98 1019 pkg=substr($0,0,index($0,":")-1);
pascal@98 1020 file=substr($0,index($0,":")+2);
pascal@98 1021 if (last != pkg) {
pascal@98 1022 last = pkg;
pascal@98 1023 printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27);
pascal@98 1024 }
pascal@98 1025 printf("%s\n",file);
pascal@98 1026 }'
pascal@187 1027 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
pascal@187 1028 done
pascal@98 1029
pascal@98 1030 else
pascal@98 1031
pankso@12 1032 # Check all pkg files.list in search match with specify the package
pankso@12 1033 # name and the full path to the file(s).
pankso@12 1034 for pkg in $INSTALLED/*
pankso@12 1035 do
pascal@122 1036 if grep -qs "$2" $pkg/files.list; then
pankso@12 1037 . $pkg/receipt
pankso@12 1038 echo ""
pankso@12 1039 echo -e "\033[1mPackage $PACKAGE :\033[0m"
pankso@54 1040 grep "$2" $pkg/files.list
pankso@12 1041 files=`grep $2 $pkg/files.list | wc -l`
pankso@12 1042 match=$(($match+$files))
pankso@12 1043 fi
pankso@12 1044 done
pascal@98 1045
pascal@98 1046 fi
pascal@98 1047
pankso@12 1048 if [ "$match" = "" ]; then
pankso@12 1049 echo "0 file found for : $2"
pankso@12 1050 echo ""
pankso@12 1051 else
pankso@12 1052 echo ""
pankso@12 1053 echo "================================================================================"
pankso@12 1054 echo "$match file(s) found for : $2"
pankso@12 1055 echo ""
pankso@12 1056 fi
pankso@6 1057 ;;
pankso@6 1058 install)
pankso@6 1059 # Install .tazpkg packages.
pankso@6 1060 #
pankso@6 1061 check_root
pankso@6 1062 check_for_package_on_cmdline
pankso@6 1063 check_for_package_file
pankso@6 1064 # Check if forced install.
pascal@20 1065 DO_CHECK="yes"
pascal@120 1066 ROOT=""
pascal@20 1067 while [ -n "$3" ]; do
pascal@20 1068 case "$3" in
pascal@20 1069 --forced)
pascal@20 1070 DO_CHECK="no"
pascal@20 1071 ;;
pascal@20 1072 --root=*)
pascal@120 1073 ROOT="${3#--root=}"
pascal@20 1074 ;;
pascal@121 1075 --list=*)
pascal@121 1076 INSTALL_LIST="${3#--list=}"
pascal@121 1077 ;;
pascal@20 1078 *) shift 2
pascal@20 1079 echo -e "\nUnknown option $*.\n"
pascal@20 1080 exit 1
pascal@20 1081 ;;
pascal@20 1082 esac
pascal@20 1083 shift
pascal@20 1084 done
pascal@20 1085 if [ "$DO_CHECK" = "yes" ]; then
pascal@121 1086 check_for_installed_package $ROOT
pankso@6 1087 fi
pascal@120 1088 install_package $ROOT
pankso@6 1089 ;;
erjo@59 1090 install-list|get-install-list)
pankso@6 1091 # Install a set of packages from a list.
pankso@6 1092 #
pankso@6 1093 check_root
pankso@6 1094 if [ -z "$2" ]; then
pankso@6 1095 echo -e "
pankso@6 1096 Please change directory (cd) to the packages repository, and specify the
pankso@6 1097 list of packages to install. Example : tazpkg install-list packages.list\n"
pankso@6 1098 exit 0
pankso@6 1099 fi
pankso@6 1100 # Check if the packages list exist.
pankso@6 1101 if [ ! -f "$2" ]; then
pankso@6 1102 echo "Unable to find : $2"
pankso@6 1103 exit 0
pankso@6 1104 else
pankso@6 1105 LIST=`cat $2`
pankso@6 1106 fi
pascal@120 1107
pascal@120 1108 # Remember processed list
pascal@121 1109 export INSTALL_LIST="$2"
pascal@120 1110
erjo@59 1111 # Set $COMMAND and install all packages.
erjo@59 1112 if [ "$1" = "get-install-list" ]; then
Eric@64 1113 COMMAND=get-install
erjo@59 1114 else
erjo@59 1115 COMMAND=install
erjo@59 1116 fi
pascal@121 1117 touch $2-processed
pankso@6 1118 for pkg in $LIST
pankso@6 1119 do
pascal@121 1120 grep -qs ^$pkg$ $2-processed && continue
pascal@121 1121 tazpkg $COMMAND $pkg --list=$2 "$3" "$4" "$5"
pankso@6 1122 done
pascal@121 1123 rm -f $2-processed
pankso@6 1124 ;;
pankso@76 1125 add-flavor)
pascal@74 1126 # Install a set of packages from a flavor.
pascal@74 1127 #
pascal@74 1128 install_flavor $2
pascal@74 1129 ;;
pankso@76 1130 install-flavor)
pascal@74 1131 # Install a set of packages from a flavor and purge other ones.
pascal@74 1132 #
pascal@74 1133 install_flavor $2 --purge
pascal@74 1134 ;;
pankso@76 1135 set-release)
pascal@74 1136 # Change curent release and upgrade packages.
pascal@74 1137 #
pascal@74 1138 RELEASE=$2
pankso@76 1139 if [ -z "$RELEASE" ]; then
pankso@76 1140 echo -e "\nPlease specify the release you want on the command line."
pankso@76 1141 echo -e "Example: tazpkg set-release cooking\n"
pankso@76 1142 exit 0
pankso@76 1143 fi
pascal@74 1144 rm /var/lib/tazpkg/mirror
pascal@74 1145 echo "$RELEASE" > /etc/slitaz-release
pascal@74 1146 tazpkg recharge && tazpkg upgrade
pascal@74 1147 ;;
pankso@6 1148 remove)
pankso@6 1149 # Remove packages.
pankso@6 1150 #
pankso@6 1151 check_root
pankso@6 1152 check_for_package_on_cmdline
pascal@122 1153 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
pankso@6 1154 echo -e "\n$PACKAGE is not installed.\n"
pankso@6 1155 exit 0
pankso@6 1156 else
pascal@30 1157 ALTERED=""
pascal@30 1158 THE_PACKAGE=$PACKAGE # altered by receipt
pascal@30 1159 for i in $(cd $INSTALLED ; ls); do
pascal@163 1160 [ -f $i/receipt ] || continue
pankso@37 1161 DEPENDS=""
pascal@30 1162 . $INSTALLED/$i/receipt
pascal@30 1163 case " $(echo $DEPENDS) " in
pascal@30 1164 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
pascal@30 1165 esac
pascal@30 1166 done
pascal@114 1167 EXTRAVERSION=""
pascal@30 1168 . $INSTALLED/$THE_PACKAGE/receipt
pankso@6 1169 fi
pankso@6 1170 echo ""
pascal@30 1171 if [ -n "$ALTERED" ]; then
pascal@30 1172 echo "The following packages depend on $PACKAGE :"
pascal@30 1173 for i in $ALTERED; do
pascal@30 1174 echo " $i"
pascal@30 1175 done
pascal@30 1176 fi
pascal@163 1177 REFRESH=$(cd $INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
pascal@163 1178 if [ -n "$REFRESH" ]; then
pascal@170 1179 echo "The following packages have been modified by $PACKAGE :"
pascal@163 1180 for i in $REFRESH; do
pascal@170 1181 echo " ${i%/modifiers}"
pascal@163 1182 done
pascal@163 1183 fi
pascal@114 1184 echo "Remove $PACKAGE ($VERSION$EXTRAVERSION) ?"
pankso@6 1185 echo -n "Please confirm uninstallation (y/N) : "; read anser
pankso@6 1186 if [ "$anser" = "y" ]; then
pankso@6 1187 echo ""
pankso@6 1188 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
pankso@6 1189 echo "================================================================================"
pankso@38 1190 # Pre remove commands.
pankso@38 1191 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
pankso@38 1192 pre_remove
pankso@38 1193 fi
pankso@6 1194 echo -n "Removing all files installed..."
pankso@6 1195 for file in `cat $INSTALLED/$PACKAGE/files.list`
pankso@6 1196 do
pascal@60 1197 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
erjo@161 1198 rm -rf $file 2>/dev/null
pankso@6 1199 done
pankso@6 1200 status
pankso@51 1201 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
pankso@51 1202 post_remove
pankso@51 1203 fi
pankso@6 1204 # Remove package receipt.
pankso@6 1205 echo -n "Removing package receipt..."
pankso@6 1206 rm -rf $INSTALLED/$PACKAGE
pankso@6 1207 status
pascal@183 1208 # Log this activity
pascal@183 1209 log Removed
pascal@30 1210 if [ -n "$ALTERED" ]; then
pascal@30 1211 echo -n "Remove packages depending on $PACKAGE"
pascal@30 1212 echo -n " (y/N) ? "; read anser
pascal@30 1213 if [ "$anser" = "y" ]; then
pascal@30 1214 for i in $ALTERED; do
pankso@37 1215 if [ -d "$INSTALLED/$i" ]; then
pankso@37 1216 tazpkg remove $i
pankso@37 1217 fi
pascal@30 1218 done
pascal@30 1219 fi
pascal@30 1220 fi
pascal@163 1221 if [ -n "$REFRESH" ]; then
pascal@163 1222 echo -n "Reinstall packages modified by $PACKAGE"
pascal@163 1223 echo -n " (y/N) ? "; read anser
pascal@163 1224 if [ "$anser" = "y" ]; then
pascal@163 1225 for i in $REFRESH; do
pascal@170 1226 if [ $(wc -l $INSTALLED/$i) -gt 1 ]; then
pascal@170 1227 echo "Check $INSTALLED/$i for reinstallation"
pascal@163 1228 continue
pascal@163 1229 fi
pascal@170 1230 rm -r $INSTALLED/$i
pascal@170 1231 tazpkg get-install ${i%/modifiers} --forced
pascal@163 1232 done
pascal@163 1233 fi
pascal@163 1234 fi
pankso@6 1235 else
pankso@6 1236 echo ""
pankso@6 1237 echo "Uninstallation of $PACKAGE cancelled."
pankso@6 1238 fi
pankso@6 1239 echo ""
pankso@6 1240 ;;
pankso@6 1241 extract)
pankso@6 1242 # Extract .tazpkg cpio archive into a directory.
pankso@6 1243 #
pankso@6 1244 check_for_package_on_cmdline
pankso@6 1245 check_for_package_file
pankso@6 1246 echo ""
pankso@6 1247 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
pankso@6 1248 echo "================================================================================"
MikeDSmith25@135 1249 # If no directory destination is found on the cmdline
MikeDSmith25@135 1250 # we create one in the current dir using the package name.
pankso@6 1251 if [ -n "$TARGET_DIR" ]; then
pankso@6 1252 DESTDIR=$TARGET_DIR/$PACKAGE
pankso@6 1253 else
pankso@6 1254 DESTDIR=$PACKAGE
pankso@6 1255 fi
pankso@6 1256 mkdir -p $DESTDIR
pankso@6 1257 echo -n "Copying original package..."
pankso@9 1258 cp $PACKAGE_FILE $DESTDIR
pankso@6 1259 status
pankso@6 1260 cd $DESTDIR
pankso@6 1261 extract_package
pankso@6 1262 echo "================================================================================"
pankso@6 1263 echo "$PACKAGE is extracted to : $DESTDIR"
pankso@6 1264 echo ""
pankso@6 1265 ;;
pascal@139 1266 list-config)
pascal@139 1267 # List configuration files installed.
pascal@139 1268 #
pascal@141 1269 if [ "$2" = "--box" ]; then
pascal@141 1270 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@141 1271 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@141 1272 zcat $i | cpio -id > /dev/null
pascal@141 1273 find * -type f | while read file; do
pascal@143 1274 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
pascal@141 1275 cmp $file /$file > /dev/null 2>&1 || \
pascal@141 1276 echo -n "$(stat -c "%.16y" /$file)"
pascal@143 1277 echo "|/$file"
pascal@141 1278 done
pascal@141 1279 rm -rf *
pascal@146 1280 done
pascal@141 1281 cd $TOP_DIR
pascal@141 1282 rm -rf $TMP_DIR
pascal@141 1283 else
pascal@141 1284 echo ""
pascal@141 1285 echo -e "\033[1mConfiguration files"
pascal@141 1286 echo "================================================================================"
pascal@146 1287 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@146 1288 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
pascal@146 1289 [ -f "$i" ] || continue
pascal@146 1290 zcat $i | cpio -t | grep -v "[0-9]* blocks"
pascal@146 1291 done | sed 's|^|/|' | sort
pascal@141 1292 echo "================================================================================"
pascal@141 1293 echo ""
pascal@141 1294 fi
pascal@139 1295 ;;
pascal@139 1296 repack-config)
pascal@137 1297 # Create SliTaz package archive from configuration files.
pascal@137 1298 #
pascal@137 1299 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@137 1300 CONFIG_VERSION=1.0
pascal@137 1301 mkdir config-$CONFIG_VERSION
pascal@137 1302 cd config-$CONFIG_VERSION
pascal@137 1303 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@137 1304 zcat $i | cpio -t | grep -v "[0-9]* blocks"
pascal@137 1305 done > files.list
pascal@137 1306 mkdir fs
pascal@137 1307 cd fs
pascal@137 1308 ( cd / ; cpio -o -H newc ) < ../files.list | cpio -id > /dev/null
pascal@137 1309 mkdir -p etc/tazlito
pascal@137 1310 for i in $INSTALLED/*/receipt; do
pascal@137 1311 EXTRAVERSION=""
pascal@137 1312 . $i
pascal@137 1313 echo "$PACKAGE-$VERSION$EXTRAVERSION"
pascal@137 1314 done > etc/tazlito/config-packages.list
pascal@137 1315 cd ..
pascal@137 1316 echo "etc/tazlito/config-packages.list" >> files.list
pascal@137 1317 cat > receipt <<EOT
pascal@137 1318 # SliTaz package receipt.
pascal@137 1319
pascal@137 1320 PACKAGE="config"
pascal@137 1321 VERSION="$CONFIG_VERSION"
pascal@137 1322 CATEGORY="base-system"
pascal@137 1323 SHORT_DESC="User configuration backup on $(date)"
pascal@137 1324 DEPENDS="$(ls $INSTALLED)"
pascal@137 1325 EOT
pascal@137 1326 cd ..
pascal@137 1327 tazpkg pack config-$CONFIG_VERSION
pascal@137 1328 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
pascal@137 1329 cd $TOP_DIR
pascal@137 1330 rm -rf $TMP_DIR
pascal@137 1331 ;;
pascal@18 1332 repack)
MikeDSmith25@135 1333 # Create SliTaz package archive from an installed package.
pascal@18 1334 #
pascal@18 1335 check_for_package_on_cmdline
pascal@18 1336 check_for_receipt
pascal@114 1337 EXTRAVERSION=""
pascal@114 1338 . $INSTALLED/$PACKAGE/receipt
pascal@18 1339 echo ""
pascal@114 1340 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
pascal@18 1341 echo "================================================================================"
pascal@24 1342 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
pascal@24 1343 echo "Can't repack $PACKAGE"
pascal@24 1344 exit 1
pascal@24 1345 fi
pascal@21 1346 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
pascal@21 1347 echo "Can't repack, $PACKAGE files have been modified by:"
pascal@21 1348 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
pascal@21 1349 echo " $i"
pascal@21 1350 done
pascal@21 1351 exit 1
pascal@21 1352 fi
pascal@18 1353 MISSING=""
pascal@63 1354 while read i; do
pascal@18 1355 [ -e "$i" ] && continue
pascal@63 1356 [ -L "$i" ] || MISSING="$MISSING\n $i"
pascal@63 1357 done < $INSTALLED/$PACKAGE/files.list
pascal@18 1358 if [ -n "$MISSING" ]; then
pascal@63 1359 echo -n "Can't repack, the following files are lost:"
pascal@63 1360 echo -e "$MISSING"
pascal@18 1361 exit 1
pascal@18 1362 fi
pascal@24 1363 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@24 1364 FILES="fs.cpio.gz\n"
pascal@24 1365 for i in $(ls $INSTALLED/$PACKAGE) ; do
pascal@128 1366 [ "$i" = "volatile.cpio.gz" ] && continue
pascal@128 1367 [ "$i" = "modifiers" ] && continue
pascal@24 1368 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
pascal@24 1369 done
pascal@72 1370 ln -s / rootfs
pascal@72 1371 mkdir tmp
pascal@72 1372 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
pascal@72 1373 ( cd tmp ; cpio -id 2>/dev/null )
pascal@72 1374 mv tmp/rootfs fs
pascal@145 1375 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
pascal@145 1376 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
pascal@145 1377 ( cd fs; cpio -id )
pascal@145 1378 fi
pascal@107 1379 if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
pascal@107 1380 . $INSTALLED/$PACKAGE/receipt
pascal@107 1381 repack_cleanup fs
pascal@107 1382 fi
pascal@107 1383 if [ -f $INSTALLED/$PACKAGE/md5sum ]; then
pascal@107 1384 sed 's, , fs,' < $INSTALLED/$PACKAGE/md5sum | \
pascal@107 1385 if ! md5sum -s -c; then
pascal@107 1386 echo -n "Can't repack, md5sum error."
pascal@107 1387 cd $TOP_DIR
pascal@107 1388 \rm -R $TMP_DIR
pascal@107 1389 exit 1
pascal@107 1390 fi
pascal@107 1391 fi
pascal@19 1392 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
pascal@24 1393 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
pascal@114 1394 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
pascal@74 1395 cd $TOP_DIR
pascal@18 1396 \rm -R $TMP_DIR
pascal@18 1397 echo "Package $PACKAGE repacked successfully."
pascal@114 1398 echo "Size : `du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
pascal@18 1399 echo ""
pascal@18 1400 ;;
pankso@6 1401 pack)
MikeDSmith25@135 1402 # Create SliTaz package archive using cpio and gzip.
pankso@6 1403 #
pankso@6 1404 check_for_package_on_cmdline
pankso@6 1405 cd $PACKAGE
pankso@6 1406 if [ ! -f "receipt" ]; then
pankso@6 1407 echo "Receipt is missing. Please read the documentation."
pankso@6 1408 exit 0
pankso@6 1409 else
pankso@6 1410 echo ""
pankso@6 1411 echo -e "\033[1mPacking :\033[0m $PACKAGE"
pankso@6 1412 echo "================================================================================"
MikeDSmith25@135 1413 # Create files.list with redirecting find outpout.
pankso@6 1414 echo -n "Creating the list of files..." && cd fs
pankso@6 1415 find . -type f -print > ../files.list
pankso@6 1416 find . -type l -print >> ../files.list
pankso@6 1417 cd .. && sed -i s/'^.'/''/ files.list
pankso@6 1418 status
pascal@138 1419 echo -n "Creating md5sum of files..."
pascal@138 1420 while read file; do
pascal@138 1421 [ -L "fs$file" ] && continue
pascal@138 1422 [ -f "fs$file" ] || continue
pascal@158 1423 case "$file" in
pascal@158 1424 /lib/modules/*/modules.*|*.pyc) continue;;
pascal@158 1425 esac
pascal@138 1426 md5sum "fs$file" | sed 's/ fs/ /'
pascal@138 1427 done < files.list > md5sum
pascal@138 1428 status
pascal@147 1429 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
pascal@147 1430 description.txt 2> /dev/null | awk \
pascal@147 1431 '{ sz=$1 } END { print sz }')
pankso@6 1432 # Build cpio archives.
pankso@6 1433 echo -n "Compressing the fs... "
pascal@138 1434 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz
pascal@138 1435 rm -rf fs
pascal@147 1436 status
pascal@147 1437 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list \
pascal@147 1438 md5sum description.txt 2> /dev/null | awk \
pascal@147 1439 '{ sz=$1 } END { print sz }')
pascal@147 1440 echo -n "Undating receipt sizes..."
pascal@147 1441 sed -i s/^PACKED_SIZE.*$// receipt
pascal@147 1442 sed -i s/^UNPACKED_SIZE.*$// receipt
pascal@147 1443 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@147 1444 status
pankso@6 1445 echo -n "Creating full cpio archive... "
pankso@6 1446 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
pascal@147 1447 status
pankso@6 1448 echo -n "Restoring original package tree... "
pascal@128 1449 zcat fs.cpio.gz | cpio -id
pascal@147 1450 status
pascal@128 1451 rm fs.cpio.gz && cd ..
pankso@6 1452 echo "================================================================================"
pascal@18 1453 echo "Package $PACKAGE compressed successfully."
pankso@6 1454 echo "Size : `du -sh $PACKAGE.tazpkg`"
pankso@6 1455 echo ""
pankso@6 1456 fi
pankso@6 1457 ;;
pankso@6 1458 recharge)
pankso@6 1459 # Recharge packages.list from a mirror.
pankso@6 1460 #
pankso@6 1461 check_root
pascal@187 1462 for path in $LOCALSTATE $LOCALSTATE/undigest/*; do
pascal@187 1463 [ -f $path/mirror ] || continue
pankso@6 1464 echo ""
pascal@187 1465 if [ "$path" != "$LOCALSTATE" ]; then
pascal@187 1466 echo "Recharge undigest $(basename $path):"
pascal@187 1467 fi
pascal@187 1468 cd $path
pascal@187 1469 if [ -f "packages.list" ]; then
pascal@187 1470 echo -n "Creating backup of the last packages list..."
pascal@187 1471 mv -f packages.desc packages.desc.bak 2>/dev/null
pascal@187 1472 mv -f packages.md5 packages.md5.txt 2>/dev/null
pascal@187 1473 mv -f packages.txt packages.txt.bak 2>/dev/null
pascal@187 1474 mv -f packages.list packages.list.bak 2>/dev/null
pascal@187 1475 mv -f packages.equiv packages.equiv.bak 2>/dev/null
pascal@187 1476 mv -f files.list.lzma files.list.lzma.bak 2> /dev/nul
pascal@187 1477 status
pascal@187 1478 fi
pascal@187 1479 download_from "$(cat mirror)" packages.desc
pascal@187 1480 download_from "$(cat mirror)" packages.md5
pascal@187 1481 download_from "$(cat mirror)" packages.txt
pascal@187 1482 download_from "$(cat mirror)" packages.list
pascal@187 1483 download_from "$(cat mirror)" packages.equiv
pascal@187 1484 download_from "$(cat mirror)" files.list.lzma
pascal@187 1485 if [ -f "packages.list.bak" ]; then
pascal@187 1486 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
pascal@187 1487 sed -i s/+// packages.diff
pascal@187 1488 echo ""
pascal@187 1489 echo -e "\033[1mMirrored packages diff\033[0m"
pankso@6 1490 echo "================================================================================"
pascal@187 1491 cat packages.diff
pascal@187 1492 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
pascal@187 1493 echo "================================================================================"
pascal@187 1494 echo "`cat packages.diff | wc -l` new packages on the mirror."
pascal@187 1495 echo ""
pascal@187 1496 else
pascal@187 1497 echo "`cat packages.diff | wc -l` new packages on the mirror."
pascal@187 1498 echo ""
pascal@187 1499 fi
pankso@6 1500 else
pascal@187 1501 echo -e "
pankso@6 1502 ================================================================================
pankso@6 1503 Last packages.list is ready to use. Note that next time you recharge the list,
MikeDSmith25@135 1504 a list of differencies will be displayed to show new and upgradeable packages.\n"
pascal@187 1505 fi
pascal@187 1506 done
pankso@6 1507 ;;
pankso@6 1508 upgrade)
pankso@6 1509 # Upgrade all installed packages with the new version from the mirror.
pankso@6 1510 #
pankso@6 1511 check_root
pankso@6 1512 check_for_packages_list
pankso@6 1513 cd $LOCALSTATE
pankso@10 1514 # Touch the blocked pkgs list to avoid errors and remove any old
pankso@10 1515 # upgrade list.
pankso@10 1516 touch blocked-packages.list
MikeDSmith25@134 1517 rm -f upgradeable-packages.list
pankso@6 1518 echo ""
MikeDSmith25@136 1519 echo -e "\033[1mAvailable upgrades\033[0m"
pankso@6 1520 echo "================================================================================"
pankso@52 1521 echo ""
pascal@66 1522 # Some packages must be installed first
pascal@121 1523 FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts "
pankso@6 1524 for pkg in $INSTALLED/*
pascal@122 1525 do
pascal@122 1526 [ -f $pkg/receipt ] || continue
pascal@114 1527 EXTRAVERSION=""
pankso@6 1528 . $pkg/receipt
MikeDSmith25@135 1529 # Display package name to show that Tazpkg is working...
pankso@52 1530 echo -en "\\033[0G "
pankso@52 1531 echo -en "\\033[0G$PACKAGE"
pankso@10 1532 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
pankso@10 1533 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 1534 blocked=$(($blocked+1))
pankso@10 1535 else
pankso@10 1536 # Check if the installed package is in the current list (other
pankso@10 1537 # mirror or local).
pascal@112 1538 NEW_PACKAGE=$(grep "^$PACKAGE-[0-9]" packages.list | head -1)
pascal@112 1539 [ -n "$NEW_PACKAGE" ] || NEW_PACKAGE=$(grep "^$PACKAGE-.[\.0-9]" packages.list | head -1)
pascal@112 1540
pascal@110 1541 if [ -n "$NEW_PACKAGE" ]; then
pankso@43 1542 # Set new pkg and version for futur comparaison
pankso@10 1543 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
pankso@43 1544 # Change '-' and 'pre' to points.
pankso@43 1545 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
pascal@114 1546 VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION
pankso@43 1547 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
pankso@43 1548 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
pascal@112 1549 NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'`
pascal@112 1550 VERSION=`echo $VERSION | sed 's/[A-Z]\.//'`
MikeDSmith25@135 1551 # Compare version. Upgrade are only available for official
pankso@10 1552 # packages, so we control de mirror and it should be ok if
pankso@10 1553 # we just check for egality.
pankso@10 1554 if [ "$VERSION" != "$NEW_VERSION" ]; then
pankso@10 1555 # Version seems different. Check for major, minor or
pankso@10 1556 # revision
pascal@105 1557 PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."`
pascal@105 1558 NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."`
pascal@105 1559 PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."`
pascal@105 1560 NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."`
pankso@10 1561 # Minor
pascal@168 1562 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then
pankso@10 1563 RELEASE=minor
pankso@10 1564 fi
pascal@168 1565 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then
pankso@10 1566 RELEASE=$WARNING
pankso@10 1567 FIXE=yes
pankso@10 1568 fi
pankso@41 1569 # Major
pascal@168 1570 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then
pankso@41 1571 RELEASE=major
pankso@41 1572 FIXE=""
pankso@41 1573 fi
pascal@168 1574 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then
pankso@41 1575 RELEASE=$WARNING
pankso@41 1576 FIXE=yes
pankso@41 1577 fi
pankso@10 1578 # Default to revision.
pankso@10 1579 if [ -z $RELEASE ]; then
pankso@10 1580 RELEASE=revision
pankso@10 1581 fi
pankso@52 1582 # Pkg name is already displayed by the check process.
pankso@10 1583 echo -en "\033[24G $VERSION"
pankso@10 1584 echo -en "\033[38G --->"
pankso@44 1585 echo -en "\033[43G $NEW_VERSION"
pankso@44 1586 echo -en "\033[58G $CATEGORY"
pankso@10 1587 echo -e "\033[72G $RELEASE"
pankso@10 1588 up=$(($up+1))
MikeDSmith25@134 1589 echo "$PACKAGE" >> upgradeable-packages.list
pascal@66 1590 case "$FIRST_CLASS_PACKAGE" in
MikeDSmith25@134 1591 *\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;;
pascal@66 1592 esac
pankso@14 1593 unset RELEASE
pankso@10 1594 fi
pankso@10 1595 packages=$(($packages+1))
pankso@6 1596 fi
pankso@10 1597 fi
pankso@6 1598 done
pankso@45 1599 if [ -z $blocked ]; then
pankso@44 1600 blocked=0
pankso@44 1601 fi
pankso@52 1602 # Clean last checked package and display summary.
pankso@6 1603 if [ ! "$up" = "" ]; then
pankso@52 1604 echo -e "\\033[0G "
pankso@6 1605 echo "================================================================================"
pankso@10 1606 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
pankso@6 1607 echo ""
pankso@6 1608 else
MikeDSmith25@136 1609 echo -e "\\033[0GSystem is up-to-date. "
pankso@52 1610 echo ""
pankso@52 1611 echo "================================================================================"
pankso@10 1612 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
pankso@6 1613 echo ""
pankso@6 1614 exit 0
pankso@6 1615 fi
pankso@10 1616 # What to do if major or minor version is smaller.
pankso@10 1617 if [ "$FIXE" == "yes" ]; then
pankso@10 1618 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
pankso@10 1619 echo "You can block packages using the command : 'tazpkg block package'"
pankso@10 1620 echo "Or upgrade package at you own risks."
pankso@10 1621 echo ""
pankso@10 1622 fi
MikeDSmith25@135 1623 # Ask for upgrade, it can be done another time.
pankso@6 1624 echo -n "Upgrade now (y/N) ? "; read anser
pankso@6 1625 if [ ! "$anser" = "y" ]; then
pankso@6 1626 echo -e "\nExiting. No package upgraded.\n"
pankso@6 1627 exit 0
pankso@6 1628 fi
MikeDSmith25@135 1629 # If anser is yes (y). Install all new versions.
MikeDSmith25@134 1630 cat upgradeable-packages.list >> upgradeable-packages.list$$
MikeDSmith25@134 1631 mv -f upgradeable-packages.list$$ upgradeable-packages.list
MikeDSmith25@134 1632 yes y | tazpkg get-install-list upgradeable-packages.list
MikeDSmith25@134 1633 #rm -f upgradeable-packages.list
pankso@6 1634 ;;
pascal@152 1635 bugs)
pascal@152 1636 # Show known bugs in package(s)
pascal@152 1637 #
pascal@152 1638 cd $INSTALLED
pascal@159 1639 shift
pascal@159 1640 LIST=$@
pascal@159 1641 [ -n "$LIST" ] || LIST=`ls`
pascal@152 1642 MSG="No known bugs."
pascal@152 1643 for PACKAGE in $LIST; do
pascal@152 1644 BUGS=""
pascal@154 1645 EXTRAVERSION=""
pascal@152 1646 . $PACKAGE/receipt
pascal@152 1647 if [ -n "$BUGS" ]; then
pascal@152 1648 MSG="
pascal@152 1649 Bug list completed"
pascal@152 1650 cat <<EOT
pascal@152 1651
pascal@162 1652 Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:
pascal@152 1653 $BUGS
pascal@152 1654 EOT
pascal@152 1655 fi
pascal@152 1656 done
pascal@152 1657 echo "$MSG"
pascal@152 1658 ;;
pascal@25 1659 check)
MikeDSmith25@135 1660 # Check installed packages set.
pascal@25 1661 #
pascal@25 1662 check_root
pascal@25 1663 cd $INSTALLED
pascal@25 1664 for PACKAGE in `ls`; do
pascal@122 1665 if [ ! -f $PACKAGE/receipt ]; then
pascal@122 1666 echo "The package $PACKAGE installation is not completed"
pascal@122 1667 continue
pascal@122 1668 fi
pascal@29 1669 DEPENDS=""
pascal@114 1670 EXTRAVERSION=""
pascal@29 1671 . $PACKAGE/receipt
pascal@29 1672 if [ -s $PACKAGE/modifiers ]; then
pascal@114 1673 echo "The package $PACKAGE $VERSION$EXTRAVERSION has been modified by :"
pascal@29 1674 for i in $(cat $PACKAGE/modifiers); do
pascal@29 1675 echo " $i"
pascal@29 1676 done
pascal@29 1677 fi
pascal@114 1678 MSG="Files lost from $PACKAGE $VERSION$EXTRAVERSION :\n"
pascal@25 1679 while read file; do
pascal@25 1680 [ -e "$file" ] && continue
pascal@25 1681 if [ -L "$file" ]; then
pascal@25 1682 MSG="$MSG target of symlink"
pascal@25 1683 fi
pascal@25 1684 echo -e "$MSG $file"
pascal@25 1685 MSG=""
pascal@25 1686 done < $PACKAGE/files.list
pascal@114 1687 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
pascal@25 1688 for i in $DEPENDS; do
pascal@25 1689 [ -d $i ] && continue
pascal@25 1690 echo -e "$MSG $i"
pascal@25 1691 MSG=""
pascal@25 1692 done
pascal@122 1693 MSG="Dependencies loop between $PACKAGE and :\n"
pascal@122 1694 ALL_DEPS=""
pascal@122 1695 check_for_deps_loop $PACKAGE $DEPENDS
pascal@25 1696 done
pascal@159 1697 echo -n "Looking for known bugs... "
pascal@152 1698 tazpkg bugs
pascal@60 1699 if [ "$PACKAGE_FILE" = "--full" ]; then
pascal@106 1700 for file in */md5sum; do
pascal@177 1701 CONFIG_FILES=""
pascal@177 1702 . $(dirname "$file")/receipt
pascal@106 1703 [ -s "$file" ] || continue
pascal@177 1704 while read md5 f; do
pascal@177 1705 [ -f $f ] || continue
pascal@177 1706 for i in $CONFIG_FILES; do
pascal@177 1707 case "$f" in
pascal@177 1708 $i|$i/*) continue 2;;
pascal@177 1709 esac
pascal@177 1710 done
pascal@177 1711 echo "$md5 $f"
pascal@177 1712 done < "$file" | md5sum -c - 2> /dev/null | \
pascal@177 1713 grep -v OK$ | sed 's/FAILED$/MD5SUM MISMATCH/'
pascal@106 1714 done
pascal@60 1715 FILES=" "
pascal@60 1716 for file in $(cat */files.list); do
pascal@60 1717 [ -d "$file" ] && continue
pascal@60 1718 case "$FILES" in *\ $file\ *) continue;; esac
pascal@60 1719 [ $(grep "^$file$" */files.list 2> /dev/null | \
pascal@60 1720 wc -l) -gt 1 ] || continue
pascal@60 1721 FILES="$FILES$file "
pascal@60 1722 echo "The following packages provide $file :"
pascal@60 1723 grep -l "^$file$" */files.list | while read f
pascal@60 1724 do
pascal@60 1725 pkg=${f%/files.list}
pascal@60 1726 echo -n " $pkg"
pascal@60 1727 if [ -f $pkg/modifiers ]; then
pascal@153 1728 echo -n " (overridden by $(echo "$(cat $pkg/modifiers)"))"
pascal@60 1729 fi
pascal@60 1730 echo ""
pascal@60 1731 done
pascal@60 1732 done
pascal@73 1733 MSG="No package has installed the following files:\n"
pascal@155 1734 find /etc /bin /sbin /lib /usr /var/www \
pascal@155 1735 -not -type d 2> /dev/null | while read file; do
pascal@73 1736 case "$file" in *\[*) continue;; esac
pascal@73 1737 grep -q "^$file$" */files.list && continue
pascal@73 1738 echo -e "$MSG $file"
pascal@73 1739 MSG=""
pascal@73 1740 done
pascal@60 1741 fi
pascal@25 1742 echo "Check completed."
pascal@25 1743 ;;
pankso@10 1744 block)
pankso@10 1745 # Add a pkg name to the list of blocked packages.
pankso@10 1746 #
pankso@10 1747 check_root
pankso@10 1748 check_for_package_on_cmdline
pankso@10 1749 echo ""
pankso@10 1750 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 1751 echo "$PACKAGE is already in the blocked packages list."
pankso@10 1752 echo ""
pankso@10 1753 exit 0
pankso@10 1754 else
pankso@10 1755 echo -n "Add $PACKAGE to : $BLOCKED..."
pankso@10 1756 echo $PACKAGE >> $BLOCKED
pankso@10 1757 status
pascal@183 1758 # Log this activity
pascal@183 1759 . $INSTALLED/$PACKAGE/receipt
pascal@183 1760 log Blocked
pankso@10 1761 fi
pankso@10 1762 echo ""
pankso@10 1763 ;;
pankso@10 1764 unblock)
MikeDSmith25@135 1765 # Remove a pkg name from the list of blocked packages.
pankso@10 1766 #
pankso@10 1767 check_root
pankso@10 1768 check_for_package_on_cmdline
pankso@10 1769 echo ""
pankso@10 1770 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 1771 echo -n "Removing $PACKAGE from : $BLOCKED..."
pankso@10 1772 sed -i s/$PACKAGE/''/ $BLOCKED
pankso@10 1773 sed -i '/^$/d' $BLOCKED
pankso@10 1774 status
pascal@183 1775 # Log this activity
pascal@183 1776 . $INSTALLED/$PACKAGE/receipt
pascal@183 1777 log Unblocked
pankso@10 1778 else
pankso@10 1779 echo "$PACKAGE is not in the blocked packages list."
pankso@10 1780 echo ""
pankso@10 1781 exit 0
pankso@10 1782 fi
pankso@10 1783 echo ""
pankso@10 1784 ;;
pankso@6 1785 get)
pankso@6 1786 # Downlowd a package with wget.
pankso@6 1787 #
pankso@6 1788 check_for_package_on_cmdline
pankso@6 1789 check_for_packages_list
pankso@6 1790 check_for_package_in_list
pankso@6 1791 echo ""
pascal@17 1792 download $PACKAGE.tazpkg
pankso@6 1793 echo ""
pankso@6 1794 ;;
pankso@6 1795 get-install)
pankso@6 1796 # Download and install a package.
pankso@6 1797 #
pankso@6 1798 check_root
pankso@6 1799 check_for_package_on_cmdline
pankso@6 1800 check_for_packages_list
pankso@6 1801 check_for_package_in_list
pascal@121 1802 DO_CHECK=""
pascal@121 1803 while [ -n "$3" ]; do
pascal@121 1804 case "$3" in
pascal@121 1805 --forced)
pascal@121 1806 DO_CHECK="no"
pascal@121 1807 ;;
pascal@121 1808 --root=*)
pascal@121 1809 ROOT="${3#--root=}"
pascal@121 1810 ;;
pascal@121 1811 --list=*)
pascal@121 1812 INSTALL_LIST="${3#--list=}"
pascal@121 1813 ;;
pascal@121 1814 *) shift 2
pascal@121 1815 echo -e "\nUnknown option $*.\n"
pascal@121 1816 exit 1
pascal@121 1817 ;;
pascal@121 1818 esac
pascal@121 1819 shift
pascal@121 1820 done
pankso@6 1821 # Check if forced install.
pascal@121 1822 if [ "$DO_CHECK" = "no" ]; then
pankso@6 1823 rm -f $CACHE_DIR/$PACKAGE.tazpkg
pankso@6 1824 else
pascal@121 1825 check_for_installed_package $ROOT
pankso@6 1826 fi
pankso@6 1827 cd $CACHE_DIR
pankso@6 1828 if [ -f "$PACKAGE.tazpkg" ]; then
pankso@6 1829 echo "$PACKAGE already in the cache : $CACHE_DIR"
MikeDSmith25@135 1830 # Check package download was finished
pascal@109 1831 tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || {
pascal@108 1832 echo "Continue $PACKAGE download"
pascal@108 1833 download $PACKAGE.tazpkg
pascal@108 1834 }
pankso@6 1835 else
pankso@6 1836 echo ""
pascal@17 1837 download $PACKAGE.tazpkg
pankso@6 1838 fi
pankso@14 1839 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
pascal@121 1840 install_package $ROOT
pankso@6 1841 ;;
pankso@6 1842 clean-cache)
pankso@6 1843 # Remove all downloaded packages.
pankso@6 1844 #
pankso@6 1845 check_root
pankso@6 1846 files=`ls -1 $CACHE_DIR | wc -l`
pankso@6 1847 echo ""
pankso@44 1848 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
pankso@6 1849 echo "================================================================================"
pankso@44 1850 echo -n "Cleaning cache directory..."
pankso@6 1851 rm -rf $CACHE_DIR/*
pankso@44 1852 status
pankso@44 1853 echo "================================================================================"
pankso@6 1854 echo "$files file(s) removed from cache."
pankso@6 1855 echo ""
pankso@6 1856 ;;
pascal@187 1857 list-undigest)
pascal@187 1858 # list undigest URLs.
pascal@187 1859 #
pascal@187 1860 if [ "$2" = "--box" ]; then
pascal@187 1861 for i in $LOCALSTATE/undigest/*/mirror; do
pascal@187 1862 [ -f $i ] || continue
pascal@187 1863 echo "$(basename $(dirname $i))|$(cat $i)"
pascal@187 1864 done
pascal@187 1865 else
pascal@187 1866 echo ""
pascal@187 1867 echo -e "\033[1mCurrent undigest(s)\033[0m"
pascal@187 1868 echo "================================================================================"
pascal@187 1869 for i in $LOCALSTATE/undigest/*/mirror; do
pascal@187 1870 if [ ! -f $i ]; then
pascal@187 1871 echo "No undigest mirror found."
pascal@187 1872 exit 1
pascal@187 1873 fi
pascal@187 1874 echo "$(basename $(dirname $i)) $(cat $i)"
pascal@187 1875 done
pascal@187 1876 echo ""
pascal@187 1877 fi
pascal@187 1878 ;;
pascal@187 1879 remove-undigest)
pascal@187 1880 # remove undigest URL.
pascal@187 1881 #
pascal@187 1882 check_root
pascal@187 1883 if [ -d $LOCALSTATE/undigest/$2 ]; then
pascal@187 1884 echo -n "Remove $2 undigest (y/N) ? "; read anser
pascal@187 1885 if [ "$anser" = "y" ]; then
pascal@187 1886 echo -n "Removing $2 undigest..."
pascal@187 1887 rm -rf $LOCALSTATE/undigest/$2
pascal@187 1888 status
pascal@187 1889 rmdir $LOCALSTATE/undigest 2> /dev/null
pascal@187 1890 fi
pascal@187 1891 else
pascal@187 1892 echo "Undigest $2 not found"
pascal@187 1893 fi
pascal@187 1894 ;;
pascal@187 1895 add-undigest|setup-undigest)
pascal@187 1896 # Add undigest URL.
pascal@187 1897 #
pascal@187 1898 check_root
pascal@187 1899 undigest=$2
pascal@187 1900 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
pascal@187 1901 if [ -z "$undigest" ]; then
pascal@187 1902 i=1
pascal@187 1903 while [ -d $LOCALSTATE/undigest/$i ]; do
pascal@187 1904 i=$(($i+1))
pascal@187 1905 done
pascal@187 1906 undigest=$i
pascal@187 1907 fi
pascal@187 1908 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
pascal@187 1909 echo "Creating new undigest $undigest."
pascal@187 1910 mkdir $LOCALSTATE/undigest/$undigest
pascal@187 1911 fi
pascal@187 1912 setup_mirror $LOCALSTATE/undigest/$undigest $3
pascal@187 1913 ;;
pankso@6 1914 setup-mirror)
pankso@6 1915 # Change mirror URL.
pankso@6 1916 #
pankso@6 1917 check_root
pascal@187 1918 setup_mirror $LOCALSTATE $2
pankso@6 1919 ;;
erjo@56 1920 reconfigure)
erjo@56 1921 # Replay post_install from receipt
erjo@56 1922 #
erjo@56 1923 check_for_package_on_cmdline
erjo@56 1924 check_root
erjo@56 1925 if [ -d "$INSTALLED/$PACKAGE" ]; then
erjo@56 1926 check_for_receipt
erjo@56 1927 # Check for post_install
erjo@56 1928 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
erjo@56 1929 . $INSTALLED/$PACKAGE/receipt
erjo@56 1930 post_install
pascal@183 1931 # Log this activity
MikeDSmith25@186 1932 log Reconfigured
erjo@56 1933 else
erjo@56 1934 echo -e "\nNothing to do for $PACKAGE."
erjo@56 1935 fi
erjo@56 1936 else
erjo@56 1937 echo -e "\npackage $PACKAGE is not installed."
erjo@56 1938 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
erjo@56 1939 fi
erjo@56 1940 ;;
pankso@55 1941 shell)
pankso@55 1942 # Tazpkg SHell
pankso@55 1943 #
pankso@55 1944 if test $(id -u) = 0 ; then
pankso@55 1945 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
pankso@55 1946 else
pankso@55 1947 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
pankso@55 1948 fi
pankso@55 1949 if [ ! "$2" = "--noheader" ]; then
pankso@55 1950 clear
pankso@55 1951 echo ""
pankso@55 1952 echo -e "\033[1mTazpkg SHell.\033[0m"
pankso@55 1953 echo "================================================================================"
MikeDSmith25@135 1954 echo "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
pankso@55 1955 echo ""
pankso@55 1956 fi
pankso@55 1957 while true
pankso@55 1958 do
pankso@55 1959 echo -en "$PROMPT"; read cmd
pankso@55 1960 case $cmd in
pankso@55 1961 q|quit)
pankso@55 1962 break ;;
pankso@55 1963 shell)
pankso@55 1964 echo "You are already running a Tazpkg SHell." ;;
pankso@55 1965 su)
pankso@55 1966 su -c 'exec tazpkg shell --noheader' && break ;;
pankso@55 1967 "")
pankso@55 1968 continue ;;
pankso@55 1969 *)
pankso@55 1970 tazpkg $cmd ;;
pankso@55 1971 esac
pankso@55 1972 done
pankso@55 1973 ;;
pankso@6 1974 usage|*)
pascal@119 1975 # Print a short help or give usage for an unknown or empty command.
pankso@6 1976 #
pankso@6 1977 usage
pankso@6 1978 ;;
pankso@6 1979 esac
pankso@6 1980
pankso@6 1981 exit 0