sup rev 45
Improve update
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Mar 10 08:57:55 2017 +0100 (2017-03-10) |
parents | d86e4e894a97 |
children | 36795f3c1ef3 |
files | libsup.sh sup |
line diff
1.1 --- a/libsup.sh Fri Mar 10 00:00:36 2017 +0100 1.2 +++ b/libsup.sh Fri Mar 10 08:57:55 2017 +0100 1.3 @@ -98,7 +98,7 @@ 1.4 # System dependencies: exit on missing system deps ? 1.5 check_sys_deps() { 1.6 . /etc/slitaz/slitaz.conf # PKGS_DB 1.7 - for dep in ${DEPENDS}; do 1.8 + for dep in ${@}; do 1.9 if [ ! -d "$PKGS_DB/installed/$dep" ]; then 1.10 gettext "Missing dependency:"; colorize 31 " $dep"; return 1 1.11 fi 1.12 @@ -129,7 +129,7 @@ 1.13 sup -i "$dep" 1.14 fi 1.15 done 1.16 - check_sys_deps 1.17 + check_sys_deps "$DEPENDS" 1.18 1.19 # Remove existing package files to avoid untracked files 1.20 if [ -d "$installed/$PACKAGE" ]; then 1.21 @@ -161,14 +161,16 @@ 1.22 gettext "Creating the list of installed files..."; echo 1.23 fi 1.24 files_list="${cache}/install/${PACKAGE}-${VERSION}/files.list" 1.25 + cd ${cache}/install/${PACKAGE}-${VERSION}/files 1.26 find . -type f -print > ${files_list} 1.27 find . -type l -print >> ${files_list} 1.28 - sed -i sed s'/^.//'g ${files_list} 1.29 + sed -i s'/^.//'g ${files_list} 1.30 1.31 # Back to pkg tree 1.32 cd ${cache}/install/${PACKAGE}-${VERSION} 1.33 echo "sup_size=\"$(du -sh files | cut -d " " -f 1)\"" >> receip 1.34 echo "md5_sum=\"${md5sum}\"" >> receip 1.35 + separator "-" 1.36 1.37 # Now we need a place to store package data and set $sup_size 1.38 echo -n "$(colorize 036 $(gettext 'Installing files:'))"
2.1 --- a/sup Fri Mar 10 00:00:36 2017 +0100 2.2 +++ b/sup Fri Mar 10 08:57:55 2017 +0100 2.3 @@ -30,12 +30,12 @@ 2.4 $(boldify $(gettext "Usage:")) $(basename $0) [command|package] [package] 2.5 2.6 $(boldify $(gettext "Commands:")) 2.7 - -c cook $(gettext "Cook a package from the wok") 2.8 - -r run $(gettext "Run sup_install without installing") 2.9 - -e extract $(gettext "Extract a package to current dir") 2.10 -i install $(gettext "Install a new package") 2.11 -u update $(gettext "Update installed package") 2.12 -r remove $(gettext "Remove an installed package") 2.13 + -c cook $(gettext "Cook a package from the wok") 2.14 + run $(gettext "Run sup_install without installing") 2.15 + -e extract $(gettext "Extract a package to current dir") 2.16 -n new $(gettext "Create a new SUP package :-)") 2.17 -l list $(gettext "List packages: installed/wok/db") 2.18 -s search $(gettext "Search for packages in the database") 2.19 @@ -172,7 +172,7 @@ 2.20 echo "$(gettext 'Packages:') $(colorize 035 $supfile) ($size)" 2.21 rm -rf ${cache} && newline ;; 2.22 2.23 - -r|run) 2.24 + run) 2.25 # Run sup_install() without any installation to help package creation 2.26 pkg="$2" 2.27 receip="$wok/$pkg/receip" 2.28 @@ -292,10 +292,10 @@ 2.29 gettext "Checking packages.sql..." 2.30 db_sum=$(wget -q "${server}?sup=dbsum" -O -) 2.31 if echo "$db_sum $pkgsdb" | md5sum -s -c -; then 2.32 - indent $(($(tty_size) - 13)) "[ $(colorize 036 synced) ]" 2.33 + info 036 "synced" 2.34 else 2.35 [ "$online" ] && rm -f ${pkgsdb} 2.36 - indent $(($(tty_size) - 13)) "[ $(colorize 035 update) ]" 2.37 + info 035 "update" 2.38 fi 2.39 2.40 # --force 2.41 @@ -310,7 +310,12 @@ 2.42 | awk '{printf $1 " " $2}') 2.43 gettext "Database timestamp:" 2.44 indent $(($(tty_size) - 23)) "[ $(colorize 30 $timestamp) ]" 2.45 - log "$(gettext 'Updated packages database: $timestamp') " 2.46 + log "$(gettext 'Updated packages database:') $timestamp" 2.47 + fi 2.48 + 2.49 + # Exit now if no packages.sql 2.50 + if [ ! -f "$pkgsdb" ]; then 2.51 + gettext "Please try later. Missing packages database"; echo; exit 1 2.52 fi 2.53 2.54 # Scan installed packages 2.55 @@ -319,34 +324,40 @@ 2.56 in=$((7 + ${char})) 2.57 2.58 gettext "Installed packages:" 2.59 - indent $(($(tty_size) - ${in})) "[ $(colorize 033 $count) ]" 2.60 - cat << EOT 2.61 + info 033 "$count"; newline 2.62 + echo -n $(boldify $(gettext "Package") $(indent 30 $(gettext "Version"))) 2.63 + info 40 $(gettext "Status") 2.64 + separator "-" 2.65 2.66 -$(boldify $(gettext "Package") $(indent 30 $(gettext "Version")) \ 2.67 -$(indent 60 $(gettext "Status"))) 2.68 -$(separator "-") 2.69 -EOT 2.70 for pkg in $(ls $installed) 2.71 do 2.72 . ${installed}/${pkg}/receip 2.73 - db_sum=$(sqlite3 ${pkgsdb} \ 2.74 - "SELECT md5sum FROM pkgs WHERE name = '$pkg'") 2.75 2.76 - # MD5sum not matching: new version our new build ? 2.77 - if [ "$md5_sum" != "$db_sum" ]; then 2.78 - 2.79 - vers=$(sqlite3 ${pkgsdb} \ 2.80 - "SELECT version FROM pkgs WHERE name = '$pkg'") 2.81 + name=$(sqlite3 ${pkgsdb} \ 2.82 + "SELECT name FROM pkgs WHERE name = '$pkg'") 2.83 + if [ ! "$name" ]; then 2.84 + #echo -n "$pkg $(indent 30 $VERSION)" 2.85 + #info 036 "$(gettext "local")" 2.86 + continue 2.87 + else 2.88 + db_sum=$(sqlite3 ${pkgsdb} \ 2.89 + "SELECT md5sum FROM pkgs WHERE name = '$pkg'") 2.90 2.91 - if [ "$VERSION" != "$vers" ]; then 2.92 - status="$(colorize 032 $(gettext "update") )" 2.93 - else 2.94 - status="$(colorize 035 $(gettext "rebuilt"))" 2.95 + # MD5sum not matching: new version our new build ? 2.96 + if [ "$md5_sum" != "$db_sum" ]; then 2.97 + echo -n "$pkg $(indent 30 $VERSION)" 2.98 + vers=$(sqlite3 ${pkgsdb} \ 2.99 + "SELECT version FROM pkgs WHERE name = '$pkg'") 2.100 + 2.101 + if [ "$VERSION" != "$vers" ]; then 2.102 + info 032 "$(gettext "$vers")" 2.103 + else 2.104 + info 035 "$(gettext "rebuilt")" 2.105 + fi 2.106 + echo "$pkg" >> ${cache}/updates 2.107 fi 2.108 - echo "$pkg $(indent 30 $VERSION) $(indent 60 $status)" 2.109 - echo "$pkg" >> ${cache}/updates 2.110 fi 2.111 - 2.112 + unset name db_sum vers 2.113 done 2.114 2.115 if [ -f "$cache/updates" ]; then