tazpkg annotate tazpkg @ rev 163

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