OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
2.6 KiB

#!/bin/bash
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/sde-package/patch-cksum.sh
# Copyright (C) 2006 - 2011 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
. lib/functions.in
override=0
files=''
usage()
{
echo "Usage:"
echo "./scripts/Create-CkSumPatch [options] <package-name>"
echo "./scripts/Create-CkSumPatch [options] <target-name>"
echo "./scripts/Create-CkSumPatch [options] <file-path>"
echo " "
echo "Options:"
echo " -override Create new cksum if old one should be valid."
echo " -help This."
}
while [ "$1" ]; do
case "$1" in
-override) override=1 ; shift ;;
-repository) files="$files `echo package/$2/*/*.desc`" ; shift ; shift ;;
-*|-help) usage ; exit
;;
target/*) files="$files $arg" ; shift ;;
*.desc) files="$files $arg" ; 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
local tmpdir="tmp/patch-cksum"
mkdir -p $tmpdir
cp $1 $tmpdir/$$
eval "egrep -v '^#' $1 | $has_D" | while read cksum file url args; do
[ "$cksum" = 'X' ] && continue
[ "$cksum" != '0' -a "$override" = '0' ] && continue
gzfile=`source_file cksum $file $url $flags`
bzfile="`bz2filename "$gzfile"`"
if [ ! -f "$bzfile" ]; then
echo "!!! File not present: $bzfile" >&2
continue
fi
echo -n "$bzfile: " >&2
newcksum=$( sh lib/sde-download/cksum.sh "$bzfile" | cut -d' ' -f2 )
echo $newcksum >&2
if [ "$cksum" != 0 -a "$cksum" != "$newcksum" ]; then
echo "!!! Checksum of $file changed (was $cksum)." >&2
fi
eval "sed \"$sedscript\" -i $tmpdir/$$"
done
diff -u ./$1 ./$tmpdir/$$
rm -f $tmpdir/$$
}
for f in $files; do
cksum_file $f
done