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

View File

@ -42,12 +42,22 @@ verify_sha256_cksum()
msg_normal "SHA256 checksum OK for $file." 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. # Downloads the distfiles and verifies checksum for all them.
# #
fetch_distfiles() fetch_distfiles()
{ {
local pkg="$1" local pkg="$1"
local upcksum="$2"
local dfiles= local dfiles=
local localurl= local localurl=
local dfcount=0 local dfcount=0
@ -106,6 +116,12 @@ fetch_distfiles()
fi fi
else else
unset localurl unset localurl
if [ -n "$upcksum" ]; then
fetch_update_cksum $f
break
fi
# #
# XXX duplicate code. # XXX duplicate code.
# #