tazpkg annotate tazpkg @ rev 38

Support for dl packages.txt and SUGGESTED variable for pkg info
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 06 14:07:05 2008 +0100 (2008-02-06)
parents a32f68caef50
children 7e87cae638a2
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
pankso@6 8 # also relolv 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@27 14 #
pankso@36 15 VERSION=1.6.1
pankso@6 16
pankso@6 17 ####################
pankso@6 18 # Script variables #
pankso@6 19 ####################
pankso@6 20
pankso@6 21 # Packages categories.
pankso@10 22 CATEGORIES="base-system base-apps x-window extra devel"
pankso@6 23
pankso@6 24 # Initialize some variables to use words
pankso@6 25 # rater than numbers for functions and actions.
pankso@6 26 COMMAND=$1
pankso@34 27 if [ -f "$2" ]; then
pankso@10 28 # Set pkg basename for install, extract
pankso@10 29 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
pankso@10 30 else
pankso@10 31 # Pkg name for remove, search and all other cmds
pankso@10 32 PACKAGE=${2%.tazpkg}
pankso@10 33 fi
pankso@9 34 PACKAGE_FILE=$2
pankso@6 35 TARGET_DIR=$3
pankso@6 36 TOP_DIR=`pwd`
pankso@6 37 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
pankso@6 38
pankso@6 39 # Path to tazpkg used dir and configuration files
pankso@6 40 LOCALSTATE=/var/lib/tazpkg
pankso@6 41 INSTALLED=$LOCALSTATE/installed
pankso@6 42 CACHE_DIR=/var/cache/tazpkg
pankso@6 43 MIRROR=$LOCALSTATE/mirror
pankso@6 44 PACKAGES_LIST=$LOCALSTATE/packages.list
pankso@10 45 BLOCKED=$LOCALSTATE/blocked-packages.list
pankso@6 46
pankso@10 47 # Bold red warnig for upgrade.
pankso@10 48 WARNING="\\033[1;31mWARNING\\033[0;39m"
pankso@6 49
pankso@6 50 # Check if the directories and files used by Tazpkg
pankso@6 51 # exists. If not and user is root we creat them.
pankso@6 52 if test $(id -u) = 0 ; then
pankso@6 53 if [ ! -d "$CACHE_DIR" ]; then
pankso@6 54 mkdir -p $CACHE_DIR
pankso@6 55 fi
pankso@6 56 if [ ! -d "$INSTALLED" ]; then
pankso@6 57 mkdir -p $INSTALLED
pankso@6 58 fi
pankso@6 59 if [ ! -f "$LOCALSTATE/mirror" ]; then
pankso@6 60 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
pankso@6 61 fi
pankso@6 62 fi
pankso@6 63
pankso@6 64 ####################
pankso@6 65 # Script functions #
pankso@6 66 ####################
pankso@6 67
pankso@6 68 # Print the usage.
pankso@6 69 usage ()
pankso@6 70 {
pankso@12 71 echo -e "SliTaz packages manager - Version: $VERSION
pankso@6 72 \033[1mUsage: \033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
pankso@6 73 \033[1mCommands: \033[0m
pankso@6 74 usage Print this short usage.
pankso@6 75 list List installed packages on the system by category or all.
pankso@37 76 xhtml-list Creat a xHTML list of installed packges.
pankso@6 77 list-mirror List all available packages on the mirror (--diff for new).
pankso@6 78 info Print informations about the package.
pankso@6 79 desc Print description of a package (if it exist).
pankso@6 80 list-files List of files installed with the package.
pankso@6 81 search Search for a package by pattern or name.
pankso@12 82 search-file Search for file(s) in all installed packages files.
pankso@6 83 install Install a local (*.tazpkg) package (--forced to force).
pankso@6 84 install-list Install all packages from a list of packages.
pankso@6 85 remove Remove the specified package and all installed files.
pankso@6 86 extract Extract a (*.tazpkg) package into a directory.
pankso@6 87 pack Pack an unpacked or prepared package tree.
pankso@6 88 recharge Recharge your packages.list from the mirror.
pascal@18 89 repack Creat a package archive from an installed package.
pankso@6 90 upgrade Upgrade all installed and listed packages on the mirror.
pankso@10 91 block|unblock Block an installed package version or unblock it for upgrade.
pankso@6 92 get Download a package into the current directory.
pankso@6 93 get-install Download and install a package from the mirror.
pascal@25 94 check Verify installed packages concistancy.
pankso@6 95 clean-cache Clean all packages downloaded in cache directory.
pankso@10 96 setup-mirror Change the mirror url configuration."
pankso@6 97 }
pankso@6 98
pankso@6 99 # Status function with color (supported by Ash).
pankso@6 100 status()
pankso@6 101 {
pankso@6 102 local CHECK=$?
pankso@6 103 echo -en "\\033[70G[ "
pankso@6 104 if [ $CHECK = 0 ]; then
pankso@6 105 echo -en "\\033[1;33mOK"
pankso@6 106 else
pankso@6 107 echo -en "\\033[1;31mFailed"
pankso@6 108 fi
pankso@6 109 echo -e "\\033[0;39m ]"
pascal@20 110 return $CHECK
pankso@6 111 }
pankso@6 112
pankso@6 113 # Check if user is root to install, or remove packages.
pankso@6 114 check_root()
pankso@6 115 {
pankso@6 116 if test $(id -u) != 0 ; then
pankso@6 117 echo -e "\nYou must be root to run `basename $0` with this option."
pankso@6 118 echo -e "Please type 'su' and root password to become super-user.\n"
pankso@6 119 exit 0
pankso@6 120 fi
pankso@6 121 }
pankso@6 122
pankso@6 123 # Check for a package name on cmdline.
pankso@6 124 check_for_package_on_cmdline()
pankso@6 125 {
pankso@6 126 if [ -z "$PACKAGE" ]; then
pankso@6 127 echo -e "\nPlease specify a package name on the command line.\n"
pankso@6 128 exit 0
pankso@6 129 fi
pankso@6 130 }
pankso@6 131
pankso@9 132 # Check if the package (*.tazpkg) exist before installing or extracting.
pankso@6 133 check_for_package_file()
pankso@6 134 {
pankso@9 135 if [ ! -f "$PACKAGE_FILE" ]; then
pankso@6 136 echo -e "
pankso@9 137 Unable to find : $PACKAGE_FILE\n"
pankso@6 138 exit 0
pankso@6 139 fi
pankso@6 140 }
pankso@6 141
pankso@6 142 # Check for the receipt of an installed package.
pankso@6 143 check_for_receipt()
pankso@6 144 {
pankso@6 145 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
pankso@6 146 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
pankso@6 147 exit 0
pankso@6 148 fi
pankso@6 149 }
pankso@6 150
pankso@6 151 # Check if a package is already installed.
pankso@6 152 check_for_installed_package()
pankso@6 153 {
pankso@6 154 if [ -d "$INSTALLED/${PACKAGE%-[0-9]*}" ]; then
pankso@6 155 echo -e "
pankso@6 156 $PACKAGE is already installed. You can use the --forced option to force
pankso@6 157 installation or remove it and reinstall.\n"
pankso@6 158 exit 0
pankso@6 159 fi
pankso@6 160 }
pankso@6 161
pankso@6 162 # Check for packages.list to download and install packages.
pankso@6 163 check_for_packages_list()
pankso@6 164 {
pankso@6 165 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@6 166 echo -e "
pankso@6 167 Unable to find the list : $LOCALSTATE/packages.list\n
pankso@6 168 You must probably run 'tazpkg recharge' as root to get the last list of
pankso@6 169 packages avalaible on the mirror.\n"
pankso@6 170 exit 0
pankso@6 171 fi
pankso@6 172 }
pankso@6 173
pankso@6 174 # Check for a package in packages.list. Used by get and get-install to grep
pankso@6 175 # package basename.
pankso@6 176 check_for_package_in_list()
pankso@6 177 {
pankso@6 178 if grep -q "^$PACKAGE-[0-9]" $LOCALSTATE/packages.list; then
pankso@6 179 PACKAGE=`grep ^$PACKAGE-[0-9] $LOCALSTATE/packages.list`
pankso@6 180 else
pankso@6 181 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
pankso@6 182 exit 0
pankso@6 183 fi
pankso@6 184 }
pankso@6 185
pascal@17 186 # Download a file trying all mirrors
pascal@17 187 download()
pascal@17 188 {
pascal@17 189 for i in $(cat $MIRROR); do
pascal@17 190 wget $i$@
pascal@17 191 done
pascal@17 192 }
pascal@17 193
pankso@6 194 # Extract a package with cpio and gzip.
pankso@6 195 extract_package()
pankso@6 196 {
pankso@6 197 echo -n "Extracting $PACKAGE..."
pankso@6 198 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
pankso@6 199 gzip -d fs.cpio.gz
pankso@6 200 echo -n "Extracting the pseudo fs... "
pankso@6 201 cpio -id < fs.cpio && rm fs.cpio
pankso@6 202 }
pankso@6 203
pankso@6 204 # This function install a package in the rootfs.
pankso@6 205 install_package()
pankso@6 206 {
pascal@20 207 ROOT=$1
pascal@20 208 if [ -n "$ROOT" ]; then
pascal@20 209 # get absolute path
pascal@20 210 ROOT=$(cd $ROOT; pwd)
pascal@20 211 fi
pankso@6 212 mkdir -p $TMP_DIR
pankso@6 213 echo ""
pankso@6 214 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
pankso@6 215 echo "================================================================================"
pankso@6 216 echo -n "Copying $PACKAGE... "
pankso@9 217 cp $PACKAGE_FILE $TMP_DIR
pankso@6 218 status
pankso@6 219 cd $TMP_DIR
pankso@6 220 extract_package
pascal@20 221 SELF_INSTALL=0
pascal@21 222 MODIFY_PACKAGES=""
pankso@6 223 # Include temporary receipt to get the right variables.
pankso@6 224 . $PWD/receipt
pascal@20 225 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
pascal@20 226 echo -n "Checking post install dependencies... "
pascal@20 227 [ -d "$INSTALLED/${PACKAGE%-[0-9]*}" ]
pascal@20 228 if ! status; then
pascal@20 229 echo "Please run 'tazpkg install $PACKAGE_FILE' and retry."
pascal@20 230 cd .. && rm -rf $TMP_DIR
pascal@20 231 exit 1
pascal@20 232 fi
pascal@20 233 fi
pascal@21 234 # Remember modified packages
pascal@21 235 for i in $MODIFY_PACKAGES; do
pascal@21 236 [ -d $ROOT$INSTALLED/$i ] || continue
pascal@23 237 grep -qs ^$PACKAGE$ $ROOT$INSTALLED/$i/modifiers && continue
pascal@21 238 echo "$PACKAGE" >> $ROOT$INSTALLED/$i/modifiers
pascal@21 239 done
pankso@6 240 # Make the installed package data dir to store
pankso@6 241 # the receipt and the files list.
pascal@20 242 mkdir -p $ROOT$INSTALLED/$PACKAGE
pascal@20 243 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
pascal@20 244 # Copy the description if found.
pankso@6 245 if [ -f "description.txt" ]; then
pascal@20 246 cp description.txt $ROOT$INSTALLED/$PACKAGE
pankso@6 247 fi
pankso@38 248 # Pre install commands.
pankso@38 249 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 250 pre_install $ROOT
pankso@6 251 fi
pankso@6 252 echo -n "Installing $PACKAGE... "
pascal@20 253 cp -a fs/* $ROOT/
pankso@6 254 status
pankso@6 255 # Remove the temporary random directory.
pankso@6 256 echo -n "Removing all tmp files... "
pankso@6 257 cd .. && rm -rf $TMP_DIR
pankso@6 258 status
pankso@38 259 # Post install commands.
pankso@38 260 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 261 post_install $ROOT
pankso@6 262 fi
pankso@6 263 cd $TOP_DIR
pankso@6 264 echo "================================================================================"
pankso@6 265 echo "$PACKAGE ($VERSION) is installed."
pankso@6 266 echo ""
pankso@6 267 }
pankso@6 268
pankso@6 269 # Check for missing deps listed in a receipt packages.
pankso@6 270 check_for_deps()
pankso@6 271 {
pankso@6 272 for i in $DEPENDS
pankso@6 273 do
pankso@6 274 if [ ! -d "$INSTALLED/$i" ]; then
pankso@6 275 MISSING_PACKAGE=$i
pankso@6 276 deps=$(($deps+1))
pankso@6 277 fi
pankso@6 278 done
pankso@6 279 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@6 280 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
pankso@6 281 echo "================================================================================"
pankso@6 282 for i in $DEPENDS
pankso@6 283 do
pankso@6 284 if [ ! -d "$INSTALLED/$i" ]; then
pankso@6 285 MISSING_PACKAGE=$i
pankso@6 286 echo "Missing : $MISSING_PACKAGE"
pankso@6 287 fi
pankso@6 288 done
pankso@6 289 echo "================================================================================"
pankso@6 290 echo "$deps missing package(s) to install."
pankso@6 291 fi
pankso@6 292 }
pankso@6 293
pankso@6 294 # Install all missing deps. First ask user then install all missing deps
pankso@6 295 # from local dir, cdrom, media or from the mirror. In case we want to
pankso@6 296 # install packages from local, we need a packages.list to find the version.
pankso@6 297 install_deps()
pankso@6 298 {
pankso@6 299 echo ""
pankso@10 300 echo -n "Install all missing dependencies (y/N) ? "; read anser
pankso@6 301 if [ "$anser" = "y" ]; then
pankso@6 302 for pkg in $DEPENDS
pankso@6 303 do
pankso@6 304 if [ ! -d "$INSTALLED/$pkg" ]; then
pankso@6 305 # We can install packages from a local dir by greping
pankso@6 306 # the TAZPKG_BASENAME in the local packages.list.
pankso@6 307 if [ -f "$TOP_DIR/packages.list" ]; then
pankso@6 308 echo "Checking if $pkg exist in local list... "
pankso@6 309 TAZPKG_BASENAME=`grep -e ^$pkg-[0-9] $TOP_DIR/packages.list`
pankso@6 310 if [ -f "$TAZPKG_BASENAME.tazpkg" ]; then
pankso@6 311 tazpkg install $TAZPKG_BASENAME.tazpkg
pankso@6 312 fi
pankso@6 313 # Install deps from the mirror.
pankso@6 314 else
pankso@6 315 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@6 316 tazpkg recharge
pankso@6 317 fi
pankso@6 318 tazpkg get-install $pkg
pankso@6 319 fi
pankso@6 320 fi
pankso@6 321 done
pankso@6 322 else
pankso@6 323 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
pankso@6 324 echo -e "The package is installed but will probably not work.\n"
pankso@6 325 fi
pankso@6 326 }
pankso@6 327
pankso@37 328 # xHTML packages list header.
pankso@37 329 xhtml_header()
pankso@37 330 {
pankso@37 331 cat > $XHTML_LIST << _EOT_
pankso@37 332 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
pankso@37 333 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
pankso@37 334 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
pankso@37 335 <head>
pankso@37 336 <title>Installed packages list</title>
pankso@37 337 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
pankso@37 338 <meta name="modified" content="$DATE" />
pankso@37 339 <meta name="generator" content="Tazpkg" />
pankso@37 340 <style type="text/css"><!--
pankso@37 341 body { font: 12px sans-serif, vernada, arial; margin: 0; }
pankso@37 342 #header { background: #f0ba08; color: black; height: 50px;
pankso@37 343 border-top: 1px solid black; border-bottom: 1px solid black; }
pankso@37 344 #content { margin: 0px 50px 26px 50px; }
pankso@37 345 #footer { border-top: 1px solid black; padding-top: 10px;}
pankso@37 346 h1 { margin: 14px 0px 0px 16px; }
pankso@37 347 pre { padding-left: 5px; }
pankso@37 348 hr { color: white; background: white; height: 1px; border: 0; }
pankso@37 349 --></style>
pankso@37 350 </head>
pankso@37 351 <body bgcolor="#ffffff">
pankso@37 352 <div id="header">
pankso@37 353 <h1><font color="#3e1220">Installed packages list</font></h1>
pankso@37 354 </div>
pankso@37 355 <hr />
pankso@37 356 <!-- Start content -->
pankso@37 357 <div id="content">
pankso@37 358
pankso@37 359 <p>
pankso@37 360 _packages_ packages installed - List generated on : $DATE
pankso@37 361 <p>
pankso@37 362
pankso@37 363 _EOT_
pankso@37 364 }
pankso@37 365
pankso@37 366 # xHTML content with packages infos.
pankso@37 367 xhtml_pkg_info()
pankso@37 368 {
pankso@37 369 cat >> $XHTML_LIST << _EOT_
pankso@37 370 <h3>$PACKAGE</h3>
pankso@37 371 <pre>
pankso@37 372 Version : $VERSION
pankso@37 373 Short desc : $SHORT_DESC
pankso@37 374 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
pankso@37 375 </pre>
pankso@37 376
pankso@37 377 _EOT_
pankso@37 378 }
pankso@37 379
pankso@37 380 # xHTML packages list footer.
pankso@37 381 xhtml_footer()
pankso@37 382 {
pankso@37 383 cat >> $XHTML_LIST << _EOT_
pankso@37 384 <hr />
pankso@37 385 <p id="footer">
pankso@37 386 $packages packages installed - List generated on : $DATE
pankso@37 387 </p>
pankso@37 388
pankso@37 389 <!-- End content -->
pankso@37 390 </div>
pankso@37 391 </body>
pankso@37 392 </html>
pankso@37 393 _EOT_
pankso@37 394 }
pankso@37 395
pankso@6 396 ###################
pankso@6 397 # Tazpkg commands #
pankso@6 398 ###################
pankso@6 399
pankso@6 400 case "$COMMAND" in
pankso@6 401 list)
pankso@6 402 # List all installed packages or a specific category.
pankso@6 403 #
pankso@6 404 if [ "$2" = "category" ]; then
pankso@6 405 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@6 406 exit 0
pankso@6 407 fi
pankso@6 408 # Check for an asked category.
pankso@6 409 if [ -n "$2" ]; then
pankso@6 410 ASKED_CATEGORY=$2
pankso@6 411 echo ""
pankso@6 412 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
pankso@6 413 echo "================================================================================"
pankso@6 414 for pkg in $INSTALLED/*
pankso@6 415 do
pankso@6 416 . $pkg/receipt
pankso@6 417 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@6 418 echo -n "$PACKAGE"
pankso@6 419 echo -e "\033[24G $VERSION"
pankso@6 420 packages=$(($packages+1))
pankso@6 421 fi
pankso@6 422 done
pankso@6 423 echo "================================================================================"
pankso@6 424 echo -e "$packages packages installed of category $ASKED_CATEGORY."
pankso@6 425 echo ""
pankso@6 426 else
pankso@6 427 # By default list all packages and version.
pankso@6 428 echo ""
pankso@6 429 echo -e "\033[1mList of all installed packages\033[0m"
pankso@6 430 echo "================================================================================"
pankso@6 431 for pkg in $INSTALLED/*
pankso@6 432 do
pankso@6 433 . $pkg/receipt
pankso@6 434 echo -n "$PACKAGE"
pankso@6 435 echo -en "\033[24G $VERSION"
pankso@6 436 echo -e "\033[42G $CATEGORY"
pankso@6 437 packages=$(($packages+1))
pankso@6 438 done
pankso@6 439 echo "================================================================================"
pankso@6 440 echo "$packages packages installed."
pankso@6 441 echo ""
pankso@6 442 fi
pankso@6 443 ;;
pankso@37 444 xhtml-list)
pankso@37 445 # Get infos in receipts and build list.
pankso@37 446 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
pankso@37 447 if [ -n "$2" ]; then
pankso@37 448 XHTML_LIST=$2
pankso@37 449 else
pankso@38 450 XHTML_LIST=installed-packages.html
pankso@37 451 fi
pankso@37 452 echo ""
pankso@37 453 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
pankso@37 454 echo "================================================================================"
pankso@37 455 echo -n "Generating xHTML header..."
pankso@37 456 xhtml_header
pankso@37 457 status
pankso@37 458 # Packages
pankso@37 459 echo -n "Creating packages informations..."
pankso@37 460 for pkg in $INSTALLED/*
pankso@37 461 do
pankso@37 462 . $pkg/receipt
pankso@37 463 xhtml_pkg_info
pankso@37 464 packages=$(($packages+1))
pankso@37 465 done
pankso@37 466 status
pankso@37 467 echo -n "Generating xHTML footer..."
pankso@37 468 xhtml_footer
pankso@37 469 status
pankso@37 470 # sed pkgs nb in header.
pankso@37 471 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
pankso@37 472 echo "================================================================================"
pankso@37 473 echo "$XHTML_LIST created - $packages packages."
pankso@37 474 echo ""
pankso@37 475 ;;
pankso@6 476 list-mirror)
pankso@6 477 # List all available packages on the mirror. Option --diff display
pankso@6 478 # last mirrored packages diff (see recharge).
pankso@6 479 check_for_packages_list
pankso@6 480 if [ "$2" = "--diff" ]; then
pankso@6 481 if [ -f "$LOCALSTATE/packages.diff" ]; then
pankso@6 482 echo ""
pankso@6 483 echo -e "\033[1mMirrored packages diff\033[0m"
pankso@6 484 echo "================================================================================"
pankso@6 485 cat $LOCALSTATE/packages.diff
pankso@6 486 echo "================================================================================"
pankso@6 487 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
pankso@6 488 echo "$pkgs new packages listed on the mirror."
pankso@6 489 echo ""
pankso@6 490 else
pankso@6 491 echo -e "\nUnable to list anything, no packages.diff found."
pankso@6 492 echo -e "Recharge your current list to creat a first diff.\n"
pankso@6 493 fi
pankso@6 494 else
pankso@6 495 echo ""
pankso@6 496 echo -e "\033[1mList of available packages on the mirror\033[0m"
pankso@6 497 echo "================================================================================"
pankso@6 498 cat $LOCALSTATE/packages.list
pankso@6 499 echo "================================================================================"
pankso@6 500 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
pankso@6 501 echo "$pkgs packages in the last recharged list."
pankso@6 502 echo ""
pankso@6 503 fi
pankso@6 504 ;;
pankso@6 505 list-files)
pankso@6 506 # List files installed with the package.
pankso@6 507 #
pankso@6 508 check_for_package_on_cmdline
pankso@6 509 check_for_receipt
pankso@6 510 echo ""
pankso@6 511 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
pankso@6 512 echo "================================================================================"
pankso@6 513 cat $INSTALLED/$PACKAGE/files.list | sort
pankso@6 514 echo "================================================================================"
pankso@6 515 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
pankso@6 516 echo "$files files installed with $PACKAGE."
pankso@6 517 echo ""
pankso@6 518 ;;
pankso@6 519 info)
pankso@6 520 # Informations about package.
pankso@6 521 #
pankso@6 522 check_for_package_on_cmdline
pankso@6 523 check_for_receipt
pankso@6 524 . $INSTALLED/$PACKAGE/receipt
pankso@6 525 echo ""
pankso@6 526 echo -e "\033[1mTazpkg informations\033[0m
pankso@6 527 ================================================================================
pankso@6 528 Package : $PACKAGE
pankso@6 529 Version : $VERSION
pankso@6 530 Category : $CATEGORY
pankso@6 531 Short desc : $SHORT_DESC
pankso@6 532 Maintainer : $MAINTAINER"
pankso@6 533 if [ ! "$DEPENDS" = "" ]; then
pankso@6 534 echo -e "Depends : $DEPENDS"
pankso@6 535 fi
pankso@38 536 if [ ! "$SUGGESTED" = "" ]; then
pankso@38 537 echo -e "Suggested : $SUGGESTED"
pankso@38 538 fi
pankso@38 539 if [ ! "$BUILD_DEPENDS" = "" ]; then
pankso@38 540 echo -e "Build deps : $BUILD_DEPENDS"
pankso@38 541 fi
pankso@6 542 if [ ! "$WANTED" = "" ]; then
pankso@6 543 echo -e "Wanted src : $WANTED"
pankso@6 544 fi
pankso@6 545 if [ ! "$WEB_SITE" = "" ]; then
pankso@6 546 echo -e "Web site : $WEB_SITE"
pankso@6 547 fi
pankso@6 548 echo "================================================================================"
pankso@6 549 echo ""
pankso@6 550 ;;
pankso@6 551 desc)
pankso@6 552 # Display package description.txt if available.
pankso@6 553 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
pankso@6 554 echo ""
pankso@6 555 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
pankso@6 556 echo "================================================================================"
pankso@6 557 cat $INSTALLED/$PACKAGE/description.txt
pankso@6 558 echo "================================================================================"
pankso@6 559 echo ""
pankso@6 560 else
pankso@6 561 echo -e "\nSorry, no description available for this package.\n"
pankso@6 562 fi
pankso@6 563 ;;
pankso@6 564 search)
pankso@6 565 # Search for a package by pattern or name.
pankso@6 566 #
pankso@6 567 if [ -z "$2" ]; then
pankso@6 568 echo -e "\nPlease specify a pattern or a package name to search."
pankso@6 569 echo -e "Example : 'tazpkg search paint'. \n"
pankso@6 570 exit 0
pankso@6 571 fi
pankso@6 572 echo ""
pankso@6 573 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@6 574 echo ""
pankso@6 575 echo "Installed packages"
pankso@6 576 echo "================================================================================"
pankso@6 577 list=`ls -1 $INSTALLED | grep $2`
pankso@6 578 for pkg in $list
pankso@6 579 do
pankso@6 580 . $INSTALLED/$pkg/receipt
pankso@6 581 echo -n "$PACKAGE "
pankso@6 582 echo -en "\033[24G $VERSION"
pankso@6 583 echo -e "\033[42G $CATEGORY"
pankso@6 584 packages=$(($packages+1))
pankso@6 585 done
pankso@12 586 # Set correct ending messages.
pankso@6 587 if [ "$packages" = "" ]; then
pankso@6 588 echo "0 installed packages found for : $2"
pankso@6 589 echo ""
pankso@6 590 else
pankso@6 591 echo "================================================================================"
pankso@12 592 echo "$packages installed package(s) found for : $2"
pankso@6 593 echo ""
pankso@6 594 fi
pankso@6 595 echo "Available packages"
pankso@6 596 echo "================================================================================"
pankso@6 597 if [ -f "$LOCALSTATE/packages.list" ]; then
pankso@6 598 cat $LOCALSTATE/packages.list | grep $2
pankso@12 599 packages=`cat $LOCALSTATE/packages.list | grep $2 | wc -l`
pankso@6 600 else
pankso@6 601 echo -e "
pankso@6 602 No 'packages.list' found to check for mirrored packages. For more results,
pankso@6 603 please run once 'tazpkg recharge' as root before searching.\n"
pankso@6 604 fi
pankso@12 605 if [ "$packages" = "0" ]; then
pankso@12 606 echo "0 available packages found for : $2"
pankso@12 607 echo ""
pankso@12 608 else
pankso@12 609 echo "================================================================================"
pankso@12 610 echo "$packages available package(s) found for : $2"
pankso@12 611 echo ""
pankso@12 612 fi
pankso@12 613 ;;
pankso@12 614 search-file)
pankso@12 615 # Search for a file by pattern or name in all files.list.
pankso@12 616 #
pankso@12 617 if [ -z "$2" ]; then
pankso@12 618 echo -e "\nPlease specify a pattern or a file name to search."
pankso@12 619 echo -e "Example : 'tazpkg search-file libnss'. \n"
pankso@12 620 exit 0
pankso@12 621 fi
pankso@12 622 echo ""
pankso@12 623 echo -e "\033[1mSearch result for file :\033[0m $2"
pankso@6 624 echo "================================================================================"
pankso@12 625 # Check all pkg files.list in search match with specify the package
pankso@12 626 # name and the full path to the file(s).
pankso@12 627 for pkg in $INSTALLED/*
pankso@12 628 do
pankso@12 629 if grep -q $2 $pkg/files.list; then
pankso@12 630 . $pkg/receipt
pankso@12 631 echo ""
pankso@12 632 echo -e "\033[1mPackage $PACKAGE :\033[0m"
pankso@12 633 grep $2 $pkg/files.list
pankso@12 634 files=`grep $2 $pkg/files.list | wc -l`
pankso@12 635 match=$(($match+$files))
pankso@12 636 fi
pankso@12 637 done
pankso@12 638 if [ "$match" = "" ]; then
pankso@12 639 echo "0 file found for : $2"
pankso@12 640 echo ""
pankso@12 641 else
pankso@12 642 echo ""
pankso@12 643 echo "================================================================================"
pankso@12 644 echo "$match file(s) found for : $2"
pankso@12 645 echo ""
pankso@12 646 fi
pankso@6 647 ;;
pankso@6 648 install)
pankso@6 649 # Install .tazpkg packages.
pankso@6 650 #
pankso@6 651 check_root
pankso@6 652 check_for_package_on_cmdline
pankso@6 653 check_for_package_file
pankso@6 654 # Check if forced install.
pascal@20 655 DO_CHECK="yes"
pascal@20 656 while [ -n "$3" ]; do
pascal@20 657 case "$3" in
pascal@20 658 --forced)
pascal@20 659 DO_CHECK="no"
pascal@20 660 ;;
pascal@20 661 --root=*)
pascal@20 662 install_package ${3#--root=}
pascal@20 663 exit $?
pascal@20 664 ;;
pascal@20 665 *) shift 2
pascal@20 666 echo -e "\nUnknown option $*.\n"
pascal@20 667 exit 1
pascal@20 668 ;;
pascal@20 669 esac
pascal@20 670 shift
pascal@20 671 done
pascal@20 672 if [ "$DO_CHECK" = "yes" ]; then
pankso@6 673 check_for_installed_package
pankso@6 674 fi
pankso@6 675 install_package
pankso@6 676 # Resolv package deps.
pankso@6 677 check_for_deps
pankso@6 678 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@6 679 install_deps
pankso@6 680 fi
pankso@6 681 ;;
pankso@6 682 install-list)
pankso@6 683 # Install a set of packages from a list.
pankso@6 684 #
pankso@6 685 check_root
pankso@6 686 if [ -z "$2" ]; then
pankso@6 687 echo -e "
pankso@6 688 Please change directory (cd) to the packages repository, and specify the
pankso@6 689 list of packages to install. Example : tazpkg install-list packages.list\n"
pankso@6 690 exit 0
pankso@6 691 fi
pankso@6 692 # Check if the packages list exist.
pankso@6 693 if [ ! -f "$2" ]; then
pankso@6 694 echo "Unable to find : $2"
pankso@6 695 exit 0
pankso@6 696 else
pankso@6 697 LIST=`cat $2`
pankso@6 698 fi
pankso@6 699 # Install all packages.
pankso@6 700 for pkg in $LIST
pankso@6 701 do
pankso@6 702 if [ "$3" = "--forced" ]; then
pankso@6 703 tazpkg install $pkg --forced
pankso@6 704 else
pankso@6 705 tazpkg install $pkg
pankso@6 706 fi
pankso@6 707 done
pankso@6 708 ;;
pankso@6 709 remove)
pankso@6 710 # Remove packages.
pankso@6 711 #
pankso@6 712 check_root
pankso@6 713 check_for_package_on_cmdline
pankso@6 714 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
pankso@6 715 echo -e "\n$PACKAGE is not installed.\n"
pankso@6 716 exit 0
pankso@6 717 else
pascal@30 718 ALTERED=""
pascal@30 719 THE_PACKAGE=$PACKAGE # altered by receipt
pascal@30 720 for i in $(cd $INSTALLED ; ls); do
pankso@37 721 DEPENDS=""
pascal@30 722 . $INSTALLED/$i/receipt
pascal@30 723 case " $(echo $DEPENDS) " in
pascal@30 724 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
pascal@30 725 esac
pascal@30 726 done
pascal@30 727 . $INSTALLED/$THE_PACKAGE/receipt
pankso@6 728 fi
pankso@6 729 echo ""
pascal@30 730 if [ -n "$ALTERED" ]; then
pascal@30 731 echo "The following packages depend on $PACKAGE :"
pascal@30 732 for i in $ALTERED; do
pascal@30 733 echo " $i"
pascal@30 734 done
pascal@30 735 fi
pankso@6 736 echo "Remove $PACKAGE ($VERSION) ?"
pankso@6 737 echo -n "Please confirm uninstallation (y/N) : "; read anser
pankso@6 738 if [ "$anser" = "y" ]; then
pankso@6 739 echo ""
pankso@6 740 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
pankso@6 741 echo "================================================================================"
pankso@38 742 # Pre remove commands.
pankso@38 743 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
pankso@38 744 pre_remove
pankso@38 745 fi
pankso@6 746 echo -n "Removing all files installed..."
pankso@6 747 for file in `cat $INSTALLED/$PACKAGE/files.list`
pankso@6 748 do
pankso@32 749 rm -f $file 2>/dev/null
pankso@6 750 done
pankso@6 751 status
pankso@6 752 # Remove package receipt.
pankso@6 753 echo -n "Removing package receipt..."
pankso@6 754 rm -rf $INSTALLED/$PACKAGE
pankso@6 755 status
pascal@30 756 if [ -n "$ALTERED" ]; then
pascal@30 757 echo -n "Remove packages depending on $PACKAGE"
pascal@30 758 echo -n " (y/N) ? "; read anser
pascal@30 759 if [ "$anser" = "y" ]; then
pascal@30 760 for i in $ALTERED; do
pankso@37 761 if [ -d "$INSTALLED/$i" ]; then
pankso@37 762 tazpkg remove $i
pankso@37 763 fi
pascal@30 764 done
pascal@30 765 fi
pascal@30 766 fi
pankso@6 767 else
pankso@6 768 echo ""
pankso@6 769 echo "Uninstallation of $PACKAGE cancelled."
pankso@6 770 fi
pankso@6 771 echo ""
pankso@6 772 ;;
pankso@6 773 extract)
pankso@6 774 # Extract .tazpkg cpio archive into a directory.
pankso@6 775 #
pankso@6 776 check_for_package_on_cmdline
pankso@6 777 check_for_package_file
pankso@6 778 echo ""
pankso@6 779 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
pankso@6 780 echo "================================================================================"
pankso@6 781 # If any directory destination is found on the cmdline
pankso@6 782 # we creat one in the current dir using the package name.
pankso@6 783 if [ -n "$TARGET_DIR" ]; then
pankso@6 784 DESTDIR=$TARGET_DIR/$PACKAGE
pankso@6 785 else
pankso@6 786 DESTDIR=$PACKAGE
pankso@6 787 fi
pankso@6 788 mkdir -p $DESTDIR
pankso@6 789 echo -n "Copying original package..."
pankso@9 790 cp $PACKAGE_FILE $DESTDIR
pankso@6 791 status
pankso@6 792 cd $DESTDIR
pankso@6 793 extract_package
pankso@6 794 echo "================================================================================"
pankso@6 795 echo "$PACKAGE is extracted to : $DESTDIR"
pankso@6 796 echo ""
pankso@6 797 ;;
pascal@18 798 repack)
pascal@18 799 # Creat SliTaz package archive from an installed package.
pascal@18 800 #
pascal@18 801 check_for_package_on_cmdline
pascal@18 802 check_for_receipt
pascal@18 803 eval $(grep ^VERSION= $INSTALLED/$PACKAGE/receipt)
pascal@18 804 echo ""
pascal@18 805 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION.tazpkg"
pascal@18 806 echo "================================================================================"
pascal@24 807 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
pascal@24 808 echo "Can't repack $PACKAGE"
pascal@24 809 exit 1
pascal@24 810 fi
pascal@21 811 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
pascal@21 812 echo "Can't repack, $PACKAGE files have been modified by:"
pascal@21 813 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
pascal@21 814 echo " $i"
pascal@21 815 done
pascal@21 816 exit 1
pascal@21 817 fi
pascal@18 818 MISSING=""
pascal@18 819 for i in $(sed 's,^fs,,g' < $INSTALLED/$PACKAGE/files.list); do
pascal@18 820 [ -e "$i" ] && continue
pascal@18 821 [ -L "$i" ] || MISSING="$MISSING $i"
pascal@18 822 done
pascal@18 823 if [ -n "$MISSING" ]; then
pascal@18 824 echo "Can't repack, the following files are lost:"
pascal@18 825 for i in $MISSING; do
pascal@18 826 echo " $i"
pascal@18 827 done
pascal@18 828 exit 1
pascal@18 829 fi
pascal@18 830 HERE=`pwd`
pascal@24 831 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@24 832 FILES="fs.cpio.gz\n"
pascal@24 833 for i in $(ls $INSTALLED/$PACKAGE) ; do
pascal@24 834 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
pascal@24 835 done
pascal@20 836 cpio -pd fs < files.list 2> /dev/null
pascal@19 837 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
pascal@24 838 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
pascal@24 839 $HERE/$PACKAGE-$VERSION.tazpkg
pascal@18 840 cd $HERE
pascal@18 841 \rm -R $TMP_DIR
pascal@18 842 echo "Package $PACKAGE repacked successfully."
pascal@18 843 echo "Size : `du -sh $PACKAGE-$VERSION.tazpkg`"
pascal@18 844 echo ""
pascal@18 845 ;;
pankso@6 846 pack)
pankso@6 847 # Creat SliTaz package archive using cpio and gzip.
pankso@6 848 #
pankso@6 849 check_for_package_on_cmdline
pankso@6 850 cd $PACKAGE
pankso@6 851 if [ ! -f "receipt" ]; then
pankso@6 852 echo "Receipt is missing. Please read the documentation."
pankso@6 853 exit 0
pankso@6 854 else
pankso@6 855 echo ""
pankso@6 856 echo -e "\033[1mPacking :\033[0m $PACKAGE"
pankso@6 857 echo "================================================================================"
pankso@6 858 # Creat files.list with redirecting find outpout.
pankso@6 859 echo -n "Creating the list of files..." && cd fs
pankso@6 860 find . -type f -print > ../files.list
pankso@6 861 find . -type l -print >> ../files.list
pankso@6 862 cd .. && sed -i s/'^.'/''/ files.list
pankso@6 863 status
pankso@6 864 # Build cpio archives.
pankso@6 865 echo -n "Compressing the fs... "
pankso@6 866 find fs -print | cpio -o -H newc > fs.cpio
pankso@6 867 gzip fs.cpio && rm -rf fs
pankso@6 868 echo -n "Creating full cpio archive... "
pankso@6 869 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
pankso@6 870 echo -n "Restoring original package tree... "
pankso@6 871 gzip -d fs.cpio.gz && cpio -id < fs.cpio
pankso@6 872 rm fs.cpio && cd ..
pankso@6 873 echo "================================================================================"
pascal@18 874 echo "Package $PACKAGE compressed successfully."
pankso@6 875 echo "Size : `du -sh $PACKAGE.tazpkg`"
pankso@6 876 echo ""
pankso@6 877 fi
pankso@6 878 ;;
pankso@6 879 recharge)
pankso@6 880 # Recharge packages.list from a mirror.
pankso@6 881 #
pankso@6 882 check_root
pankso@6 883 cd $LOCALSTATE
pankso@6 884 echo ""
pankso@6 885 if [ -f "$LOCALSTATE/packages.list" ]; then
pankso@6 886 echo -n "Creating backup of the last packages list..."
pankso@38 887 mv -f packages.txt packages.txt.bak 2>/dev/null
pankso@6 888 mv -f packages.list packages.list.bak
pankso@6 889 status
pankso@6 890 fi
pankso@38 891 download packages.txt
pascal@17 892 download packages.list
pankso@6 893 if [ -f "$LOCALSTATE/packages.list.bak" ]; then
pankso@6 894 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
pankso@6 895 sed -i s/+// packages.diff
pankso@6 896 echo ""
pankso@6 897 echo -e "\033[1mMirrored packages diff\033[0m"
pankso@6 898 echo "================================================================================"
pankso@6 899 cat packages.diff
pankso@6 900 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
pankso@6 901 echo "================================================================================"
pankso@6 902 echo "`cat packages.diff | wc -l` new packages on the mirror."
pankso@6 903 echo ""
pankso@6 904 else
pankso@6 905 echo "`cat packages.diff | wc -l` new packages on the mirror."
pankso@6 906 echo ""
pankso@6 907 fi
pankso@6 908 else
pankso@6 909 echo -e "
pankso@6 910 ================================================================================
pankso@6 911 Last packages.list is ready to use. Note that next time you recharge the list,
pankso@6 912 a list of differencies will be displayed to show new and upgradable packages.\n"
pankso@6 913 fi
pankso@6 914 ;;
pankso@6 915 upgrade)
pankso@6 916 # Upgrade all installed packages with the new version from the mirror.
pankso@6 917 #
pankso@6 918 check_root
pankso@6 919 check_for_packages_list
pankso@6 920 cd $LOCALSTATE
pankso@10 921 # Touch the blocked pkgs list to avoid errors and remove any old
pankso@10 922 # upgrade list.
pankso@10 923 touch blocked-packages.list
pankso@6 924 rm -f upradable-packages.list
pankso@6 925 echo ""
pankso@6 926 echo -e "\033[1mAvalaible upgrade\033[0m"
pankso@6 927 echo "================================================================================"
pankso@6 928 for pkg in $INSTALLED/*
pankso@6 929 do
pankso@6 930 . $pkg/receipt
pankso@10 931 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
pankso@10 932 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 933 blocked=$(($blocked+1))
pankso@10 934 else
pankso@10 935 # Check if the installed package is in the current list (other
pankso@10 936 # mirror or local).
pankso@10 937 if grep -q "^$PACKAGE-[0-9]" packages.list; then
pankso@10 938 # Set new kg and version for futur comparaison
pankso@10 939 NEW_PACKAGE=`grep ^$PACKAGE-[0-9] packages.list`
pankso@10 940 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
pankso@10 941 # Compare version. Upgrade are only avalaible for official
pankso@10 942 # packages, so we control de mirror and it should be ok if
pankso@10 943 # we just check for egality.
pankso@10 944 if [ "$VERSION" != "$NEW_VERSION" ]; then
pankso@10 945 # Version seems different. Check for major, minor or
pankso@10 946 # revision
pankso@10 947 PKG_MAJOR=`echo $VERSION | cut -f1 -d"."`
pankso@10 948 NEW_MAJOR=`echo $NEW_VERSION | cut -f1 -d"."`
pankso@10 949 PKG_MINOR=`echo $VERSION | cut -f2 -d"."`
pankso@10 950 NEW_MINOR=`echo $NEW_VERSION | cut -f2 -d"."`
pankso@10 951 # Major
pankso@10 952 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ]; then
pankso@10 953 RELEASE=major
pankso@10 954 fi
pankso@10 955 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ]; then
pankso@10 956 RELEASE=$WARNING
pankso@10 957 FIXE=yes
pankso@10 958 fi
pankso@10 959 # Minor
pankso@10 960 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ]; then
pankso@10 961 RELEASE=minor
pankso@10 962 fi
pankso@10 963 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ]; then
pankso@10 964 RELEASE=$WARNING
pankso@10 965 FIXE=yes
pankso@10 966 fi
pankso@10 967 # Default to revision.
pankso@10 968 if [ -z $RELEASE ]; then
pankso@10 969 RELEASE=revision
pankso@10 970 fi
pankso@10 971 echo -n "$PACKAGE"
pankso@10 972 echo -en "\033[24G $VERSION"
pankso@10 973 echo -en "\033[38G --->"
pankso@10 974 echo -en "\033[48G $NEW_VERSION"
pankso@10 975 echo -en "\033[60G $CATEGORY"
pankso@10 976 echo -e "\033[72G $RELEASE"
pankso@10 977 up=$(($up+1))
pankso@10 978 echo "$PACKAGE" >> upradable-packages.list
pankso@14 979 unset RELEASE
pankso@10 980 fi
pankso@10 981 packages=$(($packages+1))
pankso@6 982 fi
pankso@10 983 fi
pankso@6 984 done
pankso@6 985 rm -f $tmpfile
pankso@6 986 if [ ! "$up" = "" ]; then
pankso@6 987 echo "================================================================================"
pankso@10 988 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
pankso@6 989 echo ""
pankso@6 990 else
pankso@10 991 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
pankso@6 992 echo ""
pankso@6 993 exit 0
pankso@6 994 fi
pankso@10 995 # What to do if major or minor version is smaller.
pankso@10 996 if [ "$FIXE" == "yes" ]; then
pankso@10 997 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
pankso@10 998 echo "You can block packages using the command : 'tazpkg block package'"
pankso@10 999 echo "Or upgrade package at you own risks."
pankso@10 1000 echo ""
pankso@10 1001 fi
pankso@6 1002 # Ask for upgrade, it can be done an other time.
pankso@6 1003 echo -n "Upgrade now (y/N) ? "; read anser
pankso@6 1004 if [ ! "$anser" = "y" ]; then
pankso@6 1005 echo -e "\nExiting. No package upgraded.\n"
pankso@6 1006 exit 0
pankso@6 1007 fi
pankso@6 1008 # If anser is yes (y). Install all new version.
pankso@6 1009 for pkg in `cat upradable-packages.list`
pankso@6 1010 do
pankso@6 1011 tazpkg get-install $pkg --forced
pankso@6 1012 done
pankso@6 1013 ;;
pascal@25 1014 check)
pascal@25 1015 # check installed packages set.
pascal@25 1016 #
pascal@25 1017 check_root
pascal@25 1018 cd $INSTALLED
pascal@25 1019 for PACKAGE in `ls`; do
pascal@29 1020 DEPENDS=""
pascal@29 1021 . $PACKAGE/receipt
pascal@29 1022 if [ -s $PACKAGE/modifiers ]; then
pascal@29 1023 echo "The package $PACKAGE $VERSION has been modified by :"
pascal@29 1024 for i in $(cat $PACKAGE/modifiers); do
pascal@29 1025 echo " $i"
pascal@29 1026 done
pascal@29 1027 fi
pascal@29 1028 MSG="Files lost from $PACKAGE $VERSION :\n"
pascal@25 1029 while read file; do
pascal@25 1030 [ -e "$file" ] && continue
pascal@25 1031 if [ -L "$file" ]; then
pascal@25 1032 MSG="$MSG target of symlink"
pascal@25 1033 fi
pascal@25 1034 echo -e "$MSG $file"
pascal@25 1035 MSG=""
pascal@25 1036 done < $PACKAGE/files.list
pankso@37 1037 MSG="Missing dependencies for $PACKAGE $VERSION :\n"
pascal@25 1038 for i in $DEPENDS; do
pascal@25 1039 [ -d $i ] && continue
pascal@25 1040 echo -e "$MSG $i"
pascal@25 1041 MSG=""
pascal@25 1042 done
pascal@25 1043 done
pascal@25 1044 echo "Check completed."
pascal@25 1045 ;;
pankso@10 1046 block)
pankso@10 1047 # Add a pkg name to the list of blocked packages.
pankso@10 1048 #
pankso@10 1049 check_root
pankso@10 1050 check_for_package_on_cmdline
pankso@10 1051 echo ""
pankso@10 1052 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 1053 echo "$PACKAGE is already in the blocked packages list."
pankso@10 1054 echo ""
pankso@10 1055 exit 0
pankso@10 1056 else
pankso@10 1057 echo -n "Add $PACKAGE to : $BLOCKED..."
pankso@10 1058 echo $PACKAGE >> $BLOCKED
pankso@10 1059 status
pankso@10 1060 fi
pankso@10 1061 echo ""
pankso@10 1062 ;;
pankso@10 1063 unblock)
pankso@10 1064 # Remove a pkg name to the list of blocked packages.
pankso@10 1065 #
pankso@10 1066 check_root
pankso@10 1067 check_for_package_on_cmdline
pankso@10 1068 echo ""
pankso@10 1069 if grep -q "^$PACKAGE" $BLOCKED; then
pankso@10 1070 echo -n "Removing $PACKAGE from : $BLOCKED..."
pankso@10 1071 sed -i s/$PACKAGE/''/ $BLOCKED
pankso@10 1072 sed -i '/^$/d' $BLOCKED
pankso@10 1073 status
pankso@10 1074 else
pankso@10 1075 echo "$PACKAGE is not in the blocked packages list."
pankso@10 1076 echo ""
pankso@10 1077 exit 0
pankso@10 1078 fi
pankso@10 1079 echo ""
pankso@10 1080 ;;
pankso@6 1081 get)
pankso@6 1082 # Downlowd a package with wget.
pankso@6 1083 #
pankso@6 1084 check_for_package_on_cmdline
pankso@6 1085 check_for_packages_list
pankso@6 1086 check_for_package_in_list
pankso@6 1087 echo ""
pascal@17 1088 download $PACKAGE.tazpkg
pankso@6 1089 echo ""
pankso@6 1090 ;;
pankso@6 1091 get-install)
pankso@6 1092 # Download and install a package.
pankso@6 1093 #
pankso@6 1094 check_root
pankso@6 1095 check_for_package_on_cmdline
pankso@6 1096 check_for_packages_list
pankso@6 1097 check_for_package_in_list
pankso@6 1098 # Check if forced install.
pankso@6 1099 if [ "$3" = "--forced" ]; then
pankso@6 1100 rm -f $CACHE_DIR/$PACKAGE.tazpkg
pankso@6 1101 else
pankso@6 1102 check_for_installed_package
pankso@6 1103 fi
pankso@6 1104 cd $CACHE_DIR
pankso@6 1105 if [ -f "$PACKAGE.tazpkg" ]; then
pankso@6 1106 echo "$PACKAGE already in the cache : $CACHE_DIR"
pankso@6 1107 else
pankso@6 1108 echo ""
pascal@17 1109 download $PACKAGE.tazpkg
pankso@6 1110 fi
pankso@14 1111 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
pankso@6 1112 install_package
pankso@6 1113 check_for_deps
pankso@6 1114 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@6 1115 install_deps
pankso@6 1116 fi
pankso@6 1117 ;;
pankso@6 1118 clean-cache)
pankso@6 1119 # Remove all downloaded packages.
pankso@6 1120 #
pankso@6 1121 check_root
pankso@6 1122 files=`ls -1 $CACHE_DIR | wc -l`
pankso@6 1123 echo ""
pankso@6 1124 echo -e "\033[1mCleaning cache directory :\033[0m $CACHE_DIR"
pankso@6 1125 echo "================================================================================"
pankso@6 1126 rm -rf $CACHE_DIR/*
pankso@6 1127 echo "$files file(s) removed from cache."
pankso@6 1128 echo ""
pankso@6 1129 ;;
pankso@6 1130 setup-mirror)
pankso@6 1131 # Change mirror URL.
pankso@6 1132 #
pankso@6 1133 check_root
pankso@6 1134 # Backup old list.
pankso@6 1135 if [ -f "$LOCALSTATE/mirror" ]; then
pankso@37 1136 cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
pankso@6 1137 fi
pankso@6 1138 echo ""
pascal@17 1139 echo -e "\033[1mCurrent mirror(s)\033[0m"
pankso@6 1140 echo "================================================================================"
pankso@6 1141 echo " `cat $MIRROR`"
pankso@6 1142 echo "
pankso@6 1143 Please enter URL of the new mirror (http or ftp). You must specify the complet
pankso@6 1144 address to the directory of the packages and packages.list file."
pankso@6 1145 echo ""
pankso@6 1146 echo -n "New mirror URL : "
pankso@6 1147 read NEW_MIRROR_URL
pankso@6 1148 if [ "$NEW_MIRROR_URL" = "" ]; then
pankso@6 1149 echo "Nothing as been change."
pankso@6 1150 else
pascal@17 1151 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
pankso@6 1152 echo "$NEW_MIRROR_URL" > $LOCALSTATE/mirror
pankso@6 1153 fi
pankso@6 1154 echo ""
pankso@6 1155 ;;
pankso@6 1156 usage|*)
pankso@6 1157 # Print a short help or give usage for an unknow or empty command.
pankso@6 1158 #
pankso@6 1159 usage
pankso@6 1160 ;;
pankso@6 1161 esac
pankso@6 1162
pankso@6 1163 exit 0