slitaz-base-files annotate rootfs/usr/lib/slitaz/libpkg.sh @ rev 183

Add check_mirror_id() to libspk.sh (canbe used by sat, spk and tazpkg)
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 25 00:15:34 2012 +0200 (2012-05-25)
parents 021b49de9f37
children 32b585eb6cbe
rev   line source
pankso@152 1 #!/bin/sh
pankso@152 2 #
pankso@152 3 # SliTaz Packages base functions used by packages manager, cook and
pankso@152 4 # all tools dealing with packages and receipts.
pankso@152 5 #
pankso@152 6 # Documentation: man libpkg or /usr/share/doc/slitaz/libpkg.txt
pankso@152 7 #
pankso@152 8 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
pankso@152 9 #
pankso@152 10
pankso@152 11 # Unset all receipt variables.
pankso@152 12 unset_receipt() {
pankso@152 13 unset PACKAGE VERSION EXTRAVERSION SHORT_DESC HOST_ARCH TARBALL \
pankso@152 14 DEPENDS BUILD_DEPENDS WANTED WGET_URL PROVIDE CROSS_BUG
pankso@152 15 }
meshca@155 16
pankso@183 17 # Converts pkg.tazpkg to pkg
meshca@155 18 package_name() {
meshca@155 19 local name=$(basename $1)
meshca@155 20 echo ${name%.tazpkg}
meshca@155 21 }
meshca@155 22
pankso@183 23 # Check mirror ID: return false if no changes or mirror unreachable
pankso@183 24 check_mirror_id() {
pankso@183 25 [ "$forced" ] && rm -f ID
pankso@183 26 [ -f "ID" ] || echo $$ > ID
pankso@183 27 mv ID ID.bak
pankso@183 28 if wget -qs ${mirror%/}/ID; then
pankso@183 29 wget -q ${mirror%/}/ID
pankso@183 30 else
pankso@183 31 gettext "Mirror is unreachable"; false
pankso@183 32 status && return 1
pankso@183 33 fi
pankso@183 34 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
pankso@183 35 gettext "Mirror is up-to-date"; true
pankso@183 36 status && return 1
pankso@183 37 fi
pankso@183 38 }
pankso@183 39
pankso@181 40 #
pankso@181 41 # Do we realy need the code below here ???
pankso@181 42 #
pankso@181 43
meshca@155 44 # checks to see if file is proper tazpkg
meshca@155 45 is_valid_tazpkg() {
meshca@155 46 local file=$1
meshca@155 47 [ -a $file ] && [ "$file" != "$(package_name $file)" ]
meshca@155 48 }
meshca@155 49
meshca@155 50 check_valid_tazpkg() {
meshca@155 51 local file=$1
meshca@155 52 if ! is_valid_tazpkg $file; then
al@179 53 eval_gettext "\$file is not a tazpkg. Exiting"; newline
meshca@155 54 exit 1
meshca@155 55 fi
meshca@155 56 }