sup view libsup.sh @ rev 17

Some improvmend on the cosmetic side
author Christophe Lincoln <pankso@slitaz.org>
date Sun Feb 26 18:52:35 2017 +0100 (2017-02-26)
parents 90e556840716
children c0a780b534c2
line source
1 #!/bin/sh
2 #
3 # libsup.sh - Shared SHell functions between sup cmdline/gtk+ tools
4 #
5 # Copyright (C) 2017 SliTaz GNU/Linux - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
8 . /lib/libtaz.sh
10 bin="$HOME/.local/bin"
11 config="$HOME/.config"
12 cache="$HOME/.cache/sup"
13 data="$HOME/.local/share"
14 supdb="$data/sup"
15 installed="$supdb/installed"
16 activity="$cache/activity.log"
18 mirror="http://scn.slitaz.org/content/sup/packages"
19 md5list="$supdb/packages.md5"
20 pkgsdb="$supdb/packages.db"
22 wok="$supdb/wok"
23 supcook="$HOME/sup-cook"
24 cooked="$supcook/packages"
26 export TEXTDOMAIN='sup-clients'
27 alias wget="busybox wget"
29 #
30 # Functions
31 #
33 # Extract a sup package: extract_sup "/path/to/pkg.sup"
34 extract_sup() {
35 pkg="$(basename ${1%.sup})"
36 supfile="$(readlink -f ${1%.sup}.sup)"
38 gettext "Uncompressing package tree..."
39 rm -rf ${pkg} && mkdir -p ${pkg} && cd ${pkg}
41 cpio -idm --quiet < "$supfile"
42 unlzma -c files.lzma | cpio -idm --quiet
44 rm files.lzma
45 size="$(du -sh $dest | cut -d " " -f 1)"
46 status
47 }
49 # Install a sup package
50 install_sup() {
51 pkg="$(basename ${1%.sup})"
52 supfile="$(readlink -f ${1%.sup}.sup)"
53 cache="$cache/install"
55 rm -rf ${cache} && mkdir ${cache}
56 cp ${supfile} ${cache} && cd ${cache}
58 # Get receip for deps
59 cpio -i receip --quiet < ${supfile}
60 . receip
62 # Install sup deps || exit on missing system deps ?
63 newline
64 gettext "Checking dependencies for"; echo " $PACKAGE..."
65 for dep in ${SUP_DEPS}; do
66 if [ ! "$installed/$dep" ]; then
67 echo "Missing dependency:"; colorize 35 " $dep"
68 fi
69 done
70 . /etc/slitaz/slitaz.conf
71 for dep in ${DEPENDS}; do
72 if [ ! "$PKGS_DB/installed/$dep" ]; then
73 echo "Missing dependency:"; colorize 35 " $dep"
74 fi
75 done
77 newline
78 gettext "Installing package:"; colorize 36 " $PACKAGE $VERSION"
79 log "$(gettext 'Installing package:') $pkg"
80 separator
82 # Extract and source receip first to check deps
83 extract_sup "$supfile"
85 # Execute sup_install() in files/ tree so packages maintainers just
86 # have to dl and move files where they were in $HOME
87 cd files
88 if grep -q "^sup_install" ../receip; then
89 local in=$(($(stty size | cut -d " " -f 2) - 15))
90 gettext "Executing install function:"
91 indent ${in} $(colorize 33 " sup_install")
92 sup_install
93 fi
95 # Create files.list
96 if [ "$verbose" ]; then
97 gettext "Creating the list of installed files..."; echo
98 fi
99 files_list="${cache}/${PACKAGE}-${VERSION}/files.list"
100 find . -type f -print > ${files_list}
101 find . -type l -print >> ${files_list}
102 sed -i s/'^.'/''/g ${files_list}
104 # Back to pkg tree
105 cd ${cache}/${PACKAGE}-${VERSION}
106 echo "sup_size=\"$(du -sh files | cut -d " " -f 1)\"" >> receip
108 # Now we need a place to store package data and set $sup_size
109 gettext "Installing files to $HOME..."
110 data="${installed}/${PACKAGE}"
111 mkdir -p ${data}
112 for file in receip README files.list; do
113 [ -f "$file" ] && cp -f ${file} ${data}
114 done
115 for file in $(ls -A files); do
116 cp -rf files/${file} ${HOME}
117 done && status
118 separator
119 gettext "Installed files:"; colorize 35 " $(cat files.list | wc -l)"
120 newline && rm -rf ${cache}
121 }