tazpkg view modules/summary @ rev 944

modules/summary: fix $((arithmetic))
Busybox ash vs. Bash problem?
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Feb 22 04:05:32 2017 +0200 (2017-02-22)
parents a02e36d44d06
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # summary - TazPkg module
4 # Show TazPkg summary
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 STATE=$(mktemp)
18 title "$(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))"
20 # Per-repository stuff
22 if [ -h "$PKGS_DB/fslink" ]; then
23 if [ -e "$PKGS_DB/fslink/etc/slitaz/slitaz.conf" ]; then
24 PKGS_DB_LINK="$PKGS_DB/fslink/$(. "$PKGS_DB/fslink/etc/slitaz/slitaz.conf"; echo "$PKGS_DB")"
25 fi
26 fi
28 for path in $PKGS_DB $PKGS_DB/undigest/* $PKGS_DB_LINK; do
29 [ ! -e "$path" ] && continue
30 case "$path" in
31 $PKGS_DB) repo_name='Main';;
32 */fslink/*) repo_name=$(readlink "$PKGS_DB/fslink");;
33 *) repo_name=$(_n 'Undigest %s' "$(basename "$path")");;
34 esac
36 newline; colorize 33 "$(_n 'Repository:'; echo -e "\t$repo_name")"
38 _n 'Last recharge:'; echo -en '\t'
39 IDs="$path/IDs"
40 if [ -e "$IDs" ]; then
41 # Timezone offset as string, ex. '+0200' for EET (+2 hours)
42 ohhmm=$(date +%z)
43 # offset sign (1; -1)
44 osign="${ohhmm:0:1}1"; osign=${osign#+}
45 # offset hours (without leading 0)
46 ohh=${ohhmm:1:2}; ohh=${ohh#0}
47 # offset minutes (without leading 0)
48 omm=${ohhmm:3:2}; omm=${omm#0}
49 # Timezone offset in the seconds
50 offset=$(( 60 * (60 * $osign * $ohh + $omm) ))
52 daynow=$(( ($(date +%s) + $offset) / 86400 ))
53 dayupd=$(( ($(date -r $IDs +%s) + $offset) / 86400 ))
54 days=$(( $daynow - $dayupd ))
55 time=$(date -r $IDs +%R)
56 case $days in
57 0) _ 'Today at %s.' "$time";;
58 1) _ 'Yesterday at %s.' "$time";;
59 *) _p '%d day ago.' '%d days ago.' "$days" "$days"; newline;;
60 esac
62 _n 'Database timestamp:'; echo -en '\t'
63 date -d "@$(awk '{print $2}' "$IDs")" "+%x %R"
64 else
65 _ 'never.'
66 fi
68 if [ -e "$path/packages.info" ]; then
69 _n 'Mirrored packages:'; echo -en '\t'; wc -l < "$path/packages.info"
70 fi
72 if [ "${path/fslink/}" != "$path" ]; then
73 _n 'Linked packages:'; echo -en '\t'
74 find "$INSTALLED" -type l | wc -l
75 fi
76 done >> "$STATE"
78 # Common stuff
80 optlist "\
81 $(_ 'Installed packages:') $(wc -l < "$PKGS_DB/installed.info")
82 $(_ 'Installed files:') $( (cat $INSTALLED/*/files.list | wc -l) 2>/dev/null || echo 0)
83 $(_ 'Blocked packages:') $(wc -l < "$BLOCKED")
84 $(_ 'Upgradeable packages:') $(wc -l < "$UP_LIST")
85 $(cat "$STATE")"
86 footer
88 rm "$STATE"