sup view libsup.sh @ rev 11

Tiny edits (receip -> receipt)
author Paul Issott <paul@slitaz.org>
date Sun Feb 26 10:04:31 2017 +0000 (2017-02-26)
parents ea32afc2e4da
children 90e556840716
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 #
27 # Functions
28 #
30 get() {
31 busybox wget "$1"
32 }
34 # Extract a sup package: extract_sup "/path/to/pkg.sup"
35 extract_sup() {
36 pkg="$(basename ${1%.sup})"
37 supfile="$(readlink -f ${1%.sup}.sup)"
39 gettext "Uncompressing package tree..."
40 rm -rf ${pkg} && mkdir -p ${pkg} && cd ${pkg}
42 cpio -idm --quiet < "$supfile"
43 unlzma -c files.lzma | cpio -idm --quiet
45 rm files.lzma
46 size="$(du -sh $dest | cut -d " " -f 1)"
47 status
48 }
50 # Install a sup package
51 install_sup() {
52 pkg="$(basename ${1%.sup})"
53 supfile="$(readlink -f ${1%.sup}.sup)"
54 cache="$cache/install"
56 rm -rf ${cache} && mkdir ${cache}
57 cp ${supfile} ${cache} && cd ${cache}
59 # Get receipt for deps
60 cpio -i receipt --quiet < ${supfile}
61 . receipt
63 # Install sup deps || exit on missing system deps ?
64 newline
65 gettext "Checking dependencies for"; echo " $PACKAGE..."
66 for dep in ${SUP_DEPS}; do
67 if [ ! "$installed/$dep" ]; then
68 echo "Missing dependency:"; colorize 35 " $dep"
69 fi
70 done
71 . /etc/slitaz/slitaz.conf
72 for dep in ${DEPENDS}; do
73 if [ ! "$PKGS_DB/installed/$dep" ]; then
74 echo "Missing dependency:"; colorize 35 " $dep"
75 fi
76 done
78 newline
79 gettext "Installing package:"; colorize 36 " $PACKAGE $VERSION"
80 log "$(gettext 'Installing package:') $pkg"
81 separator
83 # Extract and source receipt first to check deps
84 extract_sup "$supfile"
86 # Execute sup_install() in files/ tree so packages maintainers just
87 # have to dl and move files where they were in $HOME
88 cd files
89 if grep -q "^sup_install" ../receipt; then
90 gettext "Executing install function:"; colorize 33 " sup_install"
91 sup_install
92 fi
94 # Create files.list
95 if [ "$verbose" ]; then
96 gettext "Creating the list of installed files..."; echo
97 fi
98 files_list="${cache}/${PACKAGE}-${VERSION}/files.list"
99 find . -type f -print > ${files_list}
100 find . -type l -print >> ${files_list}
101 sed -i s/'^.'/''/g ${files_list}
103 # Back to pkg tree
104 cd ${cache}/${PACKAGE}-${VERSION}
105 echo "sup_size=\"$(du -sh files | cut -d " " -f 1)\"" >> receipt
107 # Now we need a place to store package data and set $sup_size
108 gettext "Installing files to $HOME..."
109 data="${installed}/${PACKAGE}"
110 mkdir -p ${data}
111 for file in receipt README files.list; do
112 [ -f "$file" ] && cp -f ${file} ${data}
113 done
114 for file in $(ls -A files); do
115 cp -rf files/${file} ${HOME}
116 done && status
117 rm -rf ${cache} && separator && newline
118 }