tazpkg annotate tazpkg @ rev 161

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