tazpkg annotate tazpkg @ rev 123

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