tazpkg annotate tazpkg @ rev 424

Change VERSION
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Feb 04 19:42:27 2011 +0100 (2011-02-04)
parents b6cf95882167
children 3a8fccb4e5f7 9e17dfffe734
rev   line source
pankso@6 1 #!/bin/sh
paul@247 2 # Tazpkg - Tiny autonomous zone packages manager.
pankso@6 3 #
pankso@6 4 # This is a lightwight packages manager for *.tazpkg files, all written in
MikeDSmith25@135 5 # SHell script. It works well with Busybox ash shell and bash. Tazpkg lets you
MikeDSmith25@135 6 # list, install, remove, download or get information about a package. You can
MikeDSmith25@135 7 # use 'tazpkg usage' to get a list of commands with short descriptions. Tazpkg
pankso@343 8 # also resolves dependencies and can upgrade packages from a mirror. I18n is
pankso@344 9 # done with gettext and eval_gettext, ex:
pankso@344 10 # gettext "displayed text"; echo
pankso@344 11 # eval_gettext "display \$VARIABLE"; echo
pankso@344 12 # echo -e "BOLD `gettext \"i18n message\"`"
pankso@6 13 #
pankso@307 14 # (C) 2007-2010 SliTaz - GNU General Public License v3.
pankso@6 15 #
pankso@27 16 # Authors : Christophe Lincoln <pankso@slitaz.org>
pankso@31 17 # Pascal Bellard <pascal.bellard@slitaz.org>
pankso@57 18 # Eric Joseph-Alexandre <erjo@slitaz.org>
pankso@279 19 # Paul Issott <paul@slitaz.org>
jozee@318 20 # Rohit Joshi <jozee@slitaz.org>
gokhlayeh@390 21 # Antoine Bodin <gokhlayeh@mailoo.org>
gokhlayeh@390 22 # Christopher Rogers <slaxemulator@gmail.com>
pankso@27 23 #
gokhlayeh@424 24 VERSION=4.2.5
pankso@6 25
pankso@6 26 ####################
pankso@6 27 # Script variables #
pankso@6 28 ####################
pankso@6 29
gokhlayeh@406 30 source /usr/lib/slitaz/libtaz
gokhlayeh@406 31 source_lib commons
pankso@307 32 . /etc/slitaz/tazpkg.conf
pankso@6 33
pankso@343 34 # Include gettext helper script.
pankso@343 35 . /usr/bin/gettext.sh
pankso@343 36
pankso@343 37 # Export package name for gettext.
pankso@343 38 TEXTDOMAIN='tazpkg'
pankso@343 39 export TEXTDOMAIN
pankso@343 40
pankso@307 41 # Initialize some variables to use words rather than numbers for functions
pankso@307 42 # and actions.
pankso@6 43 COMMAND=$1
pankso@34 44 if [ -f "$2" ]; then
pankso@10 45 # Set pkg basename for install, extract
pankso@10 46 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
pankso@10 47 else
pankso@10 48 # Pkg name for remove, search and all other cmds
pankso@10 49 PACKAGE=${2%.tazpkg}
pankso@10 50 fi
gokhlayeh@416 51 PACKAGE_FILE="$PWD/$2"
pankso@6 52 TARGET_DIR=$3
pankso@6 53 TOP_DIR=`pwd`
gokhlayeh@406 54 TMP_DIR=$tmp/$RANDOM
pankso@307 55 INSTALL_LIST=""
gokhlayeh@419 56 SAVE_CACHE_DIR="$CACHE_DIR"
pankso@6 57
pankso@6 58 # Path to tazpkg used dir and configuration files
pankso@6 59 INSTALLED=$LOCALSTATE/installed
pankso@6 60 MIRROR=$LOCALSTATE/mirror
pankso@10 61 BLOCKED=$LOCALSTATE/blocked-packages.list
pankso@117 62 DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
pankso@6 63
pankso@6 64 # Check if the directories and files used by Tazpkg
MikeDSmith25@135 65 # exist. If not and user is root we create them.
gokhlayeh@407 66 check_base_dir()
gokhlayeh@407 67 {
gokhlayeh@407 68 if test $(id -u) = 0 ; then
gokhlayeh@407 69 check_dir $1$CACHE_DIR
gokhlayeh@407 70 check_dir $1$INSTALLED
gokhlayeh@407 71 if [ ! -f "$1$LOCALSTATE/mirror" ]; then
gokhlayeh@407 72 echo "$DEFAULT_MIRROR" > $1$LOCALSTATE/mirror
gokhlayeh@407 73 fi
pankso@6 74 fi
gokhlayeh@407 75 }
gokhlayeh@407 76 check_base_dir
pankso@6 77
pankso@6 78 ####################
pankso@6 79 # Script functions #
pankso@6 80 ####################
pankso@6 81
pankso@6 82 # Print the usage.
pankso@6 83 usage ()
pankso@6 84 {
gokhlayeh@388 85 echo -e "`gettext \"SliTaz package manager - Version\"`: $VERSION
gokhlayeh@388 86 \033[1m`gettext \"Usage\"`:\033[0m `gettext \"tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]\"`
gokhlayeh@388 87 tazpkg shell\n
gokhlayeh@388 88 \033[1m`gettext \"Commands\"`: \033[0m
gokhlayeh@388 89 usage `gettext \"Print this short usage.\"`
gokhlayeh@388 90 bugs `gettext \"Show known bugs in packages.\"`
gokhlayeh@388 91 list `gettext \"List installed packages on the system by category or all.\"`
gokhlayeh@388 92 xhtml-list `gettext \"Create a xHTML list of installed packages.\"`
gokhlayeh@388 93 list-mirror `gettext \"List all available packages on the mirror (--diff for new).\"`
gokhlayeh@388 94 info `gettext \"Print information about a package.\"`
gokhlayeh@388 95 desc `gettext \"Print description of a package (if it exists).\"`
gokhlayeh@388 96 list-files `gettext \"List the files installed with a package.\"`
gokhlayeh@388 97 list-config `gettext \"List the configuration files.\"`
gokhlayeh@388 98 search `gettext \"Search for a package by pattern or name (options: -i|-l|-m).\"`
gokhlayeh@388 99 search-pkgname `gettext \"Search on mirror for package having a particular file.\"`
gokhlayeh@388 100 search-file `gettext \"Search for file(s) in all installed packages files.\"`
gokhlayeh@388 101 install `gettext \"Install a local (*.tazpkg) package (--forced to force).\"`
gokhlayeh@388 102 install-list `gettext \"Install all packages from a list of packages.\"`
gokhlayeh@388 103 remove `gettext \"Remove the specified package and all installed files.\"`
gokhlayeh@388 104 extract `gettext \"Extract a (*.tazpkg) package into a directory.\"`
gokhlayeh@388 105 pack `gettext \"Pack an unpacked or prepared package tree.\"`
gokhlayeh@388 106 recharge `gettext \"Recharge your packages.list from the mirror.\"`
gokhlayeh@388 107 repack `gettext \"Create a package archive from an installed package.\"`
gokhlayeh@388 108 repack-config `gettext \"Create a package archive with configuration files.\"`
gokhlayeh@388 109 recompress `gettext \"Rebuild a package with the better compression ratio.\"`
gokhlayeh@388 110 upgrade `gettext \"Upgrade one or all installed/listed package(s) on the mirror.\"`
gokhlayeh@388 111 upgradeable `gettext \"Build upgradeable packages list quickly.\"`
gokhlayeh@388 112 block|unblock `gettext \"Block an installed package version or unblock it for upgrade.\"`
gokhlayeh@388 113 get `gettext \"Download a package into the current directory.\"`
gokhlayeh@388 114 get-install `gettext \"Download and install a package from the mirror.\"`
gokhlayeh@388 115 get-install-list `gettext \"Download and install a list of packages from the mirror.\"`
gokhlayeh@388 116 check `gettext \"Verify consistency of installed packages.\"`
gokhlayeh@388 117 add-flavor `gettext \"Install the flavor list of packages.\"`
gokhlayeh@388 118 install-flavor `gettext \"Install the flavor list of packages and remove other ones.\"`
gokhlayeh@388 119 set-release `gettext \"Change release and update packages.\"`
gokhlayeh@388 120 clean-cache `gettext \"Clean all packages downloaded in cache directory.\"`
gokhlayeh@388 121 depends `gettext \"Display dependencies tree.\"`
gokhlayeh@388 122 rdepends `gettext \"Display reverse dependencies tree.\"`
gokhlayeh@388 123 convert `gettext \"Convert a deb/rpm/tgz/arch package to a slitaz (.tazpkg).\"`
gokhlayeh@388 124 link `gettext \"Link a package from another slitaz installation.\"`
gokhlayeh@388 125 setup-mirror `gettext \"Change the mirror url configuration.\"`
gokhlayeh@388 126 list-undigest `gettext \"List undigest mirrors.\"`
gokhlayeh@388 127 remove-undigest `gettext \"Remove an undigest mirror.\"`
gokhlayeh@388 128 add-undigest `gettext \"Add an undigest mirror.\"`
gokhlayeh@388 129 setup-undigest `gettext \"Update an undigest mirror.\"`
gokhlayeh@388 130 reconfigure `gettext \"Replay post install script from package.\"`"
pankso@6 131 }
pankso@6 132
pankso@6 133 # Check for a package name on cmdline.
pankso@6 134 check_for_package_on_cmdline()
pankso@6 135 {
pankso@6 136 if [ -z "$PACKAGE" ]; then
pankso@344 137 echo ""
pankso@344 138 gettext "Please specify a package name on the command line."; echo
pankso@344 139 echo ""
pankso@6 140 exit 0
pankso@6 141 fi
pankso@6 142 }
pankso@6 143
pankso@9 144 # Check if the package (*.tazpkg) exist before installing or extracting.
pankso@6 145 check_for_package_file()
pankso@6 146 {
pankso@9 147 if [ ! -f "$PACKAGE_FILE" ]; then
pankso@344 148 echo ""
pankso@344 149 eval_gettext "Unable to find: \$PACKAGE_FILE"; echo
pankso@344 150 echo "" && exit 0
pankso@6 151 fi
pankso@6 152 }
pankso@6 153
pankso@6 154 # Check for the receipt of an installed package.
pankso@6 155 check_for_receipt()
pankso@6 156 {
pascal@250 157 if [ ! -f "$1$INSTALLED/$PACKAGE/receipt" ]; then
pankso@344 158 FS=$1
pankso@344 159 echo ""
pankso@344 160 eval_gettext "Unable to find the receipt: \$FS\$INSTALLED/\$PACKAGE/receipt"; echo
pankso@344 161 echo "" && exit 0
pankso@6 162 fi
pankso@6 163 }
pankso@6 164
gokhlayeh@386 165 # Get repositories priority using $LOCALSTATE/priority.
gokhlayeh@386 166 # In this files, undigest are called by their name and main mirror
gokhlayeh@386 167 # by main. Sort order : priority
gokhlayeh@386 168 look_for_priority()
gokhlayeh@386 169 {
gokhlayeh@386 170 [ -s $LOCALSTATE/priority ] && priority=$(cat $LOCALSTATE/priority)
gokhlayeh@386 171 for rep in main $(ls $LOCALSTATE/undigest 2>/dev/null); do
gokhlayeh@386 172 if [ ! -s $LOCALSTATE/priority ] || \
gokhlayeh@386 173 ! grep -q ^$rep$ $LOCALSTATE/priority; then
gokhlayeh@386 174 priority=$(echo -e "$priority\n$rep")
gokhlayeh@386 175 fi
gokhlayeh@386 176 done
gokhlayeh@386 177 priority=$(echo "$priority" | sed '/^$/d' | \
gokhlayeh@386 178 while read line; do
gokhlayeh@386 179 if [ "$line" = main ]; then
gokhlayeh@386 180 echo $LOCALSTATE
gokhlayeh@386 181 else
gokhlayeh@386 182 echo $LOCALSTATE/undigest/$line
gokhlayeh@386 183 fi
gokhlayeh@386 184 done)
gokhlayeh@386 185 }
gokhlayeh@386 186
pascal@110 187 # Get package name in a directory
pascal@110 188 package_fullname_in_dir()
pascal@110 189 {
gokhlayeh@407 190 [ -f $1/receipt ] || return
pascal@114 191 EXTRAVERSION=""
gokhlayeh@407 192 . $1/receipt
pascal@110 193 echo $PACKAGE-$VERSION$EXTRAVERSION
pascal@110 194 }
pascal@110 195
pascal@110 196 # Get package name that is already installed.
pascal@110 197 get_installed_package_pathname()
pascal@110 198 {
pascal@121 199 for i in $2$INSTALLED/${1%%-*}*; do
pascal@115 200 [ -d $i ] || continue
gokhlayeh@407 201 if [ "$1" = "$(package_fullname_in_dir $i)" ]; then
pascal@110 202 echo $i
pascal@110 203 return
pascal@110 204 fi
pascal@110 205 done
pascal@110 206 }
pascal@110 207
pankso@6 208 # Check if a package is already installed.
pankso@6 209 check_for_installed_package()
pankso@6 210 {
pascal@121 211 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
pankso@344 212 echo ""
pankso@344 213 eval_gettext "\$PACKAGE package is already installed. You can
pankso@344 214 use the --forced option to force installation or remove it and reinstall."; echo
pankso@344 215 echo "" && exit 0
pankso@6 216 fi
pankso@6 217 }
pankso@6 218
pankso@6 219 # Check for packages.list to download and install packages.
pankso@6 220 check_for_packages_list()
pankso@6 221 {
pankso@6 222 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@71 223 if test $(id -u) = 0 ; then
pankso@71 224 tazpkg recharge
pankso@71 225 else
pankso@344 226 echo ""
pankso@344 227 eval_gettext "Unable to find the list: \$LOCALSTATE/packages.list"; echo
pankso@344 228 gettext \
pankso@344 229 "You must probably run 'tazpkg recharge' as root to get the latest list of
pankso@344 230 packages available on the mirror."; echo
pankso@344 231 echo "" && exit 0
pankso@71 232 fi
pankso@6 233 fi
pankso@6 234 }
pankso@6 235
gokhlayeh@419 236 get_cache_dir()
gokhlayeh@419 237 {
gokhlayeh@419 238 echo $rep > $tmp/rep
gokhlayeh@421 239 if [ "$rep" = "$LOCALSTATE" ]; then
gokhlayeh@419 240 CACHE_DIR="$SAVE_CACHE_DIR/$SLITAZ_VERSION/packages"
gokhlayeh@419 241 elif [ "${rep%-incoming}" = "$rep" ]; then
gokhlayeh@419 242 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages"
gokhlayeh@419 243 else
gokhlayeh@419 244 rep="${rep%-incoming}"
gokhlayeh@419 245 CACHE_DIR="$SAVE_CACHE_DIR/${rep##*/}/packages-incoming"
gokhlayeh@419 246 fi
gokhlayeh@419 247 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
gokhlayeh@419 248 echo $CACHE_DIR > $tmp/cachedir
gokhlayeh@419 249 }
gokhlayeh@419 250
pascal@261 251 # get an already installed package from packages.equiv
pascal@226 252 equivalent_pkg()
pascal@226 253 {
pascal@226 254 for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
pascal@226 255 $LOCALSTATE/undigest/*/packages.equiv | sed "s/^$1=//"); do
gokhlayeh@409 256 if echo $i | fgrep -q : ; then
pascal@226 257 # format 'alternative:newname'
pascal@226 258 # if alternative is installed then substitute newname
pascal@226 259 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
pascal@226 260 # substitute package dependancy
pascal@226 261 echo ${i#*:}
pascal@226 262 return
pascal@226 263 fi
pascal@226 264 else
pascal@226 265 # if alternative is installed then nothing to install
pascal@241 266 if [ -f $2$INSTALLED/$i/receipt ]; then
pascal@226 267 # substitute installed package
pascal@226 268 echo $i
pascal@226 269 return
pascal@226 270 fi
pascal@226 271 fi
pascal@226 272 done
pascal@226 273 # if not found in packages.equiv then no substitution
pascal@226 274 echo $1
pascal@226 275 }
pascal@226 276
pascal@261 277 # get a virtual package from packages.equiv
pascal@261 278 virtual_pkg()
pascal@261 279 {
gokhlayeh@386 280 for i in $(for rep in $priority; do
gokhlayeh@386 281 grep -hs "^$1=" $rep/packages.equiv
gokhlayeh@386 282 done | sed "s/^$1=//"); do
gokhlayeh@409 283 if echo $i | fgrep -q : ; then
pascal@261 284 # format 'alternative:newname'
pascal@261 285 # if alternative is installed then substitute newname
pascal@261 286 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
pascal@261 287 # substitute package dependancy
pascal@261 288 echo ${i#*:}
pascal@261 289 return
pascal@261 290 fi
pascal@261 291 else
pascal@262 292 # unconditional substitution
pascal@261 293 echo $i
pascal@261 294 return
pascal@261 295 fi
pascal@261 296 done
pascal@261 297 }
pascal@261 298
pascal@190 299 # Get package filename available on the mirror
pascal@190 300 get_package_filename()
pascal@190 301 {
pascal@190 302 local pkg
gokhlayeh@386 303 for rep in $priority; do
gokhlayeh@386 304 pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | \
gokhlayeh@386 305 sed 's/^ *//')
gokhlayeh@386 306 [ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \
gokhlayeh@387 307 $rep/packages.list | head -1)
gokhlayeh@387 308
gokhlayeh@387 309 # Allow user to call a package with his version number.
gokhlayeh@387 310 [ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1)
gokhlayeh@387 311
gokhlayeh@386 312 [ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \
gokhlayeh@386 313 $rep/packages.list | head -1)
gokhlayeh@386 314 [ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
gokhlayeh@386 315 $rep/packages.list | head -1)
gokhlayeh@419 316 [ "$pkg" ] && get_cache_dir && break
gokhlayeh@386 317 done
pascal@226 318 if [ -z "$pkg" ]; then
pascal@226 319 # Check for vitual package
pascal@226 320 local equiv
pascal@261 321 equiv=$(virtual_pkg $1)
pascal@226 322 if [ "$equiv" != "$1" ]; then
pascal@226 323 PACKAGE=$equiv
pascal@226 324 get_package_filename $PACKAGE
pascal@226 325 return
pascal@226 326 fi
pascal@226 327 fi
pascal@190 328 echo $pkg
pascal@190 329 }
pascal@190 330
pankso@6 331 # Check for a package in packages.list. Used by get and get-install to grep
pankso@6 332 # package basename.
pankso@6 333 check_for_package_in_list()
pankso@6 334 {
pascal@190 335 local filename
pascal@202 336 local check_only
pascal@202 337 check_only="$1"
gokhlayeh@416 338 filename=$(get_package_filename $PACKAGE)
gokhlayeh@419 339 if [ "$filename" ]; then
pascal@190 340 PACKAGE=$filename
gokhlayeh@419 341 CACHE_DIR=$(cat $tmp/cachedir)
gokhlayeh@419 342 rep=$(cat $tmp/rep)
gokhlayeh@419 343 rm -f $tmp/rep $tmp/cachedir
pankso@6 344 else
pankso@344 345 echo ""
pankso@344 346 eval_gettext "Unable to find: \$PACKAGE in the mirrored packages list."; echo
pankso@344 347 echo ""
pascal@202 348 [ -n "$check_only" ] && return 1
pankso@6 349 exit 0
pankso@6 350 fi
pankso@6 351 }
pankso@6 352
pascal@183 353 # Log this activity
pascal@183 354 log()
pascal@183 355 {
pascal@207 356 local extra
pascal@207 357 [ "$1" = "Installed" ] && \
gokhlayeh@409 358 extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.md5 | awk '{ print $1 }')"
pascal@183 359 [ -e $LOG ] || touch $LOG
pascal@183 360 DATE=`date +'%F %T'`
pankso@279 361 [ -w $LOG ] &&
pascal@207 362 echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
pascal@183 363 }
pascal@183 364
pascal@187 365 # Download a file from this mirror
pascal@187 366 download_from()
pascal@187 367 {
pascal@187 368 local i
pascal@187 369 local mirrors
pascal@187 370 mirrors="$1"
pascal@187 371 shift
pascal@187 372 for i in $mirrors; do
pascal@187 373 case "$i" in
pascal@187 374 http://*|ftp://*) wget -c $i$@ && break;;
gokhlayeh@391 375 *) ln -sf $i/$1 . && break;;
pascal@187 376 esac
pascal@187 377 done
pascal@187 378 }
pascal@187 379
pascal@17 380 # Download a file trying all mirrors
pascal@17 381 download()
pascal@17 382 {
pascal@187 383 local i
pascal@225 384 case "$1" in
pascal@225 385 *.tazpkg)
gokhlayeh@386 386 for i in $priority ; do
gokhlayeh@386 387 grep -q "^${1%.tazpkg}$" $i/packages.list 2>/dev/null || continue
pascal@225 388 download_from "$(cat $i/mirror)" "$@" && return
pascal@225 389 done
pascal@225 390 esac
gokhlayeh@386 391 for i in $(cat `for rep in $priority; do echo $rep/mirror; done` \
gokhlayeh@386 392 2> /dev/null); do
pascal@191 393 download_from "$i" "$@" && break
pascal@17 394 done
pascal@17 395 }
pascal@17 396
pascal@297 397 # Extract a package with cpio and gzip/lzma.
pankso@6 398 extract_package()
pankso@6 399 {
gokhlayeh@388 400 eval_gettext "Extracting \$PACKAGE... "
gokhlayeh@414 401 cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
gokhlayeh@383 402 status
pascal@297 403 if [ -f fs.cpio.lzma ]; then
gokhlayeh@355 404 gettext "Extracting the pseudo fs... "
pascal@297 405 echo -n "(lzma) "
gokhlayeh@383 406 unlzma -c fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma
gokhlayeh@383 407 status
gokhlayeh@355 408 elif [ -f fs.cpio.gz ]; then
gokhlayeh@355 409 gettext "Extracting the pseudo fs... "
gokhlayeh@383 410 zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz
gokhlayeh@383 411 status
pascal@297 412 fi
pankso@6 413 }
pankso@6 414
pascal@299 415 remove_with_path()
pascal@299 416 {
gokhlayeh@385 417 # Avoid dirname errors by checking for argument.
gokhlayeh@385 418 [ "$1" ] || return
gokhlayeh@385 419
pascal@299 420 local dir
pascal@299 421 rm -f $1 2>/dev/null
pascal@299 422 dir="$1"
pascal@299 423 while [ "$dir" != "/" ]; do
pascal@299 424 dir="$(dirname $dir)"
pascal@299 425 rmdir $dir 2> /dev/null || break
pascal@299 426 done
pascal@299 427 }
pascal@299 428
pascal@377 429 grepesc()
pascal@377 430 {
pascal@377 431 sed 's/\[/\\[/g'
pascal@377 432 }
pascal@377 433
MikeDSmith25@135 434 # This function installs a package in the rootfs.
pankso@6 435 install_package()
pankso@6 436 {
pascal@20 437 ROOT=$1
pascal@20 438 if [ -n "$ROOT" ]; then
MikeDSmith25@135 439 # Get absolute path
pascal@20 440 ROOT=$(cd $ROOT; pwd)
pascal@20 441 fi
gokhlayeh@408 442 {
MikeDSmith25@134 443 # Create package path early to avoid dependencies loop
pascal@122 444 mkdir -p $TMP_DIR
gokhlayeh@408 445 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
pascal@122 446 . $TMP_DIR/receipt
pascal@224 447 if grep -q ^pre_depends $TMP_DIR/receipt; then
pascal@224 448 pre_depends $ROOT
pascal@224 449 fi
pascal@273 450 # keep modifers and file list on upgrade
pascal@273 451 cp $ROOT$INSTALLED/$PACKAGE/modifiers \
pascal@273 452 $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
pascal@249 453 rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
pascal@122 454 # Make the installed package data dir to store
pascal@122 455 # the receipt and the files list.
pascal@122 456 mkdir -p $ROOT$INSTALLED/$PACKAGE
pascal@249 457 cp $TMP_DIR/modifiers $ROOT$INSTALLED/$PACKAGE 2> /dev/null
pascal@273 458 cp $TMP_DIR/files.list $ROOT$INSTALLED/$PACKAGE 2> /dev/null
pascal@249 459 rm -rf $TMP_DIR 2> /dev/null
pascal@195 460 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
pascal@191 461 $ROOT$LOCALSTATE/installed.md5 2> /dev/null
pascal@195 462 cd $(dirname $PACKAGE_FILE)
pascal@195 463 md5sum $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.md5
gokhlayeh@408 464 }
MikeDSmith25@134 465 # Resolve package deps.
pascal@120 466 check_for_deps $ROOT
pascal@120 467 if [ ! "$MISSING_PACKAGE" = "" ]; then
pascal@120 468 install_deps $ROOT
pascal@120 469 fi
pankso@6 470 mkdir -p $TMP_DIR
pascal@121 471 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $INSTALL_LIST-processed
pankso@6 472 echo ""
pankso@344 473 echo -e "\033[1m`gettext \"Installation of :\"`\033[0m $PACKAGE"
pankso@6 474 echo "================================================================================"
pankso@344 475 eval_gettext "Copying \$PACKAGE... "
pankso@9 476 cp $PACKAGE_FILE $TMP_DIR
pankso@6 477 status
pankso@6 478 cd $TMP_DIR
pankso@6 479 extract_package
pascal@20 480 SELF_INSTALL=0
pascal@114 481 EXTRAVERSION=""
pascal@144 482 CONFIG_FILES=""
pankso@6 483 # Include temporary receipt to get the right variables.
pankso@6 484 . $PWD/receipt
pascal@273 485 cd $ROOT$INSTALLED
pascal@20 486 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
pankso@344 487 gettext "Checking post install dependencies... "
pascal@125 488 [ -f $INSTALLED/$PACKAGE/receipt ]
pascal@20 489 if ! status; then
pankso@344 490 eval_gettext "Please run 'tazpkg install \$PACKAGE_FILE' in / and retry."; echo
pascal@273 491 rm -rf $TMP_DIR
pascal@20 492 exit 1
pascal@20 493 fi
pascal@20 494 fi
pascal@273 495 # Get files to remove if upgrading
pascal@273 496 if [ -f $PACKAGE/files.list ]; then
pascal@273 497 while read file; do
pascal@377 498 grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue
pankso@279 499 for i in $(cat $PACKAGE/modifiers 2> /dev/null ;
gokhlayeh@409 500 fgrep -sl $PACKAGE */modifiers | cut -d/ -f1 ); do
pascal@377 501 grep -qs "^$(echo $file | grepesc)$" $i/files.list && continue 2
pascal@273 502 done
pascal@273 503 echo $file
pascal@273 504 done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
pascal@273 505 fi
pascal@21 506 # Remember modified packages
pascal@299 507 { check=false
gokhlayeh@409 508 for i in $(fgrep -v [ $TMP_DIR/files.list); do
pascal@69 509 [ -e "$ROOT$i" ] || continue
pascal@69 510 [ -d "$ROOT$i" ] && continue
pascal@299 511 echo "- $i"
pascal@299 512 check=true
pascal@299 513 done ;
pascal@299 514 $check && for i in *; do
pascal@299 515 [ "$i" == "$PACKAGE" ] && continue
pascal@342 516 [ -s $i/files.list ] || continue
pascal@299 517 awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
gokhlayeh@414 518 done; } | awk '
pascal@299 519 {
pascal@299 520 if ($1 == "-" || file[$2] != "") {
pascal@299 521 file[$2] = file[$2] " " $1
pascal@299 522 if ($1 != "-") {
pascal@299 523 if (pkg[$1] == "") all = all " " $1
pascal@299 524 pkg[$1] = pkg[$1] " " $2
pascal@299 525 }
pascal@299 526 }
pascal@299 527 }
pascal@299 528 END {
pascal@299 529 for (i = split(all, p, " "); i > 0; i--)
pascal@299 530 for (j = split(pkg[p[i]], f, " "); j > 0; j--)
pascal@299 531 printf "%s %s\n",p[i],f[j];
pascal@299 532 }
pascal@299 533 ' | while read dir file; do
pascal@299 534 if grep -qs ^$dir$ $PACKAGE/modifiers; then
pascal@299 535 # Do not overload an overloaded file !
pascal@299 536 rm $TMP_DIR$file 2> /dev/null
pascal@299 537 continue
pascal@299 538 fi
pascal@299 539 grep -qs ^$PACKAGE$ $dir/modifiers && continue
pascal@299 540 if [ -s "$dir/volatile.cpio.gz" ]; then
pascal@299 541 # We can modify backed up files without notice
gokhlayeh@383 542 zcat $dir/volatile.cpio.gz | cpio -t --quiet | \
pascal@299 543 grep -q "^${file#/}$" && continue
pascal@299 544 fi
pascal@299 545 echo "$PACKAGE" >> $dir/modifiers
pascal@21 546 done
pascal@299 547
pascal@273 548 cd $TMP_DIR
pascal@20 549 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
pascal@20 550 # Copy the description if found.
pankso@6 551 if [ -f "description.txt" ]; then
pascal@20 552 cp description.txt $ROOT$INSTALLED/$PACKAGE
pankso@6 553 fi
pascal@128 554 # Copy the md5sum if found.
pascal@128 555 if [ -f "md5sum" ]; then
pascal@128 556 cp md5sum $ROOT$INSTALLED/$PACKAGE
pascal@128 557 fi
pankso@38 558 # Pre install commands.
pankso@38 559 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 560 pre_install $ROOT
pankso@6 561 fi
pascal@144 562 if [ -n "$CONFIG_FILES" ]; then
pascal@144 563 # save 'official' configuration files
pankso@344 564 eval_gettext "Saving configuration files for \$PACKAGE... "
pascal@144 565 for i in $CONFIG_FILES; do
gokhlayeh@416 566 { cd fs ; find ${i#/} -type f; cd ..; }
gokhlayeh@416 567 done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
pascal@144 568 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
pascal@144 569 # keep user configuration files
pascal@144 570 for i in $CONFIG_FILES; do
gokhlayeh@416 571 { cd fs ; find ${i#/} -type f; cd ..; }
pascal@148 572 done | while read i; do
pascal@148 573 [ -e $ROOT/$i ] || continue
pascal@148 574 cp -a $ROOT/$i fs/$i
pascal@144 575 done
pascal@144 576 status
pascal@144 577 fi
pankso@344 578 eval_gettext "Installing \$PACKAGE... "
pascal@20 579 cp -a fs/* $ROOT/
pankso@6 580 status
pascal@273 581 if [ -s files2remove.list ]; then
pankso@344 582 eval_gettext "Removing old \$PACKAGE... "
pascal@273 583 while read file; do
pascal@299 584 remove_with_path $ROOT$file
pascal@273 585 done < files2remove.list
pascal@299 586 true
pascal@273 587 status
pascal@273 588 fi
pankso@6 589 # Remove the temporary random directory.
pankso@344 590 gettext "Removing all tmp files... "
pankso@6 591 cd .. && rm -rf $TMP_DIR
pankso@6 592 status
pankso@38 593 # Post install commands.
pankso@38 594 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@20 595 post_install $ROOT
pankso@6 596 fi
gokhlayeh@356 597 # Update-desktop-database if needed.
gokhlayeh@409 598 if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
gokhlayeh@356 599 updatedesktopdb=yes
gokhlayeh@356 600 fi
slaxemulator@369 601 # Update-mime-database if needed.
gokhlayeh@409 602 if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
slaxemulator@369 603 updatemimedb=yes
slaxemulator@369 604 fi
pankso@6 605 cd $TOP_DIR
pankso@6 606 echo "================================================================================"
pankso@344 607 eval_gettext "\$PACKAGE (\$VERSION\$EXTRAVERSION) is installed."; echo
pankso@6 608 echo ""
pascal@183 609 # Log this activity
pascal@184 610 [ -n "$ROOT" ] || log Installed
pankso@6 611 }
pankso@6 612
pascal@122 613 # Check for loop in deps tree.
pascal@122 614 check_for_deps_loop()
pascal@122 615 {
pascal@122 616 local list
pascal@122 617 local pkg
pascal@122 618 local deps
pascal@122 619 pkg=$1
pascal@122 620 shift
pascal@122 621 [ -n "$1" ] || return
pascal@122 622 list=""
pascal@122 623 # Filter out already processed deps
pascal@122 624 for i in $@; do
pascal@122 625 case " $ALL_DEPS" in
pascal@122 626 *\ $i\ *);;
pascal@122 627 *) list="$list $i";;
pascal@122 628 esac
pascal@122 629 done
pascal@122 630 ALL_DEPS="$ALL_DEPS$list "
pascal@122 631 for i in $list; do
pascal@122 632 [ -f $i/receipt ] || continue
pascal@122 633 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@122 634 case " $deps " in
pascal@122 635 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
pascal@122 636 *) check_for_deps_loop $pkg $deps;;
pascal@122 637 esac
pascal@122 638 done
pascal@122 639 }
pascal@122 640
pankso@6 641 # Check for missing deps listed in a receipt packages.
pankso@6 642 check_for_deps()
pankso@6 643 {
pascal@116 644 local saved;
pascal@116 645 saved=$PACKAGE
pascal@116 646 mkdir -p $TMP_DIR
gokhlayeh@408 647 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $PACKAGE_FILE
pascal@116 648 . $TMP_DIR/receipt
pascal@116 649 PACKAGE=$saved
pascal@116 650 rm -rf $TMP_DIR
pascal@164 651 for pkgorg in $DEPENDS
pankso@6 652 do
pascal@164 653 i=$(equivalent_pkg $pkgorg $1)
pascal@120 654 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 655 MISSING_PACKAGE=$i
pankso@6 656 deps=$(($deps+1))
pascal@122 657 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
pankso@344 658 eval_gettext "WARNING Dependency loop between \$PACKAGE and \$i."; echo
pankso@6 659 fi
pankso@6 660 done
pankso@6 661 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@344 662 echo -e "\033[1m`gettext \"Tracking dependencies for :\"`\033[0m $PACKAGE"
pankso@6 663 echo "================================================================================"
pascal@164 664 for pkgorg in $DEPENDS
pankso@6 665 do
pascal@164 666 i=$(equivalent_pkg $pkgorg $1)
pascal@120 667 if [ ! -d "$1$INSTALLED/$i" ]; then
pankso@6 668 MISSING_PACKAGE=$i
pankso@344 669 eval_gettext "Missing: \$MISSING_PACKAGE"; echo
pankso@6 670 fi
pankso@6 671 done
pankso@6 672 echo "================================================================================"
pankso@344 673 eval_gettext "\$deps missing package(s) to install."; echo
pankso@6 674 fi
pankso@6 675 }
pankso@6 676
pankso@308 677 # Install all missing deps. Auto install or ask user then install all missing
pankso@308 678 # deps from local dir, cdrom, media or from the mirror. In case we want to
pankso@6 679 # install packages from local, we need a packages.list to find the version.
pankso@6 680 install_deps()
pankso@6 681 {
pascal@120 682 local root
pascal@120 683 root=""
pascal@121 684 [ -n "$1" ] && root="--root=$1"
pankso@308 685 if [ "$AUTO_INSTALL_DEPS" == "yes" ]; then
gokhlayeh@395 686 answer=`translate_querry y`
pankso@308 687 else
pankso@308 688 echo ""
gokhlayeh@388 689 gettext "Install all missing dependencies"
gokhlayeh@388 690 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 691 read answer
pankso@308 692 echo ""
pankso@308 693 fi
gokhlayeh@388 694 if [ "$answer" == "$(translate_querry y)" ]; then
pascal@164 695 for pkgorg in $DEPENDS
pankso@6 696 do
pascal@164 697 pkg=$(equivalent_pkg $pkgorg $1)
pascal@120 698 if [ ! -d "$1$INSTALLED/$pkg" ]; then
pascal@121 699 local list
pascal@121 700 list="$INSTALL_LIST"
pascal@121 701 [ -n "$list" ] || list="$TOP_DIR/packages.list"
pankso@6 702 # We can install packages from a local dir by greping
pankso@6 703 # the TAZPKG_BASENAME in the local packages.list.
pascal@153 704 found=0
pascal@121 705 if [ -f "$list" ]; then
pankso@344 706 eval_gettext "Checking if \$pkg exists in local list... "; echo
pascal@110 707 mkdir $TMP_DIR
pascal@110 708 for i in $pkg-*.tazpkg; do
pascal@124 709 [ -f $i ] || continue
gokhlayeh@408 710 { cd $TMP_DIR ; cpio --quiet -i receipt > /dev/null 2>&1; } < $i
pascal@153 711 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
pascal@121 712 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
pascal@110 713 then
pascal@153 714 found=1
pascal@121 715 tazpkg install $i $root --list=$list
pascal@110 716 break
pascal@110 717 fi
pascal@110 718 done
pascal@110 719 rm -rf $TMP_DIR
pascal@153 720 fi
pankso@6 721 # Install deps from the mirror.
pascal@153 722 if [ $found -eq 0 ]; then
pascal@121 723 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@6 724 tazpkg recharge
pankso@6 725 fi
pascal@120 726 tazpkg get-install $pkg $root
pankso@6 727 fi
pankso@6 728 fi
pankso@6 729 done
pankso@6 730 else
pankso@344 731 echo ""
pankso@344 732 eval_gettext \
pankso@344 733 "Leaving dependencies for \$PACKAGE unsolved. The package is installed but
pankso@344 734 will probably not work."; echo
pankso@344 735 echo ""
pankso@6 736 fi
pankso@6 737 }
pankso@6 738
pankso@37 739 # xHTML packages list header.
pankso@37 740 xhtml_header()
pankso@37 741 {
pankso@37 742 cat > $XHTML_LIST << _EOT_
pankso@37 743 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
pankso@37 744 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
pankso@37 745 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
pankso@37 746 <head>
pankso@37 747 <title>Installed packages list</title>
pankso@37 748 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
pankso@37 749 <meta name="modified" content="$DATE" />
pankso@37 750 <meta name="generator" content="Tazpkg" />
pankso@37 751 <style type="text/css"><!--
pankso@37 752 body { font: 12px sans-serif, vernada, arial; margin: 0; }
pankso@37 753 #header { background: #f0ba08; color: black; height: 50px;
pankso@37 754 border-top: 1px solid black; border-bottom: 1px solid black; }
pankso@37 755 #content { margin: 0px 50px 26px 50px; }
pankso@37 756 #footer { border-top: 1px solid black; padding-top: 10px;}
pankso@37 757 h1 { margin: 14px 0px 0px 16px; }
pankso@37 758 pre { padding-left: 5px; }
pankso@37 759 hr { color: white; background: white; height: 1px; border: 0; }
pankso@37 760 --></style>
pankso@37 761 </head>
pankso@37 762 <body bgcolor="#ffffff">
pankso@37 763 <div id="header">
pankso@37 764 <h1><font color="#3e1220">Installed packages list</font></h1>
pankso@37 765 </div>
pankso@37 766 <hr />
pankso@37 767 <!-- Start content -->
pankso@37 768 <div id="content">
pankso@37 769
pankso@37 770 <p>
pankso@37 771 _packages_ packages installed - List generated on : $DATE
pankso@37 772 <p>
pankso@37 773
pankso@37 774 _EOT_
pankso@37 775 }
pankso@37 776
MikeDSmith25@135 777 # xHTML content with packages info.
pankso@37 778 xhtml_pkg_info()
pankso@37 779 {
pankso@37 780 cat >> $XHTML_LIST << _EOT_
pankso@37 781 <h3>$PACKAGE</h3>
pankso@37 782 <pre>
pascal@114 783 Version : $VERSION$EXTRAVERSION
pankso@37 784 Short desc : $SHORT_DESC
pankso@37 785 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
pankso@37 786 </pre>
pankso@37 787
pankso@37 788 _EOT_
pankso@37 789 }
pankso@37 790
pankso@37 791 # xHTML packages list footer.
pankso@37 792 xhtml_footer()
pankso@37 793 {
pankso@37 794 cat >> $XHTML_LIST << _EOT_
pankso@37 795 <hr />
pankso@37 796 <p id="footer">
pankso@37 797 $packages packages installed - List generated on : $DATE
pankso@37 798 </p>
pankso@37 799
pankso@37 800 <!-- End content -->
pankso@37 801 </div>
pankso@37 802 </body>
pankso@37 803 </html>
pankso@37 804 _EOT_
pankso@37 805 }
pankso@37 806
pankso@279 807 # Search pattern in installed packages.
pankso@54 808 search_in_installed_packages()
pankso@54 809 {
pankso@344 810 gettext "Installed packages"; echo
pankso@54 811 echo "================================================================================"
erjo@62 812 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
pankso@54 813 for pkg in $list
pankso@54 814 do
pascal@114 815 EXTRAVERSION=""
pascal@122 816 [ -f $INSTALLED/$pkg/receipt ] || continue
pankso@54 817 . $INSTALLED/$pkg/receipt
pankso@54 818 echo -n "$PACKAGE "
pascal@114 819 echo -en "\033[24G $VERSION$EXTRAVERSION"
gokhlayeh@388 820 echo -e "\033[42G `translate_category $CATEGORY`."
pankso@54 821 packages=$(($packages+1))
pankso@54 822 done
pankso@54 823 # Set correct ending messages.
pankso@54 824 if [ "$packages" = "" ]; then
pankso@344 825 eval_gettext "0 installed packages found for : \$PATTERN"; echo
pankso@54 826 echo ""
pankso@54 827 else
pankso@54 828 echo "================================================================================"
pankso@344 829 eval_gettext "\$packages installed package(s) found for : \$PATTERN"; echo
pankso@54 830 echo ""
pankso@54 831 fi
pankso@54 832 }
pankso@54 833
pankso@279 834 # Search in packages.list for available pkgs.
pankso@54 835 search_in_packages_list()
pankso@54 836 {
pankso@344 837 gettext "Available packages name-version"; echo
pankso@54 838 echo "================================================================================"
pascal@187 839 packages=0
pascal@187 840 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
pascal@187 841 grep -is "$PATTERN" $i
pascal@187 842 packages=$(($packages + `grep -is "$PATTERN" $i | wc -l`))
pascal@187 843 done
pascal@187 844 if [ ! -f "$LOCALSTATE/packages.list" ]; then
pankso@344 845 echo ""
pankso@344 846 gettext \
pankso@344 847 "No 'packages.list' found to check for mirrored packages. For more results,
pankso@344 848 please run 'tazpkg recharge' once as root before searching."; echo
pankso@344 849 echo ""
pankso@54 850 fi
pankso@54 851 if [ "$packages" = "0" ]; then
pankso@344 852 eval_gettext "0 available packages found for : \$PATTERN"; echo
pankso@54 853 echo ""
pankso@54 854 else
pankso@54 855 echo "================================================================================"
pankso@344 856 eval_gettext "\$packages available package(s) found for : \$PATTERN"; echo
pankso@54 857 echo ""
pankso@54 858 fi
pankso@54 859 }
pankso@54 860
pankso@279 861 # search --mirror: Search in packages.txt for available pkgs and give more
pankso@279 862 # info than --list or default.
pankso@54 863 search_in_packages_txt()
pankso@54 864 {
pankso@344 865 gettext "Matching packages name with version and desc"; echo
pankso@54 866 echo "================================================================================"
pascal@187 867 packages=0
pascal@187 868 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
pascal@187 869 grep -is -A 2 "^$PATTERN" $i
pascal@187 870 packages=$(($packages + `grep -is "^$PATTERN" $i | wc -l`))
pascal@187 871 done
pascal@187 872 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
pankso@344 873 echo ""
pankso@344 874 gettext \
pankso@344 875 "No 'packages.txt' found to check for mirrored packages. For more results,
pankso@344 876 please run 'tazpkg recharge' once as root before searching."; echo
pankso@344 877 echo ""
pankso@54 878 fi
pankso@54 879 if [ "$packages" = "0" ]; then
pankso@344 880 eval_gettext "0 available packages found for : \$PATTERN"; echo
pankso@54 881 echo ""
pankso@54 882 else
pankso@54 883 echo "================================================================================"
pankso@344 884 eval_gettext "\$packages available package(s) found for : \$PATTERN"; echo
pankso@54 885 echo ""
pankso@54 886 fi
pankso@54 887 }
pankso@54 888
pascal@74 889 # Install package-list from a flavor
pascal@74 890 install_flavor()
pascal@74 891 {
pascal@74 892 check_root
gokhlayeh@386 893
gokhlayeh@386 894 # Get repositories priority list.
gokhlayeh@386 895 look_for_priority
gokhlayeh@386 896
pascal@74 897 FLAVOR=$1
pascal@74 898 ARG=$2
pascal@74 899 mkdir -p $TMP_DIR
pascal@74 900 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
pascal@74 901 cd $TMP_DIR
pascal@74 902 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
gokhlayeh@383 903 zcat $FLAVOR.flavor | cpio --quiet -i >/dev/null
pascal@74 904 while read file; do
pascal@74 905 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
pascal@122 906 [ -f $pkg/receipt ] || continue
pascal@114 907 EXTRAVERSION=""
pascal@74 908 . $pkg/receipt
pascal@114 909 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
pascal@74 910 done
pascal@114 911 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
pascal@74 912 cd $CACHE_DIR
pascal@74 913 download $file.tazpkg
pascal@74 914 cd $TMP_DIR
pascal@74 915 tazpkg install $CACHE_DIR/$file.tazpkg --forced
pascal@74 916 done < $FLAVOR.pkglist
pascal@75 917 [ -f $FLAVOR.nonfree ] && while read pkg; do
pascal@75 918 [ -d $INSTALLED/$pkg ] || continue
pascal@75 919 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
pascal@75 920 get-$pkg
pascal@75 921 done < $FLAVOR.nonfree
pascal@74 922 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
pascal@122 923 [ -f $INSTALLED/$pkg/receipt ] || continue
pascal@114 924 EXTRAVERSION=""
pascal@74 925 . $INSTALLED/$pkg/receipt
pascal@114 926 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
pascal@75 927 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
pascal@74 928 tazpkg remove $PACKAGE
pascal@74 929 done
pascal@74 930 else
pankso@344 931 eval_gettext "Can't find flavor \$FLAVOR. Aborting."; echo
pascal@74 932 fi
pascal@74 933 cd $TOP_DIR
pascal@74 934 rm -rf $TMP_DIR
pascal@74 935 }
pascal@74 936
pascal@187 937 # Update mirror urls
pascal@187 938 setup_mirror()
pascal@187 939 {
pascal@187 940 # Backup old list.
pascal@187 941 if [ -f "$1/mirror" ]; then
pascal@187 942 cp -f $1/mirror $1/mirror.bak
pascal@187 943 fi
pascal@187 944 echo ""
pankso@344 945 echo -e "\033[1m`gettext \"Current mirror(s)\"`\033[0m"
pascal@187 946 echo "================================================================================"
pascal@187 947 echo " `cat $1/mirror 2> /dev/null`"
pankso@344 948 gettext \
pankso@344 949 "Please enter URL of the new mirror (http, ftp or local path). You must specify
pankso@344 950 the complete address to the directory of the packages and packages.list file."; echo
pascal@187 951 echo ""
pankso@344 952 gettext "New mirror(s) URL : "
pascal@187 953 NEW_MIRROR_URL=$2
pascal@187 954 if [ -n "$NEW_MIRROR_URL" ]; then
pascal@187 955 echo $NEW_MIRROR_URL
pascal@187 956 else
pascal@187 957 read NEW_MIRROR_URL
pascal@187 958 fi
pascal@187 959 if [ "$NEW_MIRROR_URL" = "" ]; then
pankso@344 960 gettext "Nothing has been changed."; echo
pascal@187 961 else
pankso@344 962 eval_gettext "Setting mirror(s) to : $NEW_MIRROR_URL"; echo
pascal@187 963 rm -f $1/mirror
pascal@187 964 for i in $NEW_MIRROR_URL; do
pascal@187 965 echo "$i" >> $1/mirror
pankso@279 966 done
pascal@187 967 fi
pascal@187 968 echo ""
pascal@187 969 }
pascal@187 970
paul@247 971 # recursive dependencies scan
pascal@205 972 dep_scan()
pascal@205 973 {
pascal@205 974 for i in $1; do
pascal@205 975 case " $ALL_DEPS " in
pascal@205 976 *\ $i\ *) continue;;
pascal@205 977 esac
pascal@205 978 ALL_DEPS="$ALL_DEPS $i"
gokhlayeh@409 979 [ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt \
pascal@303 980 | tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
pascal@205 981 [ -f $i/receipt ] || continue
pascal@205 982 DEPENDS=""
pascal@205 983 . $i/receipt
pascal@205 984 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
pascal@205 985 done
pascal@205 986 }
pascal@205 987
paul@247 988 # recursive reverse dependencies scan
pascal@205 989 rdep_scan()
pascal@205 990 {
pascal@260 991 SEARCH=$1
pascal@260 992
pascal@260 993 for i in * ; do
pascal@260 994 DEPENDS=""
pascal@260 995 . $i/receipt
pascal@260 996 echo "$i $(echo $DEPENDS)"
pascal@260 997 done | awk -v search=$SEARCH '
pascal@260 998 function show_deps(deps, all_deps, pkg, space)
pascal@260 999 {
pascal@260 1000 if (all_deps[pkg] == 1) return
pascal@260 1001 all_deps[pkg] = 1
pascal@304 1002 if (space != "") printf "%s %s\n",space,pkg
pascal@299 1003 for (i = 1, n = split(deps[pkg], mydeps, " "); i <= n; i++) {
pascal@304 1004 show_deps(deps, all_deps, mydeps[i],"==" space)
pascal@260 1005 }
pascal@260 1006 }
pascal@260 1007
pascal@260 1008 {
pascal@260 1009 all_deps[$1] = 0
pascal@260 1010 for (i = 2; i <= NF; i++)
pascal@260 1011 deps[$i] = deps[$i] " " $1
pascal@260 1012 }
pascal@260 1013
pascal@260 1014 END {
pascal@260 1015 show_deps(deps, all_deps, search, "")
pascal@260 1016 }
pascal@304 1017 ' | while read spc pkg; do
pascal@304 1018 echo -n $spc | sed 's/=/ /g'
pascal@304 1019 echo -n $pkg
pascal@304 1020 echo -n ' ('
gokhlayeh@409 1021 fgrep -A 3 $pkg $LOCALSTATE/packages.txt | tail -1 | \
pascal@304 1022 sed 's/.*(\([^ ]*\).*/\1)/'
pascal@304 1023 done
pascal@205 1024 }
pascal@205 1025
pascal@268 1026 # Check for ELF file
pascal@268 1027 is_elf()
pascal@268 1028 {
pascal@268 1029 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
pascal@268 1030 }
pascal@268 1031
pascal@268 1032 # Print shared library dependencies
pascal@268 1033 ldd()
pascal@268 1034 {
pascal@268 1035 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
pascal@268 1036 }
pascal@268 1037
pascal@268 1038 # search dependencies for files in $TMP_DIR/$file/fs
pascal@268 1039 find_depends()
pascal@268 1040 {
pascal@268 1041 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
pascal@268 1042
slaxemulator@418 1043 [ -f $LOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null
slaxemulator@418 1044 for i in $LOCALSTATE/files.list.lzma \
slaxemulator@418 1045 $LOCALSTATE/undigest/*/files.list.lzma ; do
pascal@268 1046 [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
pascal@268 1047 done
pascal@295 1048 find $TMP_DIR/$file/fs -type f | while read chkfile ; do
pascal@295 1049 is_elf $chkfile || continue
pascal@295 1050 case "$chkfile" in
pascal@268 1051 *.o|*.ko|*.ko.gz) continue;;
pascal@268 1052 esac
pascal@295 1053 ldd $chkfile | while read lib rem; do
pascal@268 1054 case "$lib" in
pascal@268 1055 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
pascal@268 1056 continue;;
pascal@268 1057 esac
pascal@295 1058 find $TMP_DIR/$file/fs | grep -q /$lib$ && continue
gokhlayeh@409 1059 for dep in $(fgrep $lib files.list | cut -d: -f1); do
pascal@295 1060 case " $DEFAULT_DEPENDS " in
pascal@268 1061 *\ $dep\ *) continue 2;;
pascal@268 1062 esac
pascal@295 1063 grep -qs "^$dep$" $TMP_DIR/depends && continue 2
pascal@268 1064 done
pascal@268 1065 if [ -n "$dep" ]; then
pascal@295 1066 echo "$dep" >> $TMP_DIR/depends
pascal@268 1067 else
pascal@295 1068 grep -qs ^$lib$ $TMP_DIR/unresolved ||
pascal@270 1069 echo "$lib" >> $TMP_DIR/unresolved
pascal@268 1070 fi
pascal@268 1071 done
pascal@268 1072 done
pascal@295 1073 spc=""
pascal@295 1074 cat $TMP_DIR/depends | sort | uniq | while read file; do
pascal@295 1075 echo -n "$spc$file"
pascal@295 1076 spc=" "
pascal@295 1077 done
pascal@268 1078 }
pascal@268 1079
pascal@270 1080 show_unresolved_lib()
pascal@270 1081 {
pascal@270 1082 if [ -s $TMP_DIR/unresolved ]; then
gokhlayeh@388 1083 echo -e "BUGS=\"`gettext \"No dependency for\"`" >> $1
pascal@295 1084 cat $TMP_DIR/unresolved | sort | uniq | while read file; do
gokhlayeh@388 1085 eval_gettext "WARNING: unknown dependency for \$lib"; echo
pascal@295 1086 echo -n " $file" >> $1
pascal@270 1087 done
pascal@295 1088 echo "\"" >> $1
pascal@270 1089 fi
pascal@270 1090 }
pascal@270 1091
pascal@296 1092 # convert a .ipk package to .tazpkg
pascal@296 1093 convert_ipk()
pascal@296 1094 {
pascal@296 1095 mkdir -p $TMP_DIR
pascal@296 1096 tar xOzf $PACKAGE_FILE ./control.tar.gz | tar xzf - -C $TMP_DIR
pascal@296 1097 package="$(grep ^Package $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1098 version="$(grep ^Version $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1099 maintainer="$(grep ^Maintainer $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1100 target="$(grep ^Architecture $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1101 descrip="$(grep ^Description $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1102 url="http://openwrt.org/"
pascal@296 1103 case "$target" in
pascal@296 1104 i386|all)
pascal@296 1105 file=$package-$version
pascal@296 1106 mkdir -p $TMP_DIR/$file/fs
pascal@296 1107 tar xOzf $PACKAGE_FILE ./data.tar.gz | \
pascal@296 1108 tar xzf - -C $TMP_DIR/$file/fs
pascal@296 1109 cd $TMP_DIR
pascal@296 1110 cat > $file/receipt <<EOT
pascal@296 1111 # SliTaz package receipt.
pascal@296 1112 # generated by tazpkg from package $(basename $PACKAGE_FILE)
pascal@296 1113 PACKAGE="$package"
pascal@296 1114 VERSION="$version"
pascal@296 1115 CATEGORY="misc"
pascal@296 1116 SHORT_DESC="$descrip"
pascal@296 1117 WEB_SITE="$url"
pascal@296 1118 MAINTAINER="$maintainer"
pascal@296 1119 DEPENDS="$(find_depends)"
pascal@296 1120 EOT
pascal@296 1121 [ -s conffiles ] && cat >> $file/receipt <<EOT
pascal@296 1122 CONFIG_FILES="$(cat conffiles)"
pascal@296 1123 EOT
pascal@296 1124 show_unresolved_lib $file/receipt
pascal@296 1125 while read script func; do
pascal@296 1126 [ -s $script ] && cat >> $file/receipt <<EOT
pascal@296 1127
pascal@296 1128 $func()
pascal@296 1129 {
pascal@296 1130 $(cat $script)
pascal@296 1131 }
pascal@296 1132 EOT
pascal@296 1133 done <<EOT
pascal@296 1134 preinst pre_install
pascal@296 1135 postinst post_install
pascal@296 1136 prerm pre_remove
pascal@296 1137 postrm post_remove
pascal@296 1138 EOT
pascal@296 1139 awk '
pascal@296 1140 {
pascal@296 1141 if (/^ / && show) print substr($0,2);
pascal@296 1142 else show=0;
pascal@296 1143 if (/^Description/) show=1;
pascal@296 1144 }' < $TMP_DIR/control > $file/description.txt
pascal@296 1145 sed -i 's/^\.$//' $file/description.txt
pascal@296 1146 [ -s $file/description.txt ] || rm -f $file/description.txt
pascal@296 1147 tazpkg pack $file
pascal@296 1148 cd $TOP_DIR
pascal@296 1149 mv $TMP_DIR/$file.tazpkg .
pascal@296 1150 ;;
pascal@296 1151 *)
pankso@344 1152 gettext "Invalid target: $target (expected i386)"; echo
pascal@296 1153 ;;
pascal@296 1154 esac
pascal@296 1155 rm -rf $TMP_DIR
pascal@296 1156 }
pascal@296 1157
pascal@404 1158 # convert a .pkg.tar.gz/.apk package to .tazpkg
pascal@288 1159 convert_arch()
pascal@288 1160 {
pascal@288 1161 mkdir -p $TMP_DIR/fs
pascal@288 1162 tar xzf $PACKAGE_FILE -C $TMP_DIR/fs
pascal@288 1163 if [ -f $TMP_DIR/fs/.PKGINFO ]; then
pascal@288 1164 cd $TMP_DIR
pascal@288 1165 package="$(grep ^pkgname fs/.PKGINFO | sed 's/.*= //')"
pascal@288 1166 version="$(grep ^pkgver fs/.PKGINFO | sed 's/.*= //')"
pascal@288 1167 descrip="$(grep ^pkgdesc fs/.PKGINFO | sed 's/.*= //')"
pascal@288 1168 url="$(grep ^url fs/.PKGINFO | sed 's/.*= //')"
pascal@288 1169 maintainer="$(grep ^packager fs/.PKGINFO | sed 's/.*= //')"
pascal@288 1170 file=$package-$version
pascal@288 1171 mkdir $file
pascal@288 1172 mv fs $file
pascal@288 1173 cat > $file/receipt <<EOT
pascal@288 1174 # SliTaz package receipt.
pascal@288 1175 # generated by tazpkg from Archlinux package $(basename $PACKAGE_FILE)
pascal@288 1176 PACKAGE="$package"
pascal@288 1177 VERSION="$version"
pascal@288 1178 CATEGORY="misc"
pascal@288 1179 SHORT_DESC="$descrip"
pascal@288 1180 WEB_SITE="$url"
pascal@288 1181 MAINTAINER="$maintainer"
pascal@288 1182 DEPENDS="$(find_depends)"
pascal@288 1183 EOT
pascal@288 1184 show_unresolved_lib $file/receipt
pascal@288 1185 rm -f $file/fs/.[A-Z]*
pascal@288 1186 tazpkg pack $file
pascal@288 1187 mv $file.tazpkg $TOP_DIR
pascal@288 1188 else
pascal@404 1189 eval_gettext "\$PACKAGE_FILE does not look like a Archlinux/Alpine package !"; echo
pascal@288 1190 fi
pascal@288 1191 cd $TOP_DIR
pascal@288 1192 rm -rf $TMP_DIR
pascal@288 1193 }
pascal@288 1194
pascal@275 1195 # convert a .tgz package to .tazpkg
pascal@275 1196 convert_tgz()
pascal@275 1197 {
pascal@276 1198 package=$(basename $PACKAGE_FILE)
pascal@275 1199 IFS='-'
pascal@276 1200 set -- $package
pascal@275 1201 unset IFS
pascal@275 1202 package=$1
pascal@275 1203 version=$2
pascal@275 1204 file="$package-$version"
pascal@275 1205 mkdir -p $TMP_DIR/$file/fs
pascal@275 1206 tar xzf $PACKAGE_FILE -C $TMP_DIR/$file/fs
pascal@275 1207 cd $TMP_DIR
pascal@275 1208 if [ -d $file/fs/install ]; then
pascal@275 1209 descrip=$(grep ^$package $file/fs/install/slack-desc | \
pascal@275 1210 head -1 | sed 's/.*(\(.*\)).*/\1/')
pascal@275 1211 cat > $file/receipt <<EOT
pascal@275 1212 # SliTaz package receipt.
pascal@275 1213 # generated by tazpkg from slackware package $(basename $PACKAGE_FILE)
pascal@275 1214 PACKAGE="$package"
pascal@275 1215 VERSION="$version"
pascal@275 1216 CATEGORY="misc"
pascal@275 1217 SHORT_DESC="$descrip"
pascal@275 1218 WEB_SITE="http://www.slackware.com/packages/"
pankso@279 1219 MAINTAINER="nobody@slitaz.org"
pascal@275 1220 DEPENDS="$(find_depends)"
pascal@275 1221 EOT
pascal@275 1222 show_unresolved_lib $file/receipt
pascal@275 1223 [ -f $file/fs/install/doinst.sh ] && cat >> $file/receipt <<EOM
pascal@275 1224
pascal@275 1225 post_install()
pascal@275 1226 {
pascal@275 1227 chroot \$1/ sh - << EOT
pascal@275 1228 cd /
pascal@278 1229 $(cat $file/fs/install/doinst.sh | sed -e 's/\\/\\\\/g' | sed -e 's/\$/\\$/g')
pascal@275 1230 EOT
pascal@275 1231 }
pascal@275 1232 EOM
pascal@275 1233 grep ^$package $file/fs/install/slack-desc | \
pascal@275 1234 sed "s/^$package://" > $file/description.txt
pascal@296 1235 [ -s $file/description.txt ] || rm -f $file/description.txt
pascal@275 1236 rm -rf $file/fs/install
pascal@275 1237 tazpkg pack $file
pascal@275 1238 mv $file.tazpkg $TOP_DIR
pascal@275 1239 else
pankso@344 1240 eval_gettext "\$PACKAGE_FILE does not look like a Slackware package !"; echo
pascal@275 1241 fi
pascal@275 1242 cd $TOP_DIR
pascal@275 1243 rm -rf $TMP_DIR
pascal@275 1244 }
pascal@275 1245
pascal@262 1246 # convert a .deb package to .tazpkg
pascal@262 1247 convert_deb()
pascal@262 1248 {
pascal@262 1249 mkdir -p $TMP_DIR
pascal@263 1250 dpkg-deb -e $PACKAGE_FILE $TMP_DIR
pascal@262 1251 package=$(grep '^ *Package' $TMP_DIR/control)
pascal@262 1252 package=$(echo ${package##*:})
pascal@262 1253 version=$(grep '^ *Version' $TMP_DIR/control)
pascal@262 1254 version=$(echo ${version##*:})
pascal@262 1255 descrip=$(grep '^ *Description' $TMP_DIR/control)
pascal@262 1256 descrip=$(echo ${descrip##*:})
pascal@296 1257 target="$(grep ^Architecture $TMP_DIR/control | sed 's/.*: //')"
pascal@296 1258 case "$target" in
pascal@296 1259 i386|all)
pascal@296 1260 file="$package-$version"
pascal@296 1261 mkdir -p $TMP_DIR/$file/fs/
pascal@296 1262 dpkg-deb -x $PACKAGE_FILE $TMP_DIR/$file/fs
pascal@296 1263 cd $TMP_DIR
pascal@296 1264 cat > $file/receipt <<EOT
pascal@262 1265 # SliTaz package receipt.
pascal@263 1266 # generated by tazpkg from debian package $(basename $PACKAGE_FILE)
pascal@262 1267 PACKAGE="$package"
pascal@262 1268 VERSION="$version"
pascal@262 1269 CATEGORY="misc"
pascal@262 1270 SHORT_DESC="$descrip"
pascal@262 1271 WEB_SITE="http://packages.debian.org/search?keywords=$package"
pankso@279 1272 MAINTAINER="nobody@slitaz.org"
pascal@268 1273 DEPENDS="$(find_depends)"
pascal@262 1274 EOT
pascal@296 1275 [ -s conffiles ] && cat >> $file/receipt <<EOT
pascal@296 1276 CONFIG_FILES="$(cat conffiles)"
pascal@296 1277 EOT
pascal@296 1278 show_unresolved_lib $file/receipt
pascal@296 1279 awk '
pascal@268 1280 {
pascal@268 1281 if (/^ / && show) print substr($0,2);
pascal@268 1282 else show=0;
pascal@268 1283 if (/^Description/) show=1;
pascal@268 1284 }' < $TMP_DIR/control > $file/description.txt
pascal@296 1285 sed -i 's/^\.$//' $file/description.txt
pascal@296 1286 [ -s $file/description.txt ] || rm -f $file/description.txt
pascal@296 1287 tazpkg pack $file
pascal@296 1288 mv $file.tazpkg $TOP_DIR
pascal@296 1289 ;;
pascal@296 1290 *)
pankso@344 1291 gettext "Invalid target: $target (expected i386)"; echo
pascal@296 1292 ;;
pascal@296 1293 esac
pascal@262 1294 cd $TOP_DIR
pascal@262 1295 rm -rf $TMP_DIR
pascal@262 1296 }
pascal@262 1297
pascal@264 1298 # convert a .rpm package to .tazpkg
pascal@264 1299 convert_rpm()
pascal@264 1300 {
pascal@264 1301 mkdir -p $TMP_DIR
pascal@264 1302 cp $PACKAGE_FILE $TMP_DIR
pascal@264 1303 PACKAGE_FILE=$TMP_DIR/$(basename $PACKAGE_FILE)
pascal@265 1304 rpm -qip $PACKAGE_FILE | awk -v pkg=$(basename $PACKAGE_FILE) '
pascal@264 1305 BEGIN {
pascal@264 1306 goturl=0;
pascal@264 1307 printf "# Taz package receipt.\n";
pascal@264 1308 printf "# generated by tazpkg from rpm package %s\n",pkg;
pascal@264 1309 }
pascal@264 1310 {
pascal@264 1311 if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; }
pascal@264 1312 if (/^Version/) printf "VERSION=\"%s-",$3;
pascal@264 1313 if (/^Release/) printf "%s\"\n",$3;
pascal@264 1314 if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15);
pascal@264 1315 if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; }
pascal@264 1316 }
pascal@264 1317 END {
pankso@279 1318 if (goturl == 0)
pascal@264 1319 printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name;
pascal@264 1320 printf "CATEGORY=\"misc\"\n";
pascal@264 1321 printf "MAINTAINER=\"nobody@slitaz.org\"\n";
pascal@264 1322 }
pascal@264 1323 ' > $TMP_DIR/receipt
pascal@264 1324 . $TMP_DIR/receipt
pascal@264 1325 file=$PACKAGE-$VERSION
pascal@264 1326 mkdir -p $TMP_DIR/$file/fs/
pascal@264 1327 mv $TMP_DIR/receipt $TMP_DIR/$file
pascal@264 1328 rpm -qip $PACKAGE_FILE | awk '
pascal@264 1329 DEGIN { show=0 }
pankso@279 1330 {
pascal@264 1331 if (show) print;
pascal@264 1332 if (/^Description/) show=1;
pascal@264 1333 }
pascal@264 1334 ' > $TMP_DIR/$file/description.txt
pascal@264 1335 cd $TMP_DIR/$file/fs/
gokhlayeh@383 1336 rpm2cpio $PACKAGE_FILE | cpio -idm --quiet
pascal@264 1337 cd ../..
pascal@270 1338 echo "DEPENDS=\"$(find_depends)\"" >> $TMP_DIR/$file/receipt
pascal@270 1339 show_unresolved_lib $TMP_DIR/$file/receipt
pascal@264 1340 tazpkg pack $file
pascal@264 1341 mv $file.tazpkg $TOP_DIR
pascal@264 1342 cd $TOP_DIR
pascal@264 1343 rm -rf $TMP_DIR
pascal@264 1344 }
pascal@264 1345
gokhlayeh@356 1346 update_desktop_database()
gokhlayeh@356 1347 {
gokhlayeh@382 1348 if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
gokhlayeh@382 1349 $1/usr/bin/update-desktop-database $1/usr/share/applications 2>/dev/null
gokhlayeh@356 1350 fi
gokhlayeh@356 1351 }
gokhlayeh@356 1352
slaxemulator@369 1353 update_mime_database()
slaxemulator@369 1354 {
slaxemulator@394 1355 if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
slaxemulator@394 1356 $1/usr/bin/update-mime-database $1/usr/share/mime
slaxemulator@369 1357 fi
slaxemulator@369 1358 }
slaxemulator@369 1359
gokhlayeh@388 1360 translate_category()
gokhlayeh@388 1361 {
gokhlayeh@388 1362 case $1 in
gokhlayeh@388 1363 base-system) gettext "base-system" ;;
gokhlayeh@388 1364 x-window) gettext "x-window" ;;
gokhlayeh@388 1365 utilities) gettext "utilities" ;;
gokhlayeh@388 1366 network) gettext "network" ;;
gokhlayeh@388 1367 graphics) gettext "graphics" ;;
gokhlayeh@388 1368 multimedia) gettext "multimedia" ;;
gokhlayeh@388 1369 office) gettext "office" ;;
gokhlayeh@388 1370 development) gettext "development" ;;
gokhlayeh@388 1371 system-tools) gettext "system-tools" ;;
gokhlayeh@388 1372 security) gettext "security" ;;
gokhlayeh@388 1373 games) gettext "games" ;;
gokhlayeh@388 1374 misc) gettext "misc" ;;
gokhlayeh@388 1375 meta) gettext "meta" ;;
gokhlayeh@388 1376 non-free) gettext "non-free" ;;
gokhlayeh@388 1377
gokhlayeh@388 1378 # Support custom categories by keeping them untranslated.
gokhlayeh@388 1379 *) echo "$1" ;;
gokhlayeh@388 1380
gokhlayeh@388 1381 esac
gokhlayeh@388 1382 }
gokhlayeh@388 1383
gokhlayeh@388 1384 reverse_translate_category()
gokhlayeh@388 1385 {
gokhlayeh@388 1386 case $1 in
gokhlayeh@388 1387 `gettext "base-system"`) echo "base-system" ;;
gokhlayeh@388 1388 `gettext "x-window"`) echo "x-window" ;;
gokhlayeh@388 1389 `gettext "utilities"`) echo "utilities" ;;
gokhlayeh@388 1390 `gettext "network"`) echo "network" ;;
gokhlayeh@388 1391 `gettext "graphics"`) echo "graphics" ;;
gokhlayeh@388 1392 `gettext "multimedia"`) echo "multimedia" ;;
gokhlayeh@388 1393 `gettext "office"`) echo "office" ;;
gokhlayeh@388 1394 `gettext "development"`) echo "development" ;;
gokhlayeh@388 1395 `gettext "system-tools"`) echo "system-tools" ;;
gokhlayeh@388 1396 `gettext "security"`) echo "security" ;;
gokhlayeh@388 1397 `gettext "games"`) echo "games" ;;
gokhlayeh@388 1398 `gettext "misc"`) echo "misc" ;;
gokhlayeh@388 1399 `gettext "meta"`) echo "meta" ;;
gokhlayeh@388 1400 `gettext "non-free"`) echo "non-free" ;;
gokhlayeh@388 1401
gokhlayeh@388 1402 # If gategory isn't one of thoses traduced in native language,
gokhlayeh@388 1403 # keep it untranslated. This allow both native and english
gokhlayeh@388 1404 # language support. This also support custom categories.
gokhlayeh@388 1405 *) echo "$1" ;;
gokhlayeh@388 1406
gokhlayeh@388 1407 esac
gokhlayeh@388 1408 }
gokhlayeh@388 1409
gokhlayeh@388 1410 translate_querry()
gokhlayeh@388 1411 {
gokhlayeh@388 1412 case $1 in
gokhlayeh@388 1413 y) gettext "y" ;;
gokhlayeh@388 1414 Y) gettext "Y" ;;
gokhlayeh@388 1415 n) gettext "n" ;;
gokhlayeh@388 1416 N) gettext "N" ;;
gokhlayeh@388 1417
gokhlayeh@388 1418 # Support other cases but keep them untranslated.
gokhlayeh@388 1419 *) echo "$1" ;;
gokhlayeh@388 1420
gokhlayeh@388 1421 esac
gokhlayeh@388 1422 }
gokhlayeh@388 1423
gokhlayeh@388 1424
pankso@6 1425 ###################
pankso@6 1426 # Tazpkg commands #
pankso@6 1427 ###################
pankso@6 1428
pankso@6 1429 case "$COMMAND" in
pankso@6 1430 list)
pankso@6 1431 # List all installed packages or a specific category.
pankso@6 1432 #
pankso@45 1433 if [ "$2" = "blocked" ]; then
pankso@45 1434 echo ""
pankso@344 1435 echo -e "\033[1m`gettext \"Blocked packages\"`\033[0m"
pankso@45 1436 echo "================================================================================"
pascal@183 1437 if [ -s "$BLOCKED" ];then
pascal@183 1438 cat $BLOCKED
pankso@45 1439 else
gokhlayeh@388 1440 gettext "No blocked packages found."; echo
pankso@45 1441 fi
pankso@344 1442 echo "" && exit 0
pankso@45 1443 fi
pankso@45 1444 # Display the list of categories.
pankso@46 1445 if [ "$2" = "cat" -o "$2" = "categories" ]; then
pankso@45 1446 echo ""
pankso@344 1447 echo -e "\033[1m`gettext \"Packages categories\"`\033[0m"
pankso@45 1448 echo "================================================================================"
pankso@45 1449 for i in $CATEGORIES
pankso@45 1450 do
gokhlayeh@388 1451 translate_category $i; echo
pankso@45 1452 categories=$(($categories+1))
pankso@45 1453 done
pankso@45 1454 echo "================================================================================"
gokhlayeh@388 1455 eval_gettext "\$categories categories"; echo
pankso@45 1456 echo ""
pankso@6 1457 exit 0
pankso@6 1458 fi
pankso@6 1459 # Check for an asked category.
pankso@6 1460 if [ -n "$2" ]; then
gokhlayeh@388 1461 ASKED_CATEGORY_I18N=$2
gokhlayeh@388 1462 ASKED_CATEGORY=$(reverse_translate_category $2)
pankso@6 1463 echo ""
gokhlayeh@388 1464 echo -e "\033[1m`gettext \"Installed packages of category:\"`\033[0m $ASKED_CATEGORY_I18N"
pankso@6 1465 echo "================================================================================"
pankso@6 1466 for pkg in $INSTALLED/*
pankso@6 1467 do
pascal@122 1468 [ -f $pkg/receipt ] || continue
pascal@114 1469 EXTRAVERSION=""
pankso@6 1470 . $pkg/receipt
pankso@6 1471 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@6 1472 echo -n "$PACKAGE"
pascal@114 1473 echo -e "\033[24G $VERSION$EXTRAVERSION"
pankso@6 1474 packages=$(($packages+1))
pankso@6 1475 fi
pankso@6 1476 done
pankso@6 1477 echo "================================================================================"
gokhlayeh@388 1478 eval_gettext "\$packages packages installed of category \$ASKED_CATEGORY_I18N."; echo
pankso@6 1479 echo ""
pankso@6 1480 else
MikeDSmith25@135 1481 # By default list all packages and versions.
pankso@6 1482 echo ""
pankso@344 1483 echo -e "\033[1m`gettext \"List of all installed packages\"`\033[0m"
pankso@6 1484 echo "================================================================================"
pankso@6 1485 for pkg in $INSTALLED/*
pankso@6 1486 do
pascal@122 1487 [ -f $pkg/receipt ] || continue
pascal@114 1488 EXTRAVERSION=""
pankso@6 1489 . $pkg/receipt
pankso@6 1490 echo -n "$PACKAGE"
pascal@114 1491 echo -en "\033[24G $VERSION$EXTRAVERSION"
gokhlayeh@388 1492 echo -e "\033[42G `translate_category $CATEGORY`"
pankso@6 1493 packages=$(($packages+1))
pankso@6 1494 done
pankso@6 1495 echo "================================================================================"
pankso@344 1496 eval_gettext "\$packages packages installed."; echo
pankso@6 1497 echo ""
pankso@309 1498 fi ;;
pankso@37 1499 xhtml-list)
MikeDSmith25@135 1500 # Get info in receipts and build list.
pankso@37 1501 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
pankso@37 1502 if [ -n "$2" ]; then
pankso@37 1503 XHTML_LIST=$2
pankso@37 1504 else
pankso@38 1505 XHTML_LIST=installed-packages.html
pankso@37 1506 fi
pankso@37 1507 echo ""
pankso@344 1508 echo -e "\033[1m`gettext \"Creating xHTML list of installed packages\"`\033[0m"
pankso@37 1509 echo "================================================================================"
pankso@344 1510 gettext "Generating xHTML header..."
pankso@37 1511 xhtml_header
pankso@37 1512 status
pankso@37 1513 # Packages
pankso@344 1514 gettext "Creating packages information..."
pankso@37 1515 for pkg in $INSTALLED/*
pankso@37 1516 do
pascal@122 1517 [ -f $pkg/receipt ] || continue
pascal@114 1518 EXTRAVERSION=""
pankso@37 1519 . $pkg/receipt
pankso@37 1520 xhtml_pkg_info
pankso@37 1521 packages=$(($packages+1))
pankso@37 1522 done
pankso@37 1523 status
pankso@344 1524 gettext "Generating xHTML footer..."
pankso@37 1525 xhtml_footer
pankso@37 1526 status
pankso@37 1527 # sed pkgs nb in header.
pankso@37 1528 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
pankso@37 1529 echo "================================================================================"
pankso@344 1530 eval_gettext "\$XHTML_LIST created - $packages packages."; echo
pankso@309 1531 echo "" ;;
pankso@6 1532 list-mirror)
paul@247 1533 # List all available packages on the mirror. Option --diff displays
pankso@6 1534 # last mirrored packages diff (see recharge).
pankso@6 1535 check_for_packages_list
pankso@53 1536 case $2 in
pankso@53 1537 --diff)
pankso@53 1538 if [ -f "$LOCALSTATE/packages.diff" ]; then
pankso@53 1539 echo ""
pankso@344 1540 echo -e "\033[1m`gettext \"Mirrored packages diff\"`\033[0m"
pankso@53 1541 echo "================================================================================"
pankso@53 1542 cat $LOCALSTATE/packages.diff
pankso@53 1543 echo "================================================================================"
pankso@53 1544 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
pankso@344 1545 eval_gettext "\$pkgs new packages listed on the mirror."; echo
pankso@53 1546 echo ""
pankso@53 1547 else
pankso@344 1548 echo ""
pankso@344 1549 gettext "Unable to list anything, no packages.diff found."; echo
pankso@344 1550 gettext "Recharge your current list to create a first diff."; echo
pankso@344 1551 echo ""
pankso@53 1552 fi && exit 0 ;;
pankso@53 1553 --text|--txt)
pankso@6 1554 echo ""
pankso@344 1555 echo -e "\033[1m`gettext \"List of available packages on the mirror\"`\033[0m"
pankso@6 1556 echo "================================================================================"
pankso@53 1557 cat $LOCALSTATE/packages.txt ;;
pankso@53 1558 --raw|*)
pankso@53 1559 echo ""
pankso@344 1560 echo -e "\033[1m`gettext \"List of available packages on the mirror\"`\033[0m"
pankso@6 1561 echo "================================================================================"
pankso@53 1562 cat $LOCALSTATE/packages.list ;;
pankso@53 1563 esac
pankso@53 1564 echo "================================================================================"
pankso@53 1565 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
pankso@344 1566 eval_gettext "\$pkgs packages in the last recharged list."; echo
pankso@309 1567 echo "" ;;
pankso@6 1568 list-files)
pankso@6 1569 # List files installed with the package.
pankso@6 1570 #
pankso@6 1571 check_for_package_on_cmdline
pankso@6 1572 check_for_receipt
pankso@6 1573 echo ""
pankso@344 1574 echo -e "\033[1m`gettext \"Installed files with:\"`\033[0m $PACKAGE"
pankso@6 1575 echo "================================================================================"
pankso@6 1576 cat $INSTALLED/$PACKAGE/files.list | sort
pankso@6 1577 echo "================================================================================"
pankso@6 1578 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
gokhlayeh@388 1579 eval_gettext "\$files files installed with \$PACKAGE."; echo
pankso@309 1580 echo "" ;;
pankso@6 1581 info)
pascal@119 1582 # Information about package.
pankso@6 1583 #
pankso@6 1584 check_for_package_on_cmdline
pankso@6 1585 check_for_receipt
pascal@114 1586 EXTRAVERSION=""
pankso@6 1587 . $INSTALLED/$PACKAGE/receipt
pankso@6 1588 echo ""
pankso@344 1589 echo -e "\033[1m`gettext \"Tazpkg information\"`\033[0m
pankso@6 1590 ================================================================================
gokhlayeh@388 1591 `gettext \"Package :\"` $PACKAGE
gokhlayeh@388 1592 `gettext \"Version :\"` $VERSION$EXTRAVERSION
gokhlayeh@388 1593 `gettext \"Category :\"` `translate_category $CATEGORY`
gokhlayeh@388 1594 `gettext \"Short desc :\"` $SHORT_DESC
gokhlayeh@388 1595 `gettext \"Maintainer :\"` $MAINTAINER"
gokhlayeh@388 1596 if [ "$DEPENDS" ]; then
gokhlayeh@388 1597 echo -e "`gettext \"Depends :\"` $DEPENDS"
pankso@6 1598 fi
gokhlayeh@388 1599 if [ "$SUGGESTED" ]; then
gokhlayeh@388 1600 echo -e "`gettext \"Suggested :\"` $SUGGESTED"
pankso@38 1601 fi
gokhlayeh@388 1602 if [ "$BUILD_DEPENDS" ]; then
gokhlayeh@388 1603 echo -e "`gettext \"Build deps :\"` $BUILD_DEPENDS"
pankso@38 1604 fi
gokhlayeh@388 1605 if [ "$WANTED" ]; then
gokhlayeh@388 1606 echo -e "`gettext \"Wanted src :\"` $WANTED"
pankso@6 1607 fi
gokhlayeh@388 1608 if [ "$WEB_SITE" ]; then
gokhlayeh@388 1609 echo -e "`gettext \"Web site :\"` $WEB_SITE"
pankso@6 1610 fi
pankso@6 1611 echo "================================================================================"
pankso@309 1612 echo "" ;;
pankso@6 1613 desc)
pankso@6 1614 # Display package description.txt if available.
pankso@6 1615 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
pankso@6 1616 echo ""
pankso@344 1617 echo -e "\033[1m`gettext \"Description of:\"`\033[0m $PACKAGE"
pankso@6 1618 echo "================================================================================"
pankso@6 1619 cat $INSTALLED/$PACKAGE/description.txt
pankso@6 1620 echo "================================================================================"
pankso@6 1621 echo ""
pankso@6 1622 else
pankso@344 1623 echo ""
pankso@344 1624 gettext "Sorry, no description available for this package."; echo
pankso@344 1625 echo ""
pankso@309 1626 fi ;;
pankso@6 1627 search)
pankso@6 1628 # Search for a package by pattern or name.
pankso@6 1629 #
pankso@54 1630 PATTERN="$2"
pankso@54 1631 if [ -z "$PATTERN" ]; then
pankso@344 1632 echo ""
pankso@344 1633 gettext "Please specify a pattern or package name to search for."; echo
pankso@344 1634 gettext "Example : 'tazpkg search paint'"; echo
pankso@344 1635 echo ""
pankso@6 1636 exit 0
pankso@6 1637 fi
pankso@6 1638 echo ""
pankso@344 1639 echo -e "\033[1m`gettext \"Search result for:\"`\033[0m $PATTERN"
pankso@6 1640 echo ""
pankso@54 1641 # Default is to search in installed pkgs and the raw list.
pankso@54 1642 case $3 in
pankso@54 1643 -i|--installed)
pankso@54 1644 search_in_installed_packages ;;
pankso@54 1645 -l|--list)
pankso@54 1646 search_in_packages_list ;;
pankso@54 1647 -m|--mirror)
pankso@54 1648 search_in_packages_txt ;;
pankso@54 1649 *)
pankso@54 1650 search_in_installed_packages
jozee@338 1651 search_in_packages_list ;;
pankso@309 1652 esac ;;
pankso@12 1653 search-file)
pankso@12 1654 # Search for a file by pattern or name in all files.list.
pankso@12 1655 #
pankso@12 1656 if [ -z "$2" ]; then
pankso@344 1657 echo ""
pankso@344 1658 gettext "Please specify a pattern or file name to search for."; echo
pankso@344 1659 gettext "Example : 'tazpkg search-file libnss'"; echo
pankso@344 1660 echo ""
pankso@12 1661 exit 0
pankso@12 1662 fi
pankso@12 1663 echo ""
pankso@344 1664 echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2"
pankso@6 1665 echo "================================================================================"
pascal@98 1666
pascal@98 1667 if [ "$3" == "--mirror" ]; then
pankso@279 1668
pascal@187 1669 match=0
pascal@187 1670 for i in $LOCALSTATE/files.list.lzma \
pascal@187 1671 $LOCALSTATE/undigest/*/files.list.lzma; do
pascal@187 1672 [ -f $i ] || continue
pascal@187 1673 unlzma -c $i | grep -- ".*:.*$2" | awk '
pascal@98 1674 BEGIN { last="" }
pascal@98 1675 {
pascal@98 1676 pkg=substr($0,0,index($0,":")-1);
pascal@98 1677 file=substr($0,index($0,":")+2);
pascal@98 1678 if (last != pkg) {
pascal@98 1679 last = pkg;
pascal@98 1680 printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27);
pascal@98 1681 }
pascal@98 1682 printf("%s\n",file);
pascal@98 1683 }'
pascal@187 1684 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
pascal@187 1685 done
pascal@98 1686
pascal@98 1687 else
pascal@98 1688
pankso@12 1689 # Check all pkg files.list in search match with specify the package
pankso@12 1690 # name and the full path to the file(s).
pankso@12 1691 for pkg in $INSTALLED/*
pankso@12 1692 do
pascal@122 1693 if grep -qs "$2" $pkg/files.list; then
pankso@12 1694 . $pkg/receipt
pankso@12 1695 echo ""
pankso@344 1696 echo -e "\033[1m`gettext \"Package\"` $PACKAGE:\033[0m"
pankso@54 1697 grep "$2" $pkg/files.list
pankso@12 1698 files=`grep $2 $pkg/files.list | wc -l`
pankso@12 1699 match=$(($match+$files))
pankso@12 1700 fi
pankso@12 1701 done
pascal@98 1702
pascal@98 1703 fi
pankso@344 1704 pkg=$2
pankso@12 1705 if [ "$match" = "" ]; then
pankso@344 1706 eval_gettext "0 file found for: \$pkg"; echo
pankso@12 1707 echo ""
pankso@12 1708 else
pankso@12 1709 echo ""
pankso@12 1710 echo "================================================================================"
pankso@344 1711 eval_gettext "\$match file(s) found for: \$pkg"; echo
pankso@12 1712 echo ""
pankso@309 1713 fi ;;
jozee@318 1714 search-pkgname)
pankso@344 1715 # Search for a package name
jozee@318 1716 if [ -z "$2" ]; then
pankso@344 1717 echo ""
pankso@344 1718 gettext "Please specify a pattern or file name to search for."; echo
pankso@344 1719 gettext "Example : 'tazpkg search-pkgname libnss'"; echo
pankso@344 1720 echo ""
jozee@318 1721 exit 0
jozee@318 1722 fi
jozee@318 1723 echo ""
pankso@344 1724 echo -e "\033[1m`gettext \"Search result for file\"`\033[0m $2"
jozee@318 1725 echo "================================================================================"
jozee@318 1726
jozee@318 1727 # Search for a file on mirror and output only the package name
jozee@318 1728 match=0
jozee@318 1729 for i in $LOCALSTATE/files.list.lzma \
jozee@318 1730 $LOCALSTATE/undigest/*/files.list.lzma; do
jozee@318 1731 [ -f $i ] || continue
jozee@318 1732 unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | awk '{ print $1 }'
jozee@318 1733 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | cut -d: -f1 | uniq | wc -l`))
jozee@318 1734 done
pankso@344 1735 file=$2
jozee@318 1736 if [ "$match" = "" ]; then
pankso@344 1737 eval_gettext "0 file found for : \$file"; echo
jozee@318 1738 echo ""
jozee@318 1739 else
jozee@318 1740 echo ""
jozee@318 1741 echo "================================================================================"
pankso@344 1742 eval_gettext "$match pkg(s) found with file: \$file"; echo
jozee@318 1743 echo ""
jozee@318 1744 fi
jozee@318 1745 ;;
pankso@6 1746 install)
pankso@6 1747 # Install .tazpkg packages.
pankso@6 1748 #
pankso@6 1749 check_root
pankso@6 1750 check_for_package_on_cmdline
pankso@6 1751 check_for_package_file
gokhlayeh@386 1752
gokhlayeh@386 1753 # Get repositories priority list.
gokhlayeh@386 1754 look_for_priority
gokhlayeh@406 1755 get_options_list="root forced list"
gokhlayeh@406 1756 get_options
gokhlayeh@386 1757
pankso@6 1758 # Check if forced install.
gokhlayeh@407 1759 [ "$root" ] && ROOT="$root" && check_dir "$root"
gokhlayeh@406 1760 [ "$list" ] && INSTALL_LIST="$list"
gokhlayeh@423 1761 if ! [ "$forced" ]; then
pascal@121 1762 check_for_installed_package $ROOT
pankso@6 1763 fi
gokhlayeh@356 1764 install_package $ROOT
slaxemulator@369 1765 update_desktop_database $ROOT
slaxemulator@369 1766 update_mime_database $ROOT ;;
erjo@59 1767 install-list|get-install-list)
pankso@6 1768 # Install a set of packages from a list.
pankso@6 1769 #
pankso@6 1770 check_root
pankso@6 1771 if [ -z "$2" ]; then
pankso@344 1772 echo ""
pankso@344 1773 gettext \
paul@349 1774 "Please change directory (cd) to the packages repository and specify the
pankso@344 1775 list of packages to install. Example : tazpkg install-list packages.list"
pankso@344 1776 echo "" && exit 0
pankso@6 1777 fi
pankso@6 1778 # Check if the packages list exist.
pankso@344 1779 list_file=$2
pankso@344 1780 if [ ! -f "$list_file" ]; then
pankso@344 1781 gettext "Unable to find : $list_file"; echo
pankso@6 1782 exit 0
pankso@6 1783 else
pankso@6 1784 LIST=`cat $2`
pankso@6 1785 fi
pankso@279 1786
pascal@120 1787 # Remember processed list
pascal@121 1788 export INSTALL_LIST="$2"
pascal@120 1789
erjo@59 1790 # Set $COMMAND and install all packages.
erjo@59 1791 if [ "$1" = "get-install-list" ]; then
Eric@64 1792 COMMAND=get-install
erjo@59 1793 else
erjo@59 1794 COMMAND=install
erjo@59 1795 fi
pascal@121 1796 touch $2-processed
pascal@314 1797
pascal@314 1798 # Upgrade tazpkg first. It may handle new features/formats...
pascal@340 1799 # then upgrade essential packages early
pascal@341 1800 for pkg in busybox-pam busybox gcc-lib-base glibc-base \
pascal@341 1801 slitaz-base-files tazpkg ; do
pascal@341 1802 pkg=$(egrep $pkg-[0-9] $INSTALL_LIST)
pascal@341 1803 [ -n "$pkg" ] || continue
gokhlayeh@388 1804 eval_gettext "Adding implicit depends \$pkg ..."; echo
pascal@341 1805 LIST="$pkg
pascal@341 1806 $LIST"
pascal@340 1807 done
pascal@314 1808
pankso@6 1809 for pkg in $LIST
pankso@6 1810 do
pascal@121 1811 grep -qs ^$pkg$ $2-processed && continue
pascal@121 1812 tazpkg $COMMAND $pkg --list=$2 "$3" "$4" "$5"
pankso@6 1813 done
pankso@309 1814 rm -f $2-processed ;;
pankso@76 1815 add-flavor)
pascal@74 1816 # Install a set of packages from a flavor.
pascal@74 1817 #
pankso@309 1818 install_flavor $2 ;;
pankso@76 1819 install-flavor)
pascal@74 1820 # Install a set of packages from a flavor and purge other ones.
pascal@74 1821 #
pankso@309 1822 install_flavor $2 --purge ;;
pankso@76 1823 set-release)
pascal@74 1824 # Change curent release and upgrade packages.
pascal@74 1825 #
pascal@74 1826 RELEASE=$2
pankso@76 1827 if [ -z "$RELEASE" ]; then
pankso@344 1828 echo ""
pankso@344 1829 gettext "Please specify the release you want on the command line."; echo
pankso@344 1830 gettext "Example: tazpkg set-release cooking"; echo
pankso@344 1831 echo ""
pankso@76 1832 exit 0
pankso@76 1833 fi
slaxemulator@418 1834 rm $LOCALSTATE/mirror
pascal@74 1835 echo "$RELEASE" > /etc/slitaz-release
pascal@74 1836 tazpkg recharge && tazpkg upgrade
pascal@222 1837
pascal@222 1838 # Install missing depends
pascal@222 1839 cd $INSTALLED
pascal@222 1840 for i in * ; do
pascal@222 1841 DEPENDS=""
pascal@222 1842 . $i/receipt
pascal@222 1843 for j in $DEPENDS ; do
pascal@222 1844 [ -d $j ] || tazpkg get-install $j
pascal@222 1845 done
pankso@309 1846 done ;;
pankso@6 1847 remove)
pankso@6 1848 # Remove packages.
pankso@6 1849 #
pankso@6 1850 check_root
pankso@6 1851 check_for_package_on_cmdline
gokhlayeh@423 1852 get_options_list="root auto"
gokhlayeh@423 1853 get_options
gokhlayeh@423 1854 [ "$root" ] && ROOT="$root"
slaxemulator@370 1855 if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then
pankso@344 1856 echo ""
pankso@344 1857 eval_gettext "\$PACKAGE is not installed."; echo
pankso@6 1858 exit 0
pankso@6 1859 else
pascal@30 1860 ALTERED=""
pascal@30 1861 THE_PACKAGE=$PACKAGE # altered by receipt
slaxemulator@370 1862 for i in $(cd $ROOT$INSTALLED ; ls); do
slaxemulator@370 1863 [ -f $ROOT$INSTALLED/$i/receipt ] || continue
pankso@37 1864 DEPENDS=""
slaxemulator@370 1865 . $ROOT$INSTALLED/$i/receipt
pascal@30 1866 case " $(echo $DEPENDS) " in
pascal@30 1867 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
pascal@30 1868 esac
pascal@30 1869 done
pascal@114 1870 EXTRAVERSION=""
slaxemulator@370 1871 . $ROOT$INSTALLED/$THE_PACKAGE/receipt
pankso@6 1872 fi
pankso@6 1873 echo ""
pascal@30 1874 if [ -n "$ALTERED" ]; then
pankso@344 1875 eval_gettext "The following packages depend on \$PACKAGE:"; echo
pascal@30 1876 for i in $ALTERED; do
pascal@30 1877 echo " $i"
pascal@30 1878 done
pascal@30 1879 fi
slaxemulator@370 1880 REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
pascal@163 1881 if [ -n "$REFRESH" ]; then
pankso@344 1882 eval_gettext "The following packages have been modified by \$PACKAGE:"; echo
pascal@163 1883 for i in $REFRESH; do
pascal@170 1884 echo " ${i%/modifiers}"
pascal@163 1885 done
pascal@163 1886 fi
gokhlayeh@423 1887 if [ "$auto" ]; then
gokhlayeh@423 1888 answer=`translate_querry y`
gokhlayeh@423 1889 else
gokhlayeh@423 1890 eval_gettext "Remove \$PACKAGE (\$VERSION\$EXTRAVERSION) ?"; echo
gokhlayeh@423 1891 gettext "Please confirm uninstallation"
gokhlayeh@423 1892 echo -n " (`translate_querry y`/`translate_querry N`) : "; read answer
gokhlayeh@423 1893 fi
gokhlayeh@388 1894 if [ "$answer" = "$(translate_querry y)" ]; then
pankso@6 1895 echo ""
pankso@344 1896 echo -e "\033[1m`gettext \"Removing:\"`\033[0m $PACKAGE"
pankso@6 1897 echo "================================================================================"
pankso@38 1898 # Pre remove commands.
slaxemulator@371 1899 if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
pankso@38 1900 pre_remove
pankso@38 1901 fi
pankso@344 1902 gettext "Removing all files installed..."
slaxemulator@370 1903 if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then
pascal@403 1904 for file in `cat $ROOT$INSTALLED/$PACKAGE/files.list`
pascal@255 1905 do
pascal@403 1906 for mod in `cat $ROOT$INSTALLED/$PACKAGE/modifiers`
pascal@251 1907 do
pascal@403 1908 [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2
pascal@206 1909 done
pascal@403 1910 remove_with_path $ROOT$file
pascal@255 1911 done
pascal@255 1912 else
slaxemulator@370 1913 for file in `cat $ROOT$INSTALLED/$PACKAGE/files.list`
pascal@255 1914 do
slaxemulator@371 1915 remove_with_path $ROOT$file
pascal@255 1916 done
pascal@255 1917 fi
pankso@6 1918 status
slaxemulator@370 1919 if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then
pankso@51 1920 post_remove
pankso@51 1921 fi
pankso@6 1922 # Remove package receipt.
pankso@344 1923 gettext "Removing package receipt..."
slaxemulator@370 1924 rm -rf $ROOT$INSTALLED/$PACKAGE
pankso@6 1925 status
pascal@253 1926 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \
pascal@253 1927 $LOCALSTATE/installed.md5 2> /dev/null
pascal@183 1928 # Log this activity
pascal@183 1929 log Removed
gokhlayeh@423 1930 if [ "$ALTERED" ]; then
gokhlayeh@423 1931 if [ "$auto" ]; then
gokhlayeh@423 1932 answer=`translate_querry y`
gokhlayeh@423 1933 else
pankso@344 1934 eval_gettext "Remove packages depending on \$PACKAGE"
gokhlayeh@388 1935 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 1936 read answer
gokhlayeh@423 1937 fi
gokhlayeh@388 1938 if [ "$answer" = "$(translate_querry y)" ]; then
pascal@30 1939 for i in $ALTERED; do
slaxemulator@370 1940 if [ -d "$ROOT$INSTALLED/$i" ]; then
slaxemulator@371 1941 tazpkg remove $i $ROOTOPTS
pankso@37 1942 fi
pascal@30 1943 done
pascal@30 1944 fi
pascal@30 1945 fi
gokhlayeh@423 1946 if [ "$REFRESH" ]; then
gokhlayeh@423 1947 if [ "$auto" ]; then
gokhlayeh@423 1948 answer=`translate_querry y`
gokhlayeh@423 1949 else
pankso@344 1950 eval_gettext "Reinstall packages modified by \$PACKAGE"
gokhlayeh@388 1951 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 1952 read answer
gokhlayeh@423 1953 fi
gokhlayeh@388 1954 if [ "$answer" = "$(translate_querry y)" ]; then
pascal@163 1955 for i in $REFRESH; do
slaxemulator@370 1956 if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then
pankso@344 1957 eval_gettext "Check \$INSTALLED/\$i for reinstallation"; echo
pascal@163 1958 continue
pascal@163 1959 fi
slaxemulator@370 1960 rm -r $ROOT$INSTALLED/$i
slaxemulator@371 1961 tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced
pascal@163 1962 done
pascal@163 1963 fi
pascal@163 1964 fi
pankso@6 1965 else
pankso@6 1966 echo ""
pankso@344 1967 eval_gettext "Uninstallation of \$PACKAGE cancelled."; echo
pankso@6 1968 fi
pankso@309 1969 echo "" ;;
pankso@6 1970 extract)
pankso@6 1971 # Extract .tazpkg cpio archive into a directory.
pankso@6 1972 #
pankso@6 1973 check_for_package_on_cmdline
pankso@6 1974 check_for_package_file
pankso@6 1975 echo ""
pankso@344 1976 echo -e "\033[1m`gettext \"Extracting:\"`\033[0m $PACKAGE"
pankso@6 1977 echo "================================================================================"
MikeDSmith25@135 1978 # If no directory destination is found on the cmdline
MikeDSmith25@135 1979 # we create one in the current dir using the package name.
pankso@6 1980 if [ -n "$TARGET_DIR" ]; then
pankso@6 1981 DESTDIR=$TARGET_DIR/$PACKAGE
pankso@6 1982 else
pankso@6 1983 DESTDIR=$PACKAGE
pankso@6 1984 fi
pankso@6 1985 mkdir -p $DESTDIR
pankso@344 1986 gettext "Copying original package..."
pankso@9 1987 cp $PACKAGE_FILE $DESTDIR
pankso@6 1988 status
pankso@6 1989 cd $DESTDIR
pankso@6 1990 extract_package
pankso@6 1991 echo "================================================================================"
pankso@344 1992 eval_gettext "\$PACKAGE is extracted to: \$DESTDIR"; echo
pankso@309 1993 echo "" ;;
pascal@297 1994 recompress)
pascal@297 1995 # Recompress .tazpkg cpio archive with lzma.
pascal@297 1996 #
pascal@297 1997 check_for_package_on_cmdline
pascal@297 1998 check_for_package_file
pascal@297 1999 echo ""
pankso@344 2000 echo -e "\033[1m`gettext \"Recompressing:\"`\033[0m $PACKAGE"
pascal@297 2001 echo "================================================================================"
pascal@297 2002 mkdir -p $TMP_DIR
pankso@344 2003 gettext "Copying original package..."
pascal@297 2004 cp $PACKAGE_FILE $TMP_DIR
pascal@297 2005 status
pascal@297 2006 cd $TMP_DIR
pascal@297 2007 extract_package
pankso@344 2008 gettext "Recompressing the fs... "
gokhlayeh@383 2009 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@297 2010 rm -rf fs
pascal@297 2011 status
pankso@344 2012 gettext "Creating new package... "
gokhlayeh@383 2013 find . -print | cpio -o -H newc --quiet > \
pascal@297 2014 $TOP_DIR/$(basename $PACKAGE_FILE).$$ && mv -f \
pascal@297 2015 $TOP_DIR/$(basename $PACKAGE_FILE).$$ \
pascal@297 2016 $TOP_DIR/$(basename $PACKAGE_FILE)
pascal@297 2017 status
pascal@297 2018 cd $TOP_DIR
pankso@309 2019 rm -rf $TMP_DIR ;;
pascal@139 2020 list-config)
pascal@139 2021 # List configuration files installed.
pascal@139 2022 #
pascal@141 2023 if [ "$2" = "--box" ]; then
pascal@141 2024 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@210 2025 FILES="$INSTALLED/*/volatile.cpio.gz"
pascal@210 2026 [ -n "$3" ] && FILES="$INSTALLED/$3/volatile.cpio.gz"
pankso@279 2027 for i in $FILES; do
gokhlayeh@383 2028 zcat $i | cpio -idm --quiet > /dev/null
pascal@190 2029 find * -type f 2>/dev/null | while read file; do
pascal@190 2030 if [ ! -e /$file ]; then
gokhlayeh@388 2031 echo -en "|--|--|--|`gettext \"File lost\"`"
pascal@190 2032 else
pascal@143 2033 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
pascal@141 2034 cmp $file /$file > /dev/null 2>&1 || \
pascal@141 2035 echo -n "$(stat -c "%.16y" /$file)"
pascal@190 2036 fi
pascal@143 2037 echo "|/$file"
pascal@141 2038 done
pascal@141 2039 rm -rf *
pascal@146 2040 done
pascal@141 2041 cd $TOP_DIR
pascal@141 2042 rm -rf $TMP_DIR
pascal@141 2043 else
pascal@141 2044 echo ""
gokhlayeh@388 2045 echo -e "\033[1m`gettext \"Configuration files\"`\033[0m"
pascal@141 2046 echo "================================================================================"
pankso@279 2047 for i in $INSTALLED/*/volatile.cpio.gz; do
pascal@146 2048 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
pascal@146 2049 [ -f "$i" ] || continue
gokhlayeh@383 2050 zcat $i | cpio -t --quiet
pascal@146 2051 done | sed 's|^|/|' | sort
pascal@141 2052 echo "================================================================================"
pascal@141 2053 echo ""
pankso@309 2054 fi ;;
pascal@139 2055 repack-config)
pascal@137 2056 # Create SliTaz package archive from configuration files.
pascal@137 2057 #
pascal@137 2058 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@137 2059 CONFIG_VERSION=1.0
pascal@137 2060 mkdir config-$CONFIG_VERSION
pascal@137 2061 cd config-$CONFIG_VERSION
pankso@279 2062 for i in $INSTALLED/*/volatile.cpio.gz; do
gokhlayeh@383 2063 zcat $i | cpio -t --quiet
pascal@137 2064 done > files.list
pascal@137 2065 mkdir fs
pascal@137 2066 cd fs
gokhlayeh@416 2067 ( cd / ; cpio -o -H newc --quiet ) < ../files.list | cpio -idm --quiet > /dev/null
pascal@137 2068 mkdir -p etc/tazlito
pankso@279 2069 for i in $INSTALLED/*/receipt; do
pascal@137 2070 EXTRAVERSION=""
pascal@137 2071 . $i
pascal@137 2072 echo "$PACKAGE-$VERSION$EXTRAVERSION"
pascal@137 2073 done > etc/tazlito/config-packages.list
pascal@137 2074 cd ..
pascal@137 2075 echo "etc/tazlito/config-packages.list" >> files.list
pascal@137 2076 cat > receipt <<EOT
pascal@137 2077 # SliTaz package receipt.
pascal@137 2078
pascal@137 2079 PACKAGE="config"
pascal@137 2080 VERSION="$CONFIG_VERSION"
pascal@137 2081 CATEGORY="base-system"
gokhlayeh@388 2082 SHORT_DESC="$(gettext "User configuration backup on ")$(date)"
pascal@137 2083 DEPENDS="$(ls $INSTALLED)"
pascal@137 2084 EOT
pascal@137 2085 cd ..
pascal@137 2086 tazpkg pack config-$CONFIG_VERSION
pascal@137 2087 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
pascal@137 2088 cd $TOP_DIR
pascal@137 2089 rm -rf $TMP_DIR
pascal@137 2090 ;;
pascal@18 2091 repack)
MikeDSmith25@135 2092 # Create SliTaz package archive from an installed package.
pascal@18 2093 #
pascal@18 2094 check_for_package_on_cmdline
pascal@18 2095 check_for_receipt
pascal@114 2096 EXTRAVERSION=""
pascal@114 2097 . $INSTALLED/$PACKAGE/receipt
pascal@18 2098 echo ""
pascal@114 2099 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
pascal@18 2100 echo "================================================================================"
pascal@24 2101 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
gokhlayeh@388 2102 eval_gettext "Can't repack \$PACKAGE"; echo
pascal@24 2103 exit 1
pascal@24 2104 fi
pascal@21 2105 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
pankso@344 2106 eval_gettext "Can't repack, \$PACKAGE files have been modified by:"; echo
pascal@21 2107 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
pascal@21 2108 echo " $i"
pascal@21 2109 done
pascal@21 2110 exit 1
pascal@21 2111 fi
pascal@18 2112 MISSING=""
pascal@63 2113 while read i; do
pascal@18 2114 [ -e "$i" ] && continue
pascal@63 2115 [ -L "$i" ] || MISSING="$MISSING\n $i"
pascal@63 2116 done < $INSTALLED/$PACKAGE/files.list
pascal@18 2117 if [ -n "$MISSING" ]; then
pankso@344 2118 gettext "Can't repack, the following files are lost:"
pascal@63 2119 echo -e "$MISSING"
pascal@18 2120 exit 1
pascal@18 2121 fi
pascal@24 2122 mkdir -p $TMP_DIR && cd $TMP_DIR
pascal@298 2123 FILES="fs.cpio.lzma\n"
pascal@24 2124 for i in $(ls $INSTALLED/$PACKAGE) ; do
pascal@128 2125 [ "$i" = "volatile.cpio.gz" ] && continue
pascal@128 2126 [ "$i" = "modifiers" ] && continue
pascal@24 2127 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
pascal@24 2128 done
pascal@72 2129 ln -s / rootfs
pascal@72 2130 mkdir tmp
gokhlayeh@383 2131 sed 's/^/rootfs/' < files.list | cpio -o -H newc --quiet |\
gokhlayeh@416 2132 { cd tmp ; cpio -idm --quiet >/dev/null; cd ..; }
pascal@72 2133 mv tmp/rootfs fs
pascal@145 2134 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
pascal@145 2135 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
gokhlayeh@416 2136 { cd fs; cpio -idm --quiet; cd ..; }
pascal@145 2137 fi
gokhlayeh@409 2138 if fgrep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
pascal@107 2139 . $INSTALLED/$PACKAGE/receipt
pascal@107 2140 repack_cleanup fs
pascal@107 2141 fi
pascal@107 2142 if [ -f $INSTALLED/$PACKAGE/md5sum ]; then
pascal@107 2143 sed 's, , fs,' < $INSTALLED/$PACKAGE/md5sum | \
pascal@214 2144 md5sum -s -c || {
gokhlayeh@388 2145 gettext "Can't repack, md5sum error."; echo
pascal@107 2146 cd $TOP_DIR
pascal@214 2147 rm -rf $TMP_DIR
pascal@107 2148 exit 1
pascal@214 2149 }
pascal@107 2150 fi
gokhlayeh@383 2151 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
gokhlayeh@383 2152 echo -e "$FILES" | cpio -o -H newc --quiet > \
pascal@114 2153 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
pascal@74 2154 cd $TOP_DIR
pascal@18 2155 \rm -R $TMP_DIR
pankso@344 2156 eval_gettext "Package \$PACKAGE repacked successfully."; echo
gokhlayeh@388 2157 echo -e "`gettext \"Size\"` : `du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
pankso@309 2158 echo "" ;;
pankso@6 2159 pack)
MikeDSmith25@135 2160 # Create SliTaz package archive using cpio and gzip.
pankso@6 2161 #
pankso@6 2162 check_for_package_on_cmdline
pankso@6 2163 cd $PACKAGE
pankso@6 2164 if [ ! -f "receipt" ]; then
pankso@344 2165 gettext "Receipt is missing. Please read the documentation."; echo
pankso@6 2166 exit 0
pankso@6 2167 else
pankso@6 2168 echo ""
pankso@6 2169 echo -e "\033[1mPacking :\033[0m $PACKAGE"
pankso@6 2170 echo "================================================================================"
MikeDSmith25@135 2171 # Create files.list with redirecting find outpout.
pankso@344 2172 gettext "Creating the list of files..." && cd fs
pankso@6 2173 find . -type f -print > ../files.list
pankso@6 2174 find . -type l -print >> ../files.list
pankso@6 2175 cd .. && sed -i s/'^.'/''/ files.list
pankso@6 2176 status
pankso@344 2177 gettext "Creating md5sum of files..."
pascal@138 2178 while read file; do
pascal@138 2179 [ -L "fs$file" ] && continue
pascal@138 2180 [ -f "fs$file" ] || continue
pascal@158 2181 case "$file" in
pascal@158 2182 /lib/modules/*/modules.*|*.pyc) continue;;
pascal@158 2183 esac
pascal@138 2184 md5sum "fs$file" | sed 's/ fs/ /'
pascal@138 2185 done < files.list > md5sum
pascal@138 2186 status
pascal@147 2187 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
pascal@147 2188 description.txt 2> /dev/null | awk \
pascal@147 2189 '{ sz=$1 } END { print sz }')
pankso@6 2190 # Build cpio archives.
pankso@344 2191 gettext "Compressing the fs... "
gokhlayeh@383 2192 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pascal@138 2193 rm -rf fs
pascal@147 2194 status
pascal@298 2195 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
pascal@147 2196 md5sum description.txt 2> /dev/null | awk \
pascal@147 2197 '{ sz=$1 } END { print sz }')
paul@349 2198 gettext "Updating receipt sizes..."
pankso@279 2199 sed -i s/^PACKED_SIZE.*$// receipt
pankso@279 2200 sed -i s/^UNPACKED_SIZE.*$// receipt
pascal@147 2201 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@147 2202 status
pankso@344 2203 gettext "Creating full cpio archive... "
gokhlayeh@383 2204 find . -print | cpio -o -H newc --quiet > ../$PACKAGE.tazpkg
pascal@147 2205 status
pankso@344 2206 gettext "Restoring original package tree... "
gokhlayeh@383 2207 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pascal@147 2208 status
pascal@298 2209 rm fs.cpio.lzma && cd ..
pankso@6 2210 echo "================================================================================"
pankso@344 2211 eval_gettext "Package \$PACKAGE compressed successfully."; echo
gokhlayeh@388 2212 echo "`gettext \"Size\"` : `du -sh $PACKAGE.tazpkg`"
pankso@6 2213 echo ""
pankso@309 2214 fi ;;
pankso@6 2215 recharge)
pankso@6 2216 # Recharge packages.list from a mirror.
pankso@6 2217 #
pankso@6 2218 check_root
gokhlayeh@386 2219
pascal@187 2220 for path in $LOCALSTATE $LOCALSTATE/undigest/*; do
pascal@187 2221 [ -f $path/mirror ] || continue
pankso@6 2222 echo ""
pascal@187 2223 if [ "$path" != "$LOCALSTATE" ]; then
gokhlayeh@388 2224 echo -e "`gettext \"Recharging undigest\"` $(basename $path):"
pascal@187 2225 fi
pascal@187 2226 cd $path
pascal@187 2227 if [ -f "packages.list" ]; then
pankso@344 2228 gettext "Creating backup of the last packages list..."
pascal@187 2229 mv -f packages.desc packages.desc.bak 2>/dev/null
pascal@187 2230 mv -f packages.md5 packages.md5.txt 2>/dev/null
pascal@187 2231 mv -f packages.txt packages.txt.bak 2>/dev/null
pascal@187 2232 mv -f packages.list packages.list.bak 2>/dev/null
pascal@187 2233 mv -f packages.equiv packages.equiv.bak 2>/dev/null
pascal@248 2234 mv -f files.list.lzma files.list.lzma.bak 2> /dev/null
pascal@248 2235 mv -f mirrors mirrors.bak 2> /dev/null
pascal@187 2236 status
pascal@187 2237 fi
pascal@187 2238 download_from "$(cat mirror)" packages.desc
pascal@187 2239 download_from "$(cat mirror)" packages.md5
pascal@187 2240 download_from "$(cat mirror)" packages.txt
pascal@187 2241 download_from "$(cat mirror)" packages.list
pascal@187 2242 download_from "$(cat mirror)" packages.equiv
pascal@187 2243 download_from "$(cat mirror)" files.list.lzma
pascal@305 2244 download_from "$(sed 's|packages/.*||' < mirror)" mirrors
pascal@248 2245 [ -f mirrors ] || mv mirrors.bak mirrors 2> /dev/null
pascal@218 2246 suffix=$(head -1 mirror)
pascal@218 2247 suffix=packages${suffix#*/packages}
pascal@218 2248 for i in $(cat mirrors 2> /dev/null); do
gokhlayeh@409 2249 fgrep -qs $i mirror || echo $i$suffix >> mirror
pascal@218 2250 done
pascal@187 2251 if [ -f "packages.list.bak" ]; then
pascal@187 2252 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
pascal@187 2253 sed -i s/+// packages.diff
pascal@187 2254 echo ""
pankso@344 2255 echo -e "\033[1m`gettext \"Mirrored packages diff\"`\033[0m"
pankso@6 2256 echo "================================================================================"
pascal@187 2257 cat packages.diff
pankso@344 2258 new_pkgs=`cat packages.diff | wc -l`
pankso@344 2259 if [ "$new_pkgs" != 0 ]; then
pascal@187 2260 echo "================================================================================"
pankso@344 2261 eval_gettext "\$new_pkgs new packages on the mirror."; echo
pascal@187 2262 echo ""
pascal@187 2263 else
pankso@344 2264 gettext "No new packages on the mirror."; echo
pascal@187 2265 echo ""
pascal@187 2266 fi
pankso@6 2267 else
pascal@187 2268 echo -e "
pankso@344 2269 ================================================================================"
pankso@344 2270 gettext \
pankso@344 2271 "Last packages.list is ready to use. Note that next time you recharge the
pankso@344 2272 list, a list of differences will be displayed to show new and upgradeable
pankso@344 2273 packages."
pankso@344 2274 echo ""
pascal@187 2275 fi
pankso@309 2276 done ;;
pascal@319 2277 upgradeable)
pascal@319 2278 # Build upgradeable-packages.list quickly.
pascal@319 2279 #
pascal@319 2280 check_root
pascal@319 2281 cd $LOCALSTATE
pascal@319 2282 while read md5 file ; do
gokhlayeh@409 2283 fgrep -qs "$md5 $file" packages.md5 && continue
pascal@319 2284 for i in 1 2 3 4 5; do
pascal@319 2285 file=${file%-*}
pascal@319 2286 [ -d installed/$file ] || continue
pascal@319 2287 echo $file
pascal@319 2288 break
pascal@319 2289 done
pascal@319 2290 done < installed.md5 > upgradeable-packages.list ;;
pankso@6 2291 upgrade)
pankso@6 2292 # Upgrade all installed packages with the new version from the mirror.
pankso@6 2293 #
pankso@6 2294 check_root
pankso@6 2295 check_for_packages_list
gokhlayeh@386 2296
gokhlayeh@386 2297 # Get repositories priority list.
gokhlayeh@386 2298 look_for_priority
gokhlayeh@386 2299
pankso@6 2300 cd $LOCALSTATE
pankso@10 2301 # Touch the blocked pkgs list to avoid errors and remove any old
pankso@10 2302 # upgrade list.
pankso@10 2303 touch blocked-packages.list
MikeDSmith25@134 2304 rm -f upgradeable-packages.list
pankso@6 2305 echo ""
pankso@344 2306 echo -e "\033[1m`gettext \"Available upgrades\"`\033[0m"
pankso@6 2307 echo "================================================================================"
pankso@52 2308 echo ""
pascal@66 2309 # Some packages must be installed first
pascal@121 2310 FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts "
pascal@271 2311 if [ -n "$PACKAGE_FILE" -a -d "$INSTALLED/$PACKAGE_FILE" ]; then
pascal@271 2312 ALL=$INSTALLED/$PACKAGE_FILE
pascal@271 2313 else
pascal@271 2314 ALL="$(ls -d $INSTALLED/*)"
pascal@271 2315 fi
pascal@271 2316 for pkg in $ALL
pankso@279 2317 do
pascal@122 2318 [ -f $pkg/receipt ] || continue
pascal@114 2319 EXTRAVERSION=""
pankso@6 2320 . $pkg/receipt
MikeDSmith25@135 2321 # Display package name to show that Tazpkg is working...
pankso@52 2322 echo -en "\\033[0G "
pankso@52 2323 echo -en "\\033[0G$PACKAGE"
pankso@10 2324 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
pascal@223 2325 if grep -qs "^$PACKAGE" $BLOCKED; then
pankso@10 2326 blocked=$(($blocked+1))
pankso@10 2327 else
pankso@10 2328 # Check if the installed package is in the current list (other
pankso@10 2329 # mirror or local).
pascal@190 2330 NEW_PACKAGE=$(get_package_filename $PACKAGE)
pascal@112 2331
pascal@110 2332 if [ -n "$NEW_PACKAGE" ]; then
paul@247 2333 # Set new pkg and version for future comparison
pankso@10 2334 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
pankso@43 2335 # Change '-' and 'pre' to points.
pankso@43 2336 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
pascal@114 2337 VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION
pankso@43 2338 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
pankso@43 2339 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
pascal@112 2340 NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'`
pascal@112 2341 VERSION=`echo $VERSION | sed 's/[A-Z]\.//'`
paul@247 2342 # Compare version. Upgrades are only available for official
paul@247 2343 # packages, so we control the mirror and it should be ok if
paul@247 2344 # we just check for equality.
pascal@191 2345 RELEASE=""
pascal@191 2346 if [ -f installed.md5 -a -f packages.md5 ]; then
gokhlayeh@409 2347 current_md5=$(fgrep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
gokhlayeh@409 2348 new_md5=$(fgrep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
pascal@191 2349 [ -n "$current_md5" ] && [ -n "$new_md5" ] &&
gokhlayeh@388 2350 [ "$current_md5" != "$new_md5" ] && RELEASE=$(gettext "build")
pascal@191 2351 fi
pascal@191 2352 if [ "$VERSION" != "$NEW_VERSION" -o -n "$RELEASE" ]; then
pankso@279 2353 # Version seems different. Check for major, minor or
pankso@10 2354 # revision
pascal@105 2355 PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."`
pascal@105 2356 NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."`
pascal@105 2357 PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."`
pascal@105 2358 NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."`
pankso@10 2359 # Minor
pascal@168 2360 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then
gokhlayeh@388 2361 RELEASE=$(gettext "minor")
pankso@10 2362 fi
pascal@168 2363 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then
gokhlayeh@388 2364 RELEASE=$(gettext "WARNING")
pankso@10 2365 FIXE=yes
pankso@10 2366 fi
pankso@41 2367 # Major
pascal@168 2368 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then
gokhlayeh@388 2369 RELEASE=$(gettext "major")
pankso@41 2370 FIXE=""
pankso@41 2371 fi
pascal@168 2372 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then
gokhlayeh@388 2373 RELEASE=$(gettext "WARNING")
pankso@41 2374 FIXE=yes
pankso@41 2375 fi
pankso@10 2376 # Default to revision.
pankso@10 2377 if [ -z $RELEASE ]; then
gokhlayeh@388 2378 RELEASE=$(gettext "revision")
pankso@10 2379 fi
pankso@52 2380 # Pkg name is already displayed by the check process.
pankso@10 2381 echo -en "\033[24G $VERSION"
pankso@10 2382 echo -en "\033[38G --->"
pankso@44 2383 echo -en "\033[43G $NEW_VERSION"
gokhlayeh@388 2384 echo -en "\033[58G `translate_category $CATEGORY`"
pankso@10 2385 echo -e "\033[72G $RELEASE"
pankso@10 2386 up=$(($up+1))
MikeDSmith25@134 2387 echo "$PACKAGE" >> upgradeable-packages.list
pascal@66 2388 case "$FIRST_CLASS_PACKAGE" in
MikeDSmith25@134 2389 *\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;;
pascal@66 2390 esac
pankso@14 2391 unset RELEASE
pankso@10 2392 fi
pankso@10 2393 packages=$(($packages+1))
pankso@6 2394 fi
pankso@10 2395 fi
pankso@6 2396 done
pankso@45 2397 if [ -z $blocked ]; then
pankso@44 2398 blocked=0
pankso@44 2399 fi
pankso@52 2400 # Clean last checked package and display summary.
pankso@6 2401 if [ ! "$up" = "" ]; then
pankso@52 2402 echo -e "\\033[0G "
pankso@6 2403 echo "================================================================================"
pankso@344 2404 eval_gettext "\$packages installed and listed packages to consider, \$up to upgrade, \$blocked blocked."; echo
pankso@6 2405 echo ""
pankso@6 2406 else
pankso@344 2407 echo -e "\\033[0G`gettext \"System is up-to-date.\"` "
pankso@52 2408 echo ""
pankso@52 2409 echo "================================================================================"
pankso@344 2410 eval_gettext "\$packages installed and listed packages to consider, 0 to upgrade, \$blocked blocked."; echo
pankso@6 2411 echo ""
pankso@6 2412 exit 0
pankso@6 2413 fi
pankso@10 2414 # What to do if major or minor version is smaller.
pankso@10 2415 if [ "$FIXE" == "yes" ]; then
pankso@344 2416 gettext \
pankso@344 2417 "WARNING ---> Installed package seems more recent than the mirrored
pankso@344 2418 one. You can block packages using the command : 'tazpkg block package'.
pankso@344 2419 Or upgrade packages at your own risk."
pankso@10 2420 echo ""
pankso@10 2421 fi
MikeDSmith25@135 2422 # Ask for upgrade, it can be done another time.
gokhlayeh@388 2423 gettext "Upgrade now"
gokhlayeh@388 2424 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 2425 read answer
gokhlayeh@388 2426 if [ ! "$answer" = "$(translate_querry y)" ]; then
pankso@344 2427 echo ""
pankso@344 2428 gettext "Exiting. No package upgraded."; echo
pankso@344 2429 echo ""
pankso@6 2430 exit 0
pankso@6 2431 fi
gokhlayeh@388 2432 # If answer is yes (y). Install all new versions.
MikeDSmith25@134 2433 cat upgradeable-packages.list >> upgradeable-packages.list$$
MikeDSmith25@134 2434 mv -f upgradeable-packages.list$$ upgradeable-packages.list
pascal@191 2435 yes y | tazpkg get-install-list upgradeable-packages.list --forced
pascal@191 2436 rm -f upgradeable-packages.list
pankso@6 2437 ;;
pascal@152 2438 bugs)
pascal@152 2439 # Show known bugs in package(s)
pascal@152 2440 #
pascal@152 2441 cd $INSTALLED
pascal@159 2442 shift
pascal@159 2443 LIST=$@
pascal@159 2444 [ -n "$LIST" ] || LIST=`ls`
gokhlayeh@388 2445 MSG=$(gettext "No known bugs.")
pascal@152 2446 for PACKAGE in $LIST; do
pascal@152 2447 BUGS=""
pascal@154 2448 EXTRAVERSION=""
pascal@152 2449 . $PACKAGE/receipt
pascal@152 2450 if [ -n "$BUGS" ]; then
gokhlayeh@388 2451 MSG=$(gettext "Bug list completed")
pankso@344 2452 echo ""
pankso@344 2453 eval_gettext "Bugs in package \$PACKAGE version \$VERSION\$EXTRAVERSION:"; echo
pascal@152 2454 cat <<EOT
pascal@152 2455 $BUGS
pascal@152 2456 EOT
pascal@152 2457 fi
pascal@152 2458 done
pankso@309 2459 echo "$MSG" ;;
pascal@25 2460 check)
MikeDSmith25@135 2461 # Check installed packages set.
pascal@25 2462 #
pascal@25 2463 check_root
gokhlayeh@386 2464
gokhlayeh@386 2465 # Get repositories priority list.
gokhlayeh@386 2466 look_for_priority
gokhlayeh@386 2467
pascal@25 2468 cd $INSTALLED
pascal@25 2469 for PACKAGE in `ls`; do
pascal@122 2470 if [ ! -f $PACKAGE/receipt ]; then
pankso@344 2471 eval_gettext "The package \$PACKAGE installation has not completed"; echo
pascal@122 2472 continue
pascal@122 2473 fi
pascal@29 2474 DEPENDS=""
pascal@114 2475 EXTRAVERSION=""
pascal@29 2476 . $PACKAGE/receipt
pascal@29 2477 if [ -s $PACKAGE/modifiers ]; then
pankso@344 2478 eval_gettext \
pankso@344 2479 "The package \$PACKAGE \$VERSION\$EXTRAVERSION has been modified by:"; echo
pascal@29 2480 for i in $(cat $PACKAGE/modifiers); do
pascal@29 2481 echo " $i"
pascal@29 2482 done
pascal@29 2483 fi
gokhlayeh@388 2484 MSG="$(eval_gettext "Files lost from \$PACKAGE \$VERSION\$EXTRAVERSION :")\n"
pascal@25 2485 while read file; do
pascal@25 2486 [ -e "$file" ] && continue
pascal@25 2487 if [ -L "$file" ]; then
gokhlayeh@388 2488 MSG="$MSG $(gettext "target of symlink")"
pascal@25 2489 fi
pascal@25 2490 echo -e "$MSG $file"
pascal@25 2491 MSG=""
pascal@25 2492 done < $PACKAGE/files.list
gokhlayeh@388 2493 MSG="$(gettext "Missing dependencies for") $PACKAGE $VERSION$EXTRAVERSION :\n"
pascal@25 2494 for i in $DEPENDS; do
pascal@25 2495 [ -d $i ] && continue
pascal@290 2496 [ -d $(equivalent_pkg $i) ] && continue
pascal@25 2497 echo -e "$MSG $i"
pascal@25 2498 MSG=""
pascal@25 2499 done
gokhlayeh@388 2500 MSG="$(gettext "Dependencies loop between") $PACKAGE and :\n"
pascal@122 2501 ALL_DEPS=""
pascal@122 2502 check_for_deps_loop $PACKAGE $DEPENDS
pascal@25 2503 done
gokhlayeh@388 2504 gettext "Looking for known bugs... "; echo
pascal@152 2505 tazpkg bugs
pascal@60 2506 if [ "$PACKAGE_FILE" = "--full" ]; then
pascal@106 2507 for file in */md5sum; do
pascal@177 2508 CONFIG_FILES=""
pascal@177 2509 . $(dirname "$file")/receipt
pascal@106 2510 [ -s "$file" ] || continue
pascal@177 2511 while read md5 f; do
pascal@177 2512 [ -f $f ] || continue
pascal@177 2513 for i in $CONFIG_FILES; do
pascal@177 2514 case "$f" in
pascal@177 2515 $i|$i/*) continue 2;;
pascal@177 2516 esac
pascal@177 2517 done
pascal@177 2518 echo "$md5 $f"
pascal@177 2519 done < "$file" | md5sum -c - 2> /dev/null | \
pascal@177 2520 grep -v OK$ | sed 's/FAILED$/MD5SUM MISMATCH/'
pascal@106 2521 done
pascal@60 2522 FILES=" "
pascal@60 2523 for file in $(cat */files.list); do
pascal@60 2524 [ -d "$file" ] && continue
pascal@60 2525 case "$FILES" in *\ $file\ *) continue;; esac
pascal@377 2526 [ $(grep "^$(echo $file | grepesc)$" */files.list 2> /dev/null | \
pascal@60 2527 wc -l) -gt 1 ] || continue
pascal@60 2528 FILES="$FILES$file "
gokhlayeh@388 2529 eval_gettext "The following packages provide \$file :"; echo
pascal@377 2530 grep -l "^$(echo $file | grepesc)$" */files.list | while read f
pascal@60 2531 do
pascal@60 2532 pkg=${f%/files.list}
pascal@60 2533 echo -n " $pkg"
pascal@60 2534 if [ -f $pkg/modifiers ]; then
gokhlayeh@388 2535 echo -en " (`gettext \"overridden by\"`) $(echo "$(cat $pkg/modifiers)"))"
pascal@60 2536 fi
pascal@60 2537 echo ""
pascal@60 2538 done
pascal@60 2539 done
gokhlayeh@388 2540 MSG="$(gettext "No package has installed the following files"):\n"
pascal@155 2541 find /etc /bin /sbin /lib /usr /var/www \
pascal@155 2542 -not -type d 2> /dev/null | while read file; do
pascal@73 2543 case "$file" in *\[*) continue;; esac
pascal@377 2544 grep -q "^$(echo $file | grepesc)$" */files.list && continue
pascal@73 2545 echo -e "$MSG $file"
pascal@73 2546 MSG=""
pascal@73 2547 done
pascal@60 2548 fi
gokhlayeh@388 2549 gettext "Check completed."; echo ;;
pankso@10 2550 block)
pankso@10 2551 # Add a pkg name to the list of blocked packages.
pankso@10 2552 #
pankso@10 2553 check_root
pankso@10 2554 check_for_package_on_cmdline
pankso@10 2555 echo ""
pascal@223 2556 if grep -qs "^$PACKAGE" $BLOCKED; then
pankso@344 2557 eval_gettext "\$PACKAGE is already in the blocked packages list."; echo
pankso@10 2558 echo ""
pankso@10 2559 exit 0
pankso@10 2560 else
pankso@344 2561 eval_gettext "Add \$PACKAGE to : \$BLOCKED..."
pankso@10 2562 echo $PACKAGE >> $BLOCKED
pankso@10 2563 status
pascal@183 2564 # Log this activity
pascal@183 2565 . $INSTALLED/$PACKAGE/receipt
pascal@183 2566 log Blocked
pankso@10 2567 fi
pankso@309 2568 echo "" ;;
pankso@10 2569 unblock)
MikeDSmith25@135 2570 # Remove a pkg name from the list of blocked packages.
pankso@10 2571 #
pankso@10 2572 check_root
pankso@10 2573 check_for_package_on_cmdline
pankso@10 2574 echo ""
pascal@223 2575 if grep -qs "^$PACKAGE" $BLOCKED; then
pankso@344 2576 eval_gettext "Removing \$PACKAGE from : \$BLOCKED..."
pankso@10 2577 sed -i s/$PACKAGE/''/ $BLOCKED
pankso@10 2578 sed -i '/^$/d' $BLOCKED
pankso@10 2579 status
pascal@183 2580 # Log this activity
pascal@183 2581 . $INSTALLED/$PACKAGE/receipt
pascal@183 2582 log Unblocked
pankso@10 2583 else
gokhlayeh@388 2584 eval_gettext "\$PACKAGE is not in the blocked packages list."; echo
pankso@10 2585 echo ""
pankso@10 2586 exit 0
pankso@10 2587 fi
pankso@309 2588 echo "" ;;
pankso@6 2589 get)
pankso@6 2590 # Downlowd a package with wget.
pankso@6 2591 #
pankso@6 2592 check_for_package_on_cmdline
pankso@6 2593 check_for_packages_list
gokhlayeh@386 2594
gokhlayeh@386 2595 # Get repositories priority list.
gokhlayeh@386 2596 look_for_priority
gokhlayeh@386 2597
pankso@6 2598 check_for_package_in_list
pankso@6 2599 echo ""
slaxemulator@378 2600 if [ -f $PACKAGE.tazpkg ]; then
gokhlayeh@420 2601 if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.md5)" ]; then
slaxemulator@378 2602 rm -f $PACKAGE.tazpkg
slaxemulator@378 2603 download $PACKAGE.tazpkg
slaxemulator@378 2604 fi
slaxemulator@378 2605 else
slaxemulator@378 2606 download $PACKAGE.tazpkg
slaxemulator@378 2607 fi
pankso@309 2608 echo "" ;;
pankso@6 2609 get-install)
pankso@6 2610 # Download and install a package.
pankso@6 2611 #
pankso@6 2612 check_root
pankso@6 2613 check_for_package_on_cmdline
pankso@6 2614 check_for_packages_list
gokhlayeh@386 2615
gokhlayeh@386 2616 # Get repositories priority list.
gokhlayeh@386 2617 look_for_priority
gokhlayeh@406 2618 get_options_list="root forced list"
gokhlayeh@406 2619 get_options
gokhlayeh@386 2620
pascal@121 2621 DO_CHECK=""
gokhlayeh@406 2622 [ "$forced" ] && DO_CHECK=no
gokhlayeh@407 2623 [ "$root" ] && ROOT="$root" && check_dir "$root"
gokhlayeh@406 2624 [ "$list" ] && INSTALL_LIST="$list"
pascal@202 2625 AUTOEXEC="no"
gokhlayeh@416 2626 if ! check_for_package_in_list check; then
gokhlayeh@416 2627 PACKAGE=get-$PACKAGE
pascal@202 2628 AUTOEXEC=$PACKAGE
pascal@202 2629 check_for_package_in_list
pascal@202 2630 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
gokhlayeh@419 2631 CACHE_DIR="${CACHE_DIR%/*}/get"
gokhlayeh@419 2632 [ -d "$CACHE_DIR" ] || mkdir -p $CACHE_DIR
pascal@202 2633 $AUTOEXEC $ROOT
pascal@202 2634 exit 0
pascal@202 2635 fi
gokhlayeh@416 2636 fi
pankso@6 2637 # Check if forced install.
gokhlayeh@423 2638 if ! [ "$forced" ]; then
pascal@121 2639 check_for_installed_package $ROOT
pankso@6 2640 fi
pankso@6 2641 cd $CACHE_DIR
pankso@6 2642 if [ -f "$PACKAGE.tazpkg" ]; then
gokhlayeh@388 2643 eval_gettext "\$PACKAGE already in the cache : \$CACHE_DIR"; echo
MikeDSmith25@135 2644 # Check package download was finished
gokhlayeh@409 2645 tail -c 2k $PACKAGE.tazpkg | fgrep -q 00000000TRAILER || {
paul@349 2646 eval_gettext "Continuing \$PACKAGE download"; echo
pascal@108 2647 download $PACKAGE.tazpkg
pascal@108 2648 }
gokhlayeh@419 2649 if [ "$(md5sum $PACKAGE.tazpkg)" != "$(fgrep " $PACKAGE.tazpkg" $rep/packages.md5)" ]; then
slaxemulator@375 2650 rm -f $PACKAGE.tazpkg
pascal@374 2651 download $PACKAGE.tazpkg
pascal@374 2652 fi
pankso@6 2653 else
pankso@6 2654 echo ""
pascal@17 2655 download $PACKAGE.tazpkg
pankso@6 2656 fi
pankso@14 2657 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
pascal@121 2658 install_package $ROOT
gokhlayeh@356 2659 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
slaxemulator@369 2660 update_desktop_database $ROOT
slaxemulator@369 2661 update_mime_database $ROOT ;;
pankso@6 2662 clean-cache)
pankso@6 2663 # Remove all downloaded packages.
pankso@6 2664 #
pankso@6 2665 check_root
pankso@6 2666 files=`ls -1 $CACHE_DIR | wc -l`
pankso@6 2667 echo ""
pankso@344 2668 echo -e "\033[1m`gettext \"Clean cache:\"`\033[0m $CACHE_DIR"
pankso@6 2669 echo "================================================================================"
gokhlayeh@388 2670 gettext "Cleaning cache directory..."; echo
pankso@6 2671 rm -rf $CACHE_DIR/*
pankso@44 2672 status
pankso@44 2673 echo "================================================================================"
pankso@344 2674 eval_gettext "\$files file(s) removed from cache."; echo
pankso@309 2675 echo "" ;;
pascal@187 2676 list-undigest)
pascal@187 2677 # list undigest URLs.
pascal@187 2678 #
pascal@187 2679 if [ "$2" = "--box" ]; then
pascal@187 2680 for i in $LOCALSTATE/undigest/*/mirror; do
pascal@187 2681 [ -f $i ] || continue
pascal@187 2682 echo "$(basename $(dirname $i))|$(cat $i)"
pascal@187 2683 done
pascal@187 2684 else
pascal@187 2685 echo ""
pankso@344 2686 echo -e "\033[1m`gettext \"Current undigest(s)\"`\033[0m"
pascal@187 2687 echo "================================================================================"
pascal@187 2688 for i in $LOCALSTATE/undigest/*/mirror; do
pascal@187 2689 if [ ! -f $i ]; then
pankso@344 2690 gettext "No undigest mirror found."; echo
pascal@187 2691 exit 1
pascal@187 2692 fi
pascal@187 2693 echo "$(basename $(dirname $i)) $(cat $i)"
pascal@187 2694 done
pascal@187 2695 echo ""
pankso@309 2696 fi ;;
pascal@187 2697 remove-undigest)
pascal@187 2698 # remove undigest URL.
pascal@187 2699 #
pascal@187 2700 check_root
gokhlayeh@388 2701 undigest="$2"
pascal@187 2702 if [ -d $LOCALSTATE/undigest/$2 ]; then
gokhlayeh@388 2703 eval_gettext "Remove \$undigest undigest"
gokhlayeh@388 2704 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 2705 read answer
gokhlayeh@388 2706 if [ "$answer" = "$(translate_querry y)" ]; then
gokhlayeh@388 2707 eval_gettext "Removing \$undigest undigest..."
pascal@187 2708 rm -rf $LOCALSTATE/undigest/$2
pascal@187 2709 status
pascal@187 2710 rmdir $LOCALSTATE/undigest 2> /dev/null
pascal@187 2711 fi
pascal@187 2712 else
gokhlayeh@388 2713 eval_gettext "Undigest \$undigest not found"; echo
pankso@309 2714 fi ;;
pascal@187 2715 add-undigest|setup-undigest)
pascal@187 2716 # Add undigest URL.
pascal@187 2717 #
pascal@187 2718 check_root
pascal@187 2719 undigest=$2
pascal@187 2720 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
pascal@187 2721 if [ -z "$undigest" ]; then
pascal@187 2722 i=1
pascal@187 2723 while [ -d $LOCALSTATE/undigest/$i ]; do
pascal@187 2724 i=$(($i+1))
pascal@187 2725 done
pascal@187 2726 undigest=$i
pascal@187 2727 fi
pascal@187 2728 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
pankso@344 2729 eval_gettext "Creating new undigest \$undigest."; echo
pascal@187 2730 mkdir $LOCALSTATE/undigest/$undigest
pascal@187 2731 fi
pankso@309 2732 setup_mirror $LOCALSTATE/undigest/$undigest $3 ;;
pankso@6 2733 setup-mirror)
pankso@6 2734 # Change mirror URL.
pankso@6 2735 #
pankso@6 2736 check_root
pankso@309 2737 setup_mirror $LOCALSTATE $2 ;;
erjo@56 2738 reconfigure)
erjo@56 2739 # Replay post_install from receipt
erjo@56 2740 #
erjo@56 2741 check_for_package_on_cmdline
erjo@56 2742 check_root
pascal@250 2743 ROOT=""
pascal@250 2744 while [ -n "$3" ]; do
pascal@250 2745 case "$3" in
pascal@250 2746 --root=*)
pankso@309 2747 ROOT="${3#--root=}/" ;;
pascal@250 2748 *) shift 2
gokhlayeh@388 2749 echo -e "\n`gettext \"Unknow option\"` $*.\n" >&2
pankso@309 2750 exit 1 ;;
pascal@250 2751 esac
pascal@250 2752 shift
pascal@250 2753 done
pascal@250 2754 if [ -d "$ROOT$INSTALLED/$PACKAGE" ]; then
pascal@250 2755 check_for_receipt $ROOT
erjo@56 2756 # Check for post_install
pascal@250 2757 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
pascal@250 2758 . $ROOT$INSTALLED/$PACKAGE/receipt
pascal@250 2759 post_install $ROOT
pascal@183 2760 # Log this activity
pascal@250 2761 [ -n "$ROOT" ] || log Reconfigured
pankso@279 2762 else
pankso@344 2763 echo ""
pankso@344 2764 eval_gettext "Nothing to do for \$PACKAGE."; echo
erjo@56 2765 fi
erjo@56 2766 else
pankso@344 2767 echo ""
paul@349 2768 eval_gettext "Package \$PACKAGE is not installed."; echo
pankso@344 2769 gettext "Install package with 'tazpkg install' or 'tazpkg get-install'"; echo
pankso@344 2770 echo ""
pankso@309 2771 fi ;;
pankso@55 2772 shell)
pankso@55 2773 # Tazpkg SHell
pankso@55 2774 #
pankso@55 2775 if test $(id -u) = 0 ; then
pankso@55 2776 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
pankso@55 2777 else
pankso@55 2778 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
pankso@55 2779 fi
pankso@55 2780 if [ ! "$2" = "--noheader" ]; then
pankso@55 2781 clear
pankso@55 2782 echo ""
gokhlayeh@388 2783 echo -e "\033[1m`gettext \"Tazpkg SHell\"`.\033[0m"
pankso@55 2784 echo "================================================================================"
pankso@344 2785 gettext "Type 'usage' to list all available commands or 'quit' or 'q' to exit."; echo
pankso@55 2786 echo ""
pankso@55 2787 fi
pankso@55 2788 while true
pankso@55 2789 do
pankso@55 2790 echo -en "$PROMPT"; read cmd
pankso@55 2791 case $cmd in
pankso@55 2792 q|quit)
pankso@55 2793 break ;;
pankso@55 2794 shell)
pankso@344 2795 gettext "You are already running a Tazpkg SHell."; echo ;;
pankso@55 2796 su)
pankso@55 2797 su -c 'exec tazpkg shell --noheader' && break ;;
pankso@55 2798 "")
pankso@55 2799 continue ;;
pankso@55 2800 *)
pankso@55 2801 tazpkg $cmd ;;
pankso@55 2802 esac
pankso@309 2803 done ;;
pascal@205 2804 depends)
paul@247 2805 # Display dependencies tree
pascal@205 2806 cd $INSTALLED
pascal@205 2807 ALL_DEPS=""
pascal@205 2808 if [ -f $2/receipt ]; then
pascal@205 2809 dep_scan $2 ""
pankso@309 2810 fi ;;
pascal@205 2811 rdepends)
paul@247 2812 # Display reverse dependencies tree
pascal@205 2813 cd $INSTALLED
pascal@205 2814 ALL_DEPS=""
pascal@205 2815 if [ -f $2/receipt ]; then
pascal@260 2816 rdep_scan $2
pankso@309 2817 fi ;;
pascal@262 2818 convert)
pascal@262 2819 # convert misc package format to .tazpkg
pascal@263 2820 check_for_package_file
pascal@263 2821 case "$PACKAGE_FILE" in
pascal@262 2822 *.deb|*.udeb)
pascal@263 2823 convert_deb;;
pascal@264 2824 *.rpm)
pascal@264 2825 convert_rpm;;
pascal@275 2826 *.tgz)
pascal@275 2827 convert_tgz;;
pascal@404 2828 *.apk|*.pkg.tar.gz)
pascal@288 2829 convert_arch;;
pascal@296 2830 *.ipk|*.opk)
pascal@296 2831 convert_ipk;;
pascal@262 2832 *)
pankso@344 2833 gettext "Unsupported format"; echo ;;
pankso@309 2834 esac ;;
pascal@263 2835 link)
pascal@263 2836 # link a package from another slitaz installation
pascal@263 2837 PACKAGE=$2
pascal@263 2838 if [ ! -d "$TARGET_DIR" -o \
pascal@263 2839 ! -d "$TARGET_DIR$INSTALLED/$PACKAGE" ]; then
pascal@263 2840 cat <<EOT
pascal@263 2841 usage: tazpkg link package_name slitaz_root
paul@272 2842 example: 'tazpkg link openoffice /mnt' will use less than 100k in
pascal@263 2843 your ram running system.
pascal@263 2844 EOT
pascal@263 2845 exit 1
pascal@263 2846 fi
pascal@263 2847 if [ -e "$INSTALLED/$PACKAGE" ]; then
pankso@344 2848 eval_gettext "\$PACKAGE is already installed."; echo
pascal@263 2849 exit 1
pascal@263 2850 fi
pascal@263 2851 ln -s $TARGET_DIR$INSTALLED/$PACKAGE $INSTALLED
pascal@266 2852 DEPENDS="$(. $INSTALLED/$PACKAGE/receipt ; echo $DEPENDS)"
pascal@266 2853 MISSING=""
pascal@266 2854 for i in $DEPENDS; do
pascal@266 2855 [ -e $INSTALLED/$i ] && continue
pascal@266 2856 MISSING="$MISSING$i "
pankso@344 2857 eval_gettext "Missing : \$i"; echo
pascal@266 2858 done
pascal@266 2859 if [ -n "$MISSING" ]; then
pascal@266 2860 echo ""
gokhlayeh@388 2861 gettext "Link all missing dependencies"
gokhlayeh@388 2862 echo -n " (`translate_querry y`/`translate_querry N`) ? "
gokhlayeh@388 2863 read answer
pascal@266 2864 echo ""
gokhlayeh@388 2865 if [ "$answer" = "$(translate_querry y)" ]; then
pascal@266 2866 for i in $MISSING; do
pascal@266 2867 tazpkg link $i $TARGET_DIR
pascal@266 2868 done
pascal@266 2869 else
pankso@344 2870 echo ""
pankso@344 2871 eval_gettext "Leaving dependencies for \$PACKAGE unsolved."; echo
pankso@344 2872 gettext "The package is installed but will probably not work."; echo
pankso@344 2873 echo ""
pascal@266 2874 fi
pascal@266 2875 fi
pascal@266 2876 . $INSTALLED/$PACKAGE/receipt
pascal@266 2877 if grep -q ^pre_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2878 pre_install
pascal@266 2879 fi
pascal@263 2880 while read path; do
pascal@263 2881 [ -e $path ] && continue
pascal@263 2882 while true; do
pascal@263 2883 dir=$(dirname $path)
pascal@263 2884 [ -e $dir ] && break
pascal@263 2885 path=$dir
pascal@263 2886 done
pascal@263 2887 ln -s $TARGET_DIR$path $dir
pascal@263 2888 done < $INSTALLED/$PACKAGE/files.list
pascal@266 2889 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
pascal@266 2890 post_install
pankso@309 2891 fi ;;
pankso@6 2892 usage|*)
pascal@119 2893 # Print a short help or give usage for an unknown or empty command.
pankso@279 2894 usage ;;
pankso@6 2895 esac
pankso@6 2896
pankso@6 2897 exit 0