# HG changeset patch # User Christophe Lincoln # Date 1337254411 -7200 # Node ID 5cba598bd418e9c1a8a6c968bae57416b6a77934 # Parent ee68829c1d604be608b9ae86a0f2f4f8dae2e060 spk-add: handle local packages and almost fix modified files check and display overwrited files diff -r ee68829c1d60 -r 5cba598bd418 lib/libspk.sh --- a/lib/libspk.sh Thu May 17 11:08:49 2012 +0200 +++ b/lib/libspk.sh Thu May 17 13:33:31 2012 +0200 @@ -46,6 +46,7 @@ extract_receipt() { local dir="$1" local file="$2" + debug "extract_receipt $1 $2" cd "$dir" { cpio --quiet -i receipt > /dev/null 2>&1; } < $file cd - >/dev/null @@ -99,6 +100,7 @@ local name="$1" if [ -d "$installed/$name" ]; then echo $(boldify "$name") $(gettext "package is already installed") + [ "$forced" ] || rm -rf $tmpdir continue fi } diff -r ee68829c1d60 -r 5cba598bd418 spk-add --- a/spk-add Thu May 17 11:08:49 2012 +0200 +++ b/spk-add Thu May 17 13:33:31 2012 +0200 @@ -11,6 +11,9 @@ tmpdir="/tmp/spk/$RANDOM" +# TODO: Handle packages.equiv: php dep on lighttpd, but id apache is installed +# we dont need lighttpd since apache is equivalent. + # # Functions # @@ -64,17 +67,11 @@ install_package() { local package_file=$1 - # Never used I think!!! # Set by receipt: pre_depends() DEPENDS SELF_INSTALL CONFIG_FILES post_install() - # Create package path early to avoid dependencies loop - mkdir -p $tmpdir - extract_receipt $tmpdir $package_file - source $tmpdir/receipt - local package_name=$PACKAGE local package_dir="$installed/$package_name" - mkdir -p $package_dir + mkdir -p $package_dir || exit 1 # Run pre_depends from receipt if it exists if grep -q ^pre_depends $tmpdir/receipt; then @@ -147,26 +144,29 @@ debug "check modified files" for file in $file_list do - local filegrep=$(grep ^${file}$ $installed/*/files.list) + local filegrep=$(egrep ^${file}$ $installed/*/files.list) if [ "$filegrep" ]; then local list=$(echo $filegrep | cut -d ":" -f 1) + local count=0 for pkg_file in $list; do local name=$(basename $(dirname $pkg_file)) - [ "$pkg" == "$name" ] && continue 2 - eval_gettext "Conflict package: \$name"; newline - # If confirm is set, ask to remove - if ! $confirm || gettext "Remove " && confirm; then - spk-rm $name - else - eval_gettext "Warning! /$file will be overwritten!"; newline - eval_gettext "If you remove /$package_name, be sure to reinstall $name"; newline + [ "$package_name" == "$name" ] && continue 2 + count=$(($count +1)) + [ "$count" == "1" ] && gettext "Modified package:"; \ + colorize " $name" 31 + gettext "Overwriting file:"; echo " $file" + # If confirm is set, ask to remove. Do we want that ? + # If gawk is installed for example we will never remove Busybox + # Use CONFLICTS receipt variable to avoid + if [ "$confirm" ]; then + echo -n "NOTE: confirm: spk-rm $name ???"; read fi done fi done cd $tmpdir || exit 1 - cp receipt files.list $package_dir + cp receipt files.list $package_dir || exit 1 # Copy the description if found. [ -f "description.txt" ] && cp description.txt $package_dir @@ -256,7 +256,22 @@ # Parameters: package_file install_local() { package_file="$1" - check_valid_tazpkg $package_file + #check_valid_tazpkg $package_file + if [ -f "$package_file" ]; then + if [ $(dirname $package_file) == "." ]; then + package_file=$(pwd)/$package_file + fi + debug "package file: $package_file" + else + gettext "Unable to find:"; echo " $package_file" + exit 1 + fi + + # Get package name now to check if installed + mkdir -p $tmpdir + extract_receipt $tmpdir $package_file + source $tmpdir/receipt + [ "$forced" ] || check_installed $PACKAGE install_package $package_file update_databases } @@ -299,6 +314,11 @@ newline && download "$package_full.tazpkg" fi + # Create package path early to avoid dependencies loop + mkdir -p $tmpdir + extract_receipt $tmpdir "$CACHE_DIR/$package_full.tazpkg" + source $tmpdir/receipt + install_package "$CACHE_DIR/$package_full.tazpkg" #[ "$AUTOEXEC" ] && chroot $root/ $package_name @@ -344,10 +364,11 @@ do case "$pkg" in *.tazpkg|*.spk) - [ "$forced" ] || check_installed $(package_name $package_file) - echo "Local package" - #install_local $pkg - ;; + #[ "$forced" ] || check_installed $(package_name $pkg) + install_local $pkg ;; + *.deb|.rmp) + echo "TODO: spk-convert then install" ;; + *.*) gettext "WARNING: Not a valid package:"; echo " $pkg" ;; --*) continue ;; *) [ "$forced" ] || check_installed $pkg