|
|
#!/bin/bash # # --- ROCK-COPYRIGHT-NOTE-BEGIN --- # # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # Please add additional copyright information _after_ the line containing # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by # the ./scripts/Create-CopyPatch script. Do not edit this copyright text! # # ROCK Linux: rock-src/scripts/Create-CkSumPatch # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. A copy of the GNU General Public # License can be found at Documentation/COPYING. # # Many people helped and are helping developing ROCK Linux. Please # have a look at http://www.rocklinux.org/ and the Documentation/TEAM # file for details. # # --- ROCK-COPYRIGHT-NOTE-END ---
. scripts/functions override=0 files=''
while [ "$1" ]; do case "$1" in -override) override=1 ; shift ;; -repository) files="$files `echo package/$2/*/*.desc`" ; shift ; shift ;; -*) echo "Usage:" echo "./scripts/Create-CkSumPatch [options] <package-name>" echo "./scripts/Create-CkSumPatch [options] <target-name>" echo "./scripts/Create-CkSumPatch [options] <file-path>" echo "./scripts/Create-CkSumPatch [options] -repository <repo-name>" echo " " echo "Options:" echo " -override Create new cksum if old one should be valid." echo " -help This." exit ;; target/*) files="$files $1" ; shift ;; *.desc) files="$files $1" ; shift ;; *) files="$files `echo package/*/$1/$1.desc`" ; shift ;; esac done
# cksum_file path-to-desc-or-target-file cksum_file() { case "$1" in target/*) has_D='cat' sedscript='s,^[0-9]* *$file,$newcksum $file,' ;; *.desc) has_D='fgrep "[D]" | sed "s/[[]D[^ ]*//"' sedscript='s,\[D\] *[0-9]* *$file,[D] $newcksum $file,' ;; *) echo "!!! File type not recognized" >&2 return -1 esac
if [ ! -f "$1" ]; then echo "!!! File not found: $1" >&2 return -1 fi
cp $1 /tmp/$$ eval "egrep -v '^#' $1 | $has_D" | while read cksum file url flags; do [ "$cksum" = 'X' ] && continue [ "$cksum" != '0' -a "$override" = '0' ] && continue
gzfile=`source_file cksum $file url $flags` bzfile="`echo "$gzfile" | sed 's,\.\(t\?\)\(gz\|Z\)$,.\1bz2,'`" if [ ! -f "$bzfile" ]; then echo "!!! File not present: $bzfile" >&2 continue fi
if [[ "$bzfile" = *.bz2 ]] || [[ "$bzfile" = *.tbz2 ]] ; then echo -n "$bzfile (bzip2): " >&2 newcksum="`bunzip2 < $bzfile | cksum | cut -f1 -d' '`" else echo -n "$gzfile (raw): " >&2 newcksum="`cksum $gzfile | cut -f1 -d' '`" fi echo $newcksum >&2
if [ "$cksum" != 0 -a "$cksum" != "$newcksum" ]; then echo "!!! Checksum of $file changed (was $cksum)." >&2 fi
eval "sed \"$sedscript\" -i /tmp/$$" done
diff -u $1 /tmp/$$ rm -f /tmp/$$ }
echo "Creating cksum.patch ..." >&2
for f in $files; do cksum_file $f done
|