xbps-src: add -u flag, if used with fetch update $checksum in tmpl file.

--HG--
extra : convert_revision : a11fe9147498fb4a60ecb2633493d2d4789c288d
This commit is contained in:
Juan RP 2009-02-09 01:01:14 +01:00
parent 807d8feb14
commit 4a4f70b005
2 changed files with 21 additions and 3 deletions

View file

@ -37,7 +37,7 @@ trap "echo && exit 1" INT QUIT
usage()
{
cat << _EOF
$progname: [-C] [-c <config_file>] <target> <pkg>
$progname: [-C] [-c <config_file>] [-u] <target> <pkg>
Targets:
build <pkg> Build a package (fetch + extract + configure + build).
@ -68,6 +68,7 @@ Options:
-C Do not remove build directory after successful installation.
-c Path to global configuration file:
if not specified @@XBPS_INSTALL_ETCDIR@@/xbps.conf is used.
-u Update the checksum in template file if used in 'fetch' target.
_EOF
exit 1
}
@ -158,10 +159,11 @@ check_config_vars()
#
# main()
#
while getopts "Cc:" opt; do
while getopts "Cc:u" opt; do
case $opt in
C) dontrm_builddir=yes;;
c) config_file_specified=yes; XBPS_CONFIG_FILE="$OPTARG";;
u) update_checksum=yes;;
--) shift; break;;
esac
done
@ -243,7 +245,7 @@ extract|fetch|info)
fi
if [ "$target" = "fetch" ]; then
. $XBPS_SHUTILSDIR/fetch_funcs.sh
fetch_distfiles $2
fetch_distfiles $2 $update_checksum
exit $?
fi
. $XBPS_SHUTILSDIR/extract_funcs.sh

View file

@ -42,12 +42,22 @@ verify_sha256_cksum()
msg_normal "SHA256 checksum OK for $file."
}
fetch_update_cksum()
{
local tmpl="$XBPS_TEMPLATESDIR/$pkgname/template"
local upcmd=$(basename $XBPS_SRCDISTDIR/$1)
sed -i -e "s|checksum.*|checksum=$(xbps-digest ${upcmd})|" $tmpl
return $?
}
#
# Downloads the distfiles and verifies checksum for all them.
#
fetch_distfiles()
{
local pkg="$1"
local upcksum="$2"
local dfiles=
local localurl=
local dfcount=0
@ -106,6 +116,12 @@ fetch_distfiles()
fi
else
unset localurl
if [ -n "$upcksum" ]; then
fetch_update_cksum $f
break
fi
#
# XXX duplicate code.
#