tazpkg annotate tazpkg @ rev 134

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