diff --git a/bin/xbps-src/main.sh b/bin/xbps-src/main.sh index 20f21446a3..3f31da60e0 100755 --- a/bin/xbps-src/main.sh +++ b/bin/xbps-src/main.sh @@ -37,7 +37,7 @@ trap "echo && exit 1" INT QUIT usage() { cat << _EOF -$progname: [-C] [-c ] +$progname: [-C] [-c ] [-u] Targets: build 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 diff --git a/shutils/fetch_funcs.sh b/shutils/fetch_funcs.sh index b7c4f2e2a2..718fec2382 100644 --- a/shutils/fetch_funcs.sh +++ b/shutils/fetch_funcs.sh @@ -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. #