#!/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 --- if [ $# = 1 -a "$1" = -misc ] ; then set x -repository misc ; shift fi if [ $# = 1 -a "$1" = -all ] ; then shift $# ; cmpfield=2 else if [ "$1" = "-repository" -o "$1" = "-target" ] then cmpfield=2 ; shift ; else cmpfield=3 ; fi if [ "$#" -eq 0 -o "${1#-}" != "$1" ] ; then echo "Usage: $0 " echo "or $0 -repository " echo "or $0 -target " echo "or $0 -misc" echo "or $0 -all" exit 1 fi fi echo "Creating cksum.patch ..." >&2 ./scripts/Download -list-cksums | grep '^00* ' | \ while read cksum gzfile ; do bzfile="`echo "$gzfile" | sed 's,\.\(t\?\)\(gz\|Z\)$,.\1bz2,'`" if [ -f "$bzfile" ] then checkthis=1 xfile="`basename $gzfile`" descfile="`grep $xfile package/*/*/*.desc target/*/download.txt | sed 's,:.*,,'`" rep="`echo $descfile | cut -f2 -d/`" pkg="`echo $descfile | cut -f3 -d/`" for x ; do [ $checkthis = 1 ] && checkthis=0 [ "$pkg" = $x ] && checkthis=2 [ "$descfile" = $x ] && checkthis=2 done if [ $checkthis = 0 ] ; then : echo "Skip: $bzfile" ; continue fi if [[ "$bzfile" = *.bz2 ]] || [[ "$bzfile" = *.tbz2 ]] ; then echo -n "$bzfile (bzip2): " >&2 cksum="`bunzip2 < $bzfile | cksum | cut -f1 -d' '`" else echo -n "$gzfile (raw): " >&2 cksum="`cksum "$gzfile" | cut -f1 -d' '`" fi echo $cksum >&2 if [ -d package/$rep ] ; then if [ -f $descfile ] ; then sedscript="s,\[D\] *00* *$xfile,[D] $cksum $xfile," sed "$sedscript" -i /tmp/$$ if cmp -s ./$descfile /tmp/$$ ; then echo "!!! SED script didn't change anything:" >&2 echo "!!! $sedscript" >&2 else { echo "diff -u -U 0 ./$descfile /tmp/$$" diff -u -U 0 ./$descfile /tmp/$$ ; } fi rm -f /tmp/$$ else echo "!!! No Desc File for $gzfile" >&2 echo "!!! (My guess was $descfile)" >&2 fi elif [ -d target/$rep -o "$rep" = misc ] ; then if [ -f $descfile ] ; then sedscript="s,^00* *$xfile,$cksum $xfile," sed "$sedscript" < $descfile > /tmp/$$ if cmp -s ./$descfile /tmp/$$ ; then echo "!!! SED script didn't change anything:" >&2 echo "!!! $sedscript" >&2 else { echo "diff -u -U 0 ./$descfile /tmp/$$" diff -u -U 0 ./$descfile /tmp/$$ ; } fi rm -f /tmp/$$ else echo "!!! No Desc File for $gzfile" >&2 echo "!!! (My guess was $descfile)" >&2 fi else echo "!!! No Desc File for $gzfile" >&2 echo "!!! (I didn't have any possible guesses)" >&2 fi fi done