3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-CkSumPatch
5 # Copyright (C) 2004 - 2023 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 .
scripts
/functions.
in
21 echo "scripts/Create-CkSumPatch [options] <package-name>"
22 echo "scripts/Create-CkSumPatch [options] <target-name>"
23 echo "scripts/Create-CkSumPatch [options] <file-path>"
26 echo " -override Create new cksum if old one should be valid."
32 -override) override
=1; shift ;;
33 -repository) files
="$files `echo package/$2/*/*.desc`"; shift; shift ;;
34 -*|
-help) usage
; exit ;;
35 *.desc|target
/*) files
="$files $1"; shift ;;
36 *) files
="$files `echo package/*/$1/$1.desc`"; shift ;;
40 # cksum_file path-to-desc-or-target-file
45 sedscript
='s,^[^ ]* *$file,$newcksum $file,'
48 has_D
='fgrep "[D]" | sed "s/[[]D[^ ]*//"'
49 sedscript
='s@\[D\] *[^ ]* *$file@[D] $newcksum $file@'
52 echo "!!! File type not recognized" >&2
56 if [ ! -f "$1" ]; then
57 echo "!!! File not found: $1" >&2
62 eval "egrep -v '^#' $1 | $has_D" |
while read cksum file url args
; do
63 [ "$cksum" = 'X' ] && continue
64 [ "$cksum" != '0' -a "$override" = '0' ] && continue
66 gzfile
=`source_file cksum $file $url $flags`
67 if [ ! -f "$gzfile" ]; then
68 echo "!!! File not present: $gzfile" >&2
74 if ! type -p $cksum2 > /dev
/null
; then
75 cksum2
=${cksum2#sha} cksum2
=${cksum2%sum}
76 cksum2
="shasum -a $cksum2"
79 local compressor
="$(get_compressor "$gzfile")"
80 if [ "$compressor" ]; then
81 echo -n "$gzfile (${compressor%% *}): " >&2
82 newcksum
="`$compressor < $gzfile | $cksum2 | cut -f1 -d' '`"
84 echo -n "$gzfile (raw): " >&2
85 newcksum
="`$cksum2 $gzfile | cut -f1 -d' '`"
87 newcksum
="$newcksum" # also support explict {$ck}
90 if [ "$cksum" != 0 -a "$cksum" != "$newcksum" ]; then
91 echo "!!! Checksum of $file changed (was $cksum)." >&2
94 eval "sed \"$sedscript\" -i /tmp/$$"
101 echo "Creating cksum.patch ..." >&2