* updated kolourpaint (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / scripts / Create-CkSumPatch
blobe8eab10a46c9903f9de9cb5eb9d1967580d37046
1 #!/bin/bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 #
6 # T2 SDE: scripts/Create-CkSumPatch
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
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
19 override=0
20 files=''
22 usage()
24 echo "Usage:"
25 echo "scripts/Create-CkSumPatch [options] <package-name>"
26 echo "scripts/Create-CkSumPatch [options] <target-name>"
27 echo "scripts/Create-CkSumPatch [options] <file-path>"
28 echo " "
29 echo "Options:"
30 echo " -override Create new cksum if old one should be valid."
31 echo " -help This."
34 while [ "$1" ]; do
35 case "$1" in
36 -override) override=1; shift ;;
37 -repository) files="$files `echo package/$2/*/*.desc`"; shift; shift ;;
38 -*|-help) usage; exit
40 target/*) files="$files $arg"; shift ;;
41 *.desc) files="$files $arg"; shift ;;
42 *) files="$files `echo package/*/$1/$1.desc`"; shift ;;
43 esac
44 done
46 # cksum_file path-to-desc-or-target-file
47 cksum_file() {
48 case "$1" in
49 target/*)
50 has_D='cat'
51 sedscript='s,^[^ ]* *$file,$newcksum $file,'
53 *.desc)
54 has_D='fgrep "[D]" | sed "s/[[]D[^ ]*//"'
55 sedscript='s,\[D\] *[^ ]* *$file,[D] $newcksum $file,'
58 echo "!!! File type not recognized" >&2
59 return -1
60 esac
62 if [ ! -f "$1" ]; then
63 echo "!!! File not found: $1" >&2
64 return -1
67 cp $1 /tmp/$$
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
76 continue
79 local ck="sha224"
80 if [[ "$bzfile" = *.zst ]] || [[ "$bzfile" = *.tzst ]]; then
81 echo -n "$bzfile (zstd): " >&2
82 newcksum="`zstd -d < $bzfile | ${ck}sum | cut -f1 -d' '`"
83 else
84 echo -n "$gzfile (raw): " >&2
85 newcksum="`${ck}sum $gzfile | cut -f1 -d' '`"
87 newcksum="$newcksum" # also support explict {$ck}
88 echo "$newcksum" >&2
90 if [ "$cksum" != 0 -a "$cksum" != "$newcksum" ]; then
91 echo "!!! Checksum of $file changed (was $cksum)." >&2
94 eval "sed \"$sedscript\" -i /tmp/$$"
95 done
97 diff -u ./$1 /tmp/$$
98 rm -f /tmp/$$
101 echo "Creating cksum.patch ..." >&2
103 for f in $files; do
104 cksum_file $f
105 done