From 27c8e5a50735566920c6fea8b80ed6101afb9914 Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Thu, 17 Jan 2008 11:18:49 +0000 Subject: [PATCH] Stefan Fiedler: scripts/Download: make -cksumpatch option work for more types of downloads, e.g.: ./scripts/Download -cksumpatch -cfg crystal -required [2007111817132432224] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8926 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- scripts/Download | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/scripts/Download b/scripts/Download index 99fab6be9..fa916d68b 100755 --- a/scripts/Download +++ b/scripts/Download @@ -361,6 +361,25 @@ is_static() { return 0 } +# Create a checksum patch for a package or target if requested +# +create_cksumpatch () { + local repo="$1" pkg="$2" + + if [ $cksumpatch = 1 ] ; then + if [ "$pkg" ] ; then + # patch for a package + ./scripts/Create-CkSumPatch $pkg | patch -p0 + else + # patch for a target download + for x in target/$repo/{,*/}download.txt ; do + [ -f "$x" ] && echo "$x" + done | xargs ./scripts/Create-CkSumPatch $x \ + | patch -p0 + fi + fi +} + # download_file local-filename download-location cksum repo pkg # # This function decides if download directly or from a mirror, @@ -368,7 +387,6 @@ is_static() { # Calls download_file_now to do the actual download. # download_file() { - # Init # local gzfile="$1" location="$2" cksum="$3" repo="$4" pkg="$5" @@ -381,7 +399,10 @@ download_file() { # Check if it's already there # - [ -s "$bzfile" -a $checkonly != 1 ] && return 0 + if [ -s "$bzfile" -a $checkonly != 1 ] ; then + create_cksumpatch $repo $pkg + return 0 + fi # Make locking # @@ -410,11 +431,9 @@ download_file() { fi elif [ -s "$gzfile" ] ; then - echo ; echo "Already downloaded $gzfile ..." else - echo ; echo "Downloading $gzfile ..." # Existing *.cksum-err @@ -553,6 +572,10 @@ download_file() { cksum_chk "$gzfile" $cksum "$gzfile" fi + # Calculate missing checksums if requested + # + create_cksumpatch $repo $pkg + # Free Lock and finish # rm -f "$lkfile" ; trap INT ; return 0 @@ -992,10 +1015,6 @@ packages() { "$url" "$cksum" "$repo" "$pkg" done < <(descparser $forkedpkg package/$repo/$pkg/$pkg.desc | grep '^\[D\] ') - - if [ $cksumpatch = 1 ]; then - ./scripts/Create-CkSumPatch $pkg | patch -p0 - fi ;; esac done