slitaz-base-files view rootfs/usr/lib/slitaz/libpkg.sh @ rev 185

libpkg.sh: Move source_receipt function in spk-ls to libpkg.sh. Source /lib/libtaz.sh in libpkg.sh so source_receipt function will work no matter what.
author Christopher Rogers <slaxemulator@gmail.com>
date Fri May 25 16:34:01 2012 +0000 (2012-05-25)
parents 32b585eb6cbe
children 1c8307dbe719
line source
1 #!/bin/sh
2 #
3 # SliTaz Packages base functions used by packages manager, cook and
4 # all tools dealing with packages and receipts.
5 #
6 # Documentation: man libpkg or /usr/share/doc/slitaz/libpkg.txt
7 #
8 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
9 #
11 . /lib/libtaz.sh
13 # Unset all receipt variables.
14 unset_receipt() {
15 unset PACKAGE VERSION EXTRAVERSION SHORT_DESC HOST_ARCH TARBALL \
16 DEPENDS BUILD_DEPENDS WANTED WGET_URL PROVIDE CROSS_BUG
17 }
19 # Converts pkg.tazpkg to pkg
20 package_name() {
21 local name=$(basename $1)
22 echo ${name%.tazpkg}
23 }
25 # Check mirror ID: return false if no changes or mirror unreachable
26 check_mirror_id() {
27 [ "$forced" ] && rm -f ID
28 [ -f "ID" ] || echo $$ > ID
29 mv ID ID.bak
30 if wget -qs ${mirror%/}/ID; then
31 wget -q ${mirror%/}/ID
32 else
33 gettext "Mirror is unreachable"; false
34 status && return 1
35 fi
36 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
37 gettext "Mirror is up-to-date"; true
38 status && return 1
39 fi
40 }
42 # Source a package receipt
43 source_receipt() {
44 local receipt=$1
45 if [ ! -f $receipt ]; then
46 echo -n $(colorize 31 "$pkg")
47 indent 28 $(gettext "missing receipt")
48 continue
49 else
50 . $receipt
51 fi
52 }
54 #
55 # Do we realy need the code below here ???
56 #
58 # checks to see if file is proper tazpkg
59 is_valid_tazpkg() {
60 local file=$1
61 [ -a $file ] && [ "$file" != "$(package_name $file)" ]
62 }
64 check_valid_tazpkg() {
65 local file=$1
66 if ! is_valid_tazpkg $file; then
67 echo -n "$file "
68 gettext "is not a tazpkg. Exiting"; newline
69 exit 1
70 fi
71 }