tazpkg annotate tazpkg @ rev 119

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