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"
34 # The version is hard coded in OMD Python binary, fix that.
35 if [ $SRC = python
]; then
36 BIN_RPATH
=$
(strings python
/tmp.python27
/bin
/python2.7 |
grep ^
/omd
/versions
)
37 NEW_RPATH
=/omd
/versions
/$OMD_VERSION/lib
38 if [ ${#BIN_RPATH} -ne ${#NEW_RPATH} ]; then
39 echo "python: Can't replace rpath (different length: $BIN_RPATH, $NEW_RPATH). Use chrpath or patchelf to fix this."
42 sed -i "s%$BIN_RPATH%$NEW_RPATH%g" python
/tmp.python27
/bin
/python2.7
47 EXCLUDES_FILE
=$
(mktemp
)
48 find "$SRC" -type f
> $EXCLUDES_FILE
50 # no cache hit - rebuild package and create cache tarball
56 find "$SRC/" -type f | \
58 if grep -Ic "$OMD_VERSION" "$file" >/dev
/null
2>&1; then
59 cp -p "$file" "$file.tmp"
60 sed -e "s%$OMD_VERSION%###BUILD_OMD_VERSION###%g" -i "$file"
61 touch -r "$file.tmp" "$file"
66 tar cfz
$TARBALL_TMP "$SRC" --exclude-from=$EXCLUDES_FILE
68 mv $TARBALL_TMP "$CACHE_FILE"
69 echo "cache file $CACHE_FILE created"
71 find "$SRC/" -type f | \
73 if grep -Ic "###BUILD_OMD_VERSION###" "$file" >/dev
/null
2>&1; then
74 cp -p "$file" "$file.tmp"
75 sed -e "s%###BUILD_OMD_VERSION###%$OMD_VERSION%g" -i "$file"
76 touch -r "$file.tmp" "$file"