tazpkg annotate tazpkg @ rev 154

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