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

libtaz.sh: add (and use) short gettext aliases: _ and _n
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Aug 09 15:38:43 2013 +0300 (2013-08-09)
parents d4df77afbed6
children 793c2b7ed97f
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 _n "Mirror is unreachable"; false
34 status && return 1
35 fi
36 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
37 _n "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 indent 28 $(_ 'Missing receipt: $receipt')
47 continue
48 else
49 . $receipt
50 fi
51 }
53 #
54 # Do we realy need the code below here ???
55 #
57 # checks to see if file is proper tazpkg
58 is_valid_tazpkg() {
59 local file=$1
60 [ -a $file ] && [ "$file" != "$(package_name $file)" ]
61 }
63 check_valid_tazpkg() {
64 local file=$1
65 if ! is_valid_tazpkg $file; then
66 _ '$file is not a tazpkg. Exiting'
67 exit 1
68 fi
69 }