tazpkg annotate tazpkg @ rev 75

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