tazpkg annotate tazpkg @ rev 124

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