comparison include.sh @ 237:735ee8a5ca35

Fix the path to calculate the tarball sha1sum, use the sha1file function more than once, fix sha1file to handle multiple arguments.
author Rob Landley <rob@landley.net>
date Tue, 30 Oct 2007 05:42:21 -0500
parents 9c48cf5b65f6
children aeb3788642e4
comparison
equal deleted inserted replaced
236:9c48cf5b65f6 237:735ee8a5ca35
8 } 8 }
9 9
10 # output the sha1sum of a file 10 # output the sha1sum of a file
11 function sha1file() 11 function sha1file()
12 { 12 {
13 sha1sum "$1" | awk '{print $1}' 13 sha1sum "$@" | awk '{print $1}'
14 } 14 }
15 15
16 # Extract tarball named in $1 and apply all relevant patches into 16 # Extract tarball named in $1 and apply all relevant patches into
17 # "$BUILD/sources/$1". Record sha1sum of tarball and patch files in 17 # "$BUILD/sources/$1". Record sha1sum of tarball and patch files in
18 # sha1-for-source.txt. Re-extract if tarball or patches change. 18 # sha1-for-source.txt. Re-extract if tarball or patches change.
21 { 21 {
22 SRCTREE="${BUILD}/sources" 22 SRCTREE="${BUILD}/sources"
23 BASENAME=`noversion "$1"` 23 BASENAME=`noversion "$1"`
24 BASENAME="${BASENAME/%\.tar\.*/}" 24 BASENAME="${BASENAME/%\.tar\.*/}"
25 SHA1FILE="$(echo "${SRCTREE}/${BASENAME}/sha1-for-source.txt")" 25 SHA1FILE="$(echo "${SRCTREE}/${BASENAME}/sha1-for-source.txt")"
26 SHA1TAR="$(sha1file "$1")" 26 SHA1TAR="$(sha1file "${SRCDIR}/$1")"
27 27
28 # Sanity check: don't ever "rm -rf /". Just don't. 28 # Sanity check: don't ever "rm -rf /". Just don't.
29 29
30 if [ -z "$BASENAME" ] || [ -z "$SRCTREE" ] 30 if [ -z "$BASENAME" ] || [ -z "$SRCTREE" ]
31 then 31 then
34 34
35 # If it's already extracted and up to date (including patches), do nothing. 35 # If it's already extracted and up to date (including patches), do nothing.
36 SHALIST=$(cat "$SHA1FILE" 2> /dev/null) 36 SHALIST=$(cat "$SHA1FILE" 2> /dev/null)
37 if [ ! -z "$SHALIST" ] 37 if [ ! -z "$SHALIST" ]
38 then 38 then
39 for i in "$SHA1TAR" $(sha1sum "${SOURCES}/patches/$BASENAME"* 2>/dev/null | awk '{print $1}') 39 for i in "$SHA1TAR" $(sha1file "${SOURCES}/patches/$BASENAME"* 2>/dev/null)
40 do 40 do
41 # Is this sha1 in the file? 41 # Is this sha1 in the file?
42 [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ] && break 42 [ -z "$(echo "$SHALIST" | sed -n "s/$i/$i/p" )" ] && break
43 # Remove it 43 # Remove it
44 SHALIST="$(echo "$SHALIST" | sed "s/$i//" )" 44 SHALIST="$(echo "$SHALIST" | sed "s/$i//" )"
73 do 73 do
74 if [ -f "$i" ] 74 if [ -f "$i" ]
75 then 75 then
76 echo "Applying $i" 76 echo "Applying $i"
77 (cd "${SRCTREE}/${BASENAME}" && patch -p1 -i "$i") || dienow 77 (cd "${SRCTREE}/${BASENAME}" && patch -p1 -i "$i") || dienow
78 sha1sum "$i" | awk '{print $1}' >> "$SHA1FILE" 78 sha1file "$i" >> "$SHA1FILE"
79 fi 79 fi
80 done 80 done
81 } 81 }
82 82
83 function download() 83 function download()