tazpkg annotate tazpkg @ rev 145

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