tazpkg annotate tazpkg @ rev 137

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