spk rev 34
spk-add: use lower case interanal var, use $root, show install path
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue May 15 21:03:40 2012 +0200 (2012-05-15) |
parents | fca271e55b69 |
children | d703999f686b |
files | lib/libspk.sh spk-add |
line diff
1.1 --- a/lib/libspk.sh Tue May 15 20:44:37 2012 +0200 1.2 +++ b/lib/libspk.sh Tue May 15 21:03:40 2012 +0200 1.3 @@ -156,7 +156,7 @@ 1.4 fi 1.5 1.6 echo -n "$(colorize "$deps" 34) " 1.7 - gettext "missing dep(s) to install."; newline 1.8 + gettext "missing dep(s) to install..."; newline 1.9 1.10 # Return true if missing deps 1.11 [ "$deps" != "0" ]
2.1 --- a/spk-add Tue May 15 20:44:37 2012 +0200 2.2 +++ b/spk-add Tue May 15 21:03:40 2012 +0200 2.3 @@ -9,10 +9,8 @@ 2.4 #. /usr/lib/slitaz/libspk.sh 2.5 . lib/libspk.sh 2.6 2.7 -# Set to / for now until we add installing to chroot support 2.8 -# Could we update tools so they do not need this? 2.9 -ROOT="" 2.10 -TMP_DIR="/tmp/$RANDOM" 2.11 + 2.12 +tmpdir="/tmp/$RANDOM" 2.13 2.14 # 2.15 # Functions 2.16 @@ -40,24 +38,24 @@ 2.17 2.18 # Update system databases 2.19 update_databases() { 2.20 - if [ -f $ROOT/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then 2.21 - chroot "$ROOT/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null 2.22 + if [ -f $root/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then 2.23 + chroot "$root/" /usr/bin/update-desktop-database /usr/share/applications 2>/dev/null 2.24 fi 2.25 # Mimetypes 2.26 - if [ -f $ROOT/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then 2.27 - chroot "$ROOT/" /usr/bin/update-mime-database /usr/share/mime 2.28 + if [ -f $root/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then 2.29 + chroot "$root/" /usr/bin/update-mime-database /usr/share/mime 2.30 fi 2.31 # Icons 2.32 - if [ -f $ROOT/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then 2.33 - chroot "$ROOT/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor 2.34 + if [ -f $root/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then 2.35 + chroot "$root/" /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor 2.36 fi 2.37 # Glib schemas 2.38 - if [ -f $ROOT/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then 2.39 - chroot "$ROOT/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 2.40 + if [ -f $root/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then 2.41 + chroot "$root/" /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas 2.42 fi 2.43 # Kernel modules 2.44 - if [ -f $ROOT/sbin/depmod ] && [ -n "$updatedepmod" ]; then 2.45 - chroot "$ROOT/" /sbin/depmod -a 2.46 + if [ -f $root/sbin/depmod ] && [ -n "$updatedepmod" ]; then 2.47 + chroot "$root/" /sbin/depmod -a 2.48 fi 2.49 } 2.50 2.51 @@ -70,17 +68,17 @@ 2.52 # Set by receipt: pre_depends() DEPENDS SELF_INSTALL CONFIG_FILES post_install() 2.53 2.54 # Create package path early to avoid dependencies loop 2.55 - mkdir -p $TMP_DIR 2.56 - extract_receipt $TMP_DIR $package_file 2.57 - source $TMP_DIR/receipt 2.58 + mkdir -p $tmpdir 2.59 + extract_receipt $tmpdir $package_file 2.60 + source $tmpdir/receipt 2.61 2.62 local package_name=$PACKAGE 2.63 local package_dir="$installed/$package_name" 2.64 mkdir -p $package_dir 2.65 2.66 # Run pre_depends from receipt if it exists 2.67 - if grep -q ^pre_depends $TMP_DIR/receipt; then 2.68 - pre_depends $ROOT 2.69 + if grep -q ^pre_depends $tmpdir/receipt; then 2.70 + pre_depends $root 2.71 fi 2.72 2.73 # Create modifiers and files.list if they do not exist 2.74 @@ -100,14 +98,14 @@ 2.75 fi 2.76 2.77 newline 2.78 - boldify $(gettext "Installation of :") $package_name 2.79 + boldify $(gettext "Installation of:") $package_name 2.80 separator 2.81 - eval_gettext "Copying \$package_name... " 2.82 - cp $package_file $TMP_DIR 2.83 + gettext "Copying"; echo -n " $package_name..." 2.84 + cp $package_file $tmpdir 2.85 status 2.86 2.87 # Extract Package 2.88 - cd $TMP_DIR || exit 1 2.89 + cd $tmpdir || exit 1 2.90 rm receipt 2.91 spk-archive extract $package_file 2.92 cd - >/dev/null 2.93 @@ -117,7 +115,7 @@ 2.94 if [ -f $package_dir/files.list ]; then 2.95 for file in $(cat $package_dir/files.list) 2.96 do 2.97 - grep -q "^$(echo $file | grepesc)$" $TMP_DIR/files.list && continue 2.98 + grep -q "^$(echo $file | grepesc)$" $tmpdir/files.list && continue 2.99 local modifiers=$(cat $package_dir/modifiers 2> /dev/null; \ 2.100 fgrep -sl $package_dir */modifiers | cut -d/ -f1) 2.101 for i in modifiers; do 2.102 @@ -130,16 +128,17 @@ 2.103 local check=false 2.104 local file_list 2.105 # Create list of all possibly modified files 2.106 - for i in $(fgrep -v [ $TMP_DIR/files.list); do 2.107 - [ -e "$ROOT$i" ] || continue 2.108 - [ -d "$ROOT$i" ] && continue 2.109 + for i in $(fgrep -v [ $tmpdir/files.list); do 2.110 + [ -e "${root}${i}" ] || continue 2.111 + [ -d "${root}${i}" ] && continue 2.112 file_list="$file_list $i" 2.113 check=true 2.114 done 2.115 2.116 # Check possibly modified files against other packages file.list 2.117 if $check; then 2.118 - for pkg in $installed/*; do 2.119 + for pkg in $installed/* 2.120 + do 2.121 [ "$pkg" == "$package_name" ] && continue 2.122 [ -s $pkg/files.list ] || continue 2.123 2.124 @@ -147,7 +146,8 @@ 2.125 # $package_name wants to install $file which is already 2.126 # installed from $pkg 2.127 if grep -q ^$file$ $pkg/files.list; then 2.128 - # Tell $pkg that $package_name is going to overwrite some of its files 2.129 + # Tell $pkg that $package_name is going to overwrite some 2.130 + # of its files 2.131 if [ -s "$pkg/volatile.cpio.gz" ]; then 2.132 # We can modify backed up files without notice 2.133 zcat $pkg/volatile.cpio.gz | cpio -t --quiet | \ 2.134 @@ -164,7 +164,7 @@ 2.135 done 2.136 fi 2.137 2.138 - cd $TMP_DIR || exit 1 2.139 + cd $tmpdir || exit 1 2.140 cp receipt files.list $package_dir 2.141 2.142 # Copy the description if found. 2.143 @@ -172,7 +172,7 @@ 2.144 2.145 # Pre install commands. 2.146 if grep -q ^pre_install $package_dir/receipt; then 2.147 - pre_install $ROOT 2.148 + pre_install $root 2.149 fi 2.150 2.151 # Handle Config Files from receipt 2.152 @@ -186,20 +186,21 @@ 2.153 confs="$confs $(find ${i#/} -type f 2> /dev/null)" 2.154 done 2.155 2.156 - echo $confs | cpio -o -H newc --quiet | gzip -9 > $package_dir/volatile.cpio.gz 2.157 + echo $confs | cpio -o -H newc --quiet | gzip -9 > \ 2.158 + $package_dir/volatile.cpio.gz 2.159 2.160 # keep user configuration files 2.161 - for conf_file in $confs; do 2.162 - [ -e $conf_file ] || continue 2.163 - cp -a $conf_file fs/$conf_file 2.164 + for configfile in $confs; do 2.165 + [ -e $configfile ] || continue 2.166 + cp -a $configfile fs/$configfile 2.167 done 2.168 status 2.169 cd - >/dev/null 2.170 fi 2.171 2.172 # Merge ROOT_FS with Package FS 2.173 - gettext "Installing"; echo -n " $package_name..." 2.174 - cp -a fs/* $ROOT/ 2.175 + gettext "Installing in:"; echo -n " $root/" 2.176 + cp -a fs/* $root/ 2.177 status 2.178 2.179 # Remove old config files 2.180 @@ -217,12 +218,12 @@ 2.181 2.182 # Remove the temporary directory. 2.183 gettext "Removing all tmp files... " 2.184 - rm -rf $TMP_DIR 2.185 + rm -rf $tmpdir 2.186 status 2.187 2.188 # Post install commands. 2.189 if grep -q ^post_install $package_dir/receipt; then 2.190 - post_install $ROOT 2.191 + post_install $root 2.192 fi 2.193 2.194 # Update-desktop-database if needed. 2.195 @@ -281,7 +282,7 @@ 2.196 2.197 cd $CACHE_DIR > /dev/null 2.198 if [ -f "$package_full.tazpkg" ]; then 2.199 - echo -n "$(colorize "$package_full" 34)"; echo ": $CACHE_DIR)" 2.200 + echo -n "$(colorize "$package_full" 34)"; echo ": $CACHE_DIR" 2.201 # Check package download was finished 2.202 if ! tail -c 2k $package_full.tazpkg | fgrep -q 00000000TRAILER; then 2.203 eval_gettext "Continuing \$package_name download"; newline 2.204 @@ -299,7 +300,7 @@ 2.205 2.206 install_package "$CACHE_DIR/$package_full.tazpkg" 2.207 2.208 - [ -n "$AUTOEXEC" ] && $package_name $ROOT 2.209 + [ -n "$AUTOEXEC" ] && $package_name $root 2.210 update_databases 2.211 } 2.212