tazpkg annotate tazpkg @ rev 143

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