tazpkg annotate tazpkg @ rev 120

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