tazpkg annotate tazpkg @ rev 113

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