3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
6 # T2 SDE: scripts/Create-CkSumPatch
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 .
scripts
/functions.
in
25 echo "scripts/Create-CkSumPatch [options] <package-name>"
26 echo "scripts/Create-CkSumPatch [options] <target-name>"
27 echo "scripts/Create-CkSumPatch [options] <file-path>"
30 echo " -override Create new cksum if old one should be valid."
36 -override) override
=1; shift ;;
37 -repository) files
="$files `echo package/$2/*/*.desc`"; shift; shift ;;
40 target
/*) files
="$files $arg"; shift ;;
41 *.desc
) files
="$files $arg"; shift ;;
42 *) files
="$files `echo package/*/$1/$1.desc`"; shift ;;
46 # cksum_file path-to-desc-or-target-file
51 sedscript
='s,^[^ ]* *$file,$newcksum $file,'
54 has_D
='fgrep "[D]" | sed "s/[[]D[^ ]*//"'
55 sedscript
='s,\[D\] *[^ ]* *$file,[D] $newcksum $file,'
58 echo "!!! File type not recognized" >&2
62 if [ ! -f "$1" ]; then
63 echo "!!! File not found: $1" >&2
68 eval "egrep -v '^#' $1 | $has_D" |
while read cksum file url args
; do
69 [ "$cksum" = 'X' ] && continue
70 [ "$cksum" != '0' -a "$override" = '0' ] && continue
72 gzfile
=`source_file cksum $file $url $flags`
73 bzfile
="`bz2filename "$gzfile"`"
74 if [ ! -f "$bzfile" ]; then
75 echo "!!! File not present: $bzfile" >&2
80 if [[ "$bzfile" = *.zst
]] ||
[[ "$bzfile" = *.tzst
]]; then
81 echo -n "$bzfile (zstd): " >&2
82 newcksum
="`zstd -d < $bzfile | ${ck}sum | cut -f1 -d' '`"
84 echo -n "$gzfile (raw): " >&2
85 newcksum
="`${ck}sum $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