7 # skip caching if cache folder is not set or does not exist or omd version length is too small, which would be error prone
8 if [ "x$BUILD_CACHE" = "x" ] ||
! test -d $BUILD_CACHE ||
[ ${#OMD_VERSION} -lt 5 ]; then
13 BUILD_CACHE
=$BUILD_CACHE/$CACHESUBDIR
17 MD5
=$
(cd "$SRC" && find .
-type f
-exec md5sum {} \
; |
sort |
md5sum |
awk '{ print $1 }')
18 CACHE_FILE
="$BUILD_CACHE/${SRC}_${MD5}.tgz"
20 # cache hit - just unpack the already built package
21 if test -e "$CACHE_FILE"; then
22 echo "md5sum matched, using cache from $CACHE_FILE"
24 find "$SRC/" -type f | \
26 if grep -Ic "###BUILD_OMD_VERSION###" "$file" >/dev
/null
2>&1; then
27 cp -p "$file" "$file.tmp"
28 sed -e "s%###BUILD_OMD_VERSION###%$OMD_VERSION%g" -i "$file"
29 touch -r "$file.tmp" "$file"
35 EXCLUDES_FILE
=$
(mktemp
)
36 find "$SRC" -type f
> $EXCLUDES_FILE
38 # no cache hit - rebuild package and create cache tarball
44 find "$SRC/" -type f | \
46 if grep -Ic "$OMD_VERSION" "$file" >/dev
/null
2>&1; then
47 cp -p "$file" "$file.tmp"
48 sed -e "s%$OMD_VERSION%###BUILD_OMD_VERSION###%g" -i "$file"
49 touch -r "$file.tmp" "$file"
54 tar cfz
$TARBALL_TMP "$SRC" --exclude-from=$EXCLUDES_FILE
56 mv $TARBALL_TMP "$CACHE_FILE"
57 echo "cache file $CACHE_FILE created"
59 find "$SRC/" -type f | \
61 if grep -Ic "###BUILD_OMD_VERSION###" "$file" >/dev
/null
2>&1; then
62 cp -p "$file" "$file.tmp"
63 sed -e "s%###BUILD_OMD_VERSION###%$OMD_VERSION%g" -i "$file"
64 touch -r "$file.tmp" "$file"