-
Notifications
You must be signed in to change notification settings - Fork 35
/
.hashsum
executable file
·35 lines (31 loc) · 1.12 KB
/
.hashsum
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
DIR="$1"
if [ "$DIR" = "" ]; then
echo "usage: $0 <folder>" >&2
echo "returns md5 hashsum for folder including dependencies" >&2
exit 3
fi
if ! test -x ../build_cached; then
echo "ERROR: must be run from packages folder" >&2
exit 3
fi
if [ "x$OMD_ROOT" = "x" ]; then
echo "ERROR: OMD_ROOT not set!" >&2
exit 3
fi
MD5=$( (find $DIR/ -type f -exec md5sum {} \; && find $DIR/ -type l -exec md5sum {} \; ) 2>&1 | sort | md5sum | awk '{ print $1 }')
# add dependencies and rebuild if any of the dependency has changed
DEPS=$(grep -P 'DEPENDS\ *=' $DIR/Makefile 2>/dev/null | awk -F = '{ print $2 }' | sort -u | sed "s|\$(OMD_ROOT)|$OMD_ROOT|g")
# add go dependencies
GOVERSION=$(grep -P 'GOPKG\ *=' $DIR/Makefile $DIR/*/Makefile 2>/dev/null | awk -F = '{ print $2 }' | tr -d ' ' | sort -u)
if [ -n "$GOVERSION" ]; then
for GO in $GOVERSION; do
DEPS="$DEPS go-$GO"
done
fi
if [ -n "$DEPS" ]; then
for DEP in $DEPS; do
MD5=$(echo $(md5sum $DEP/*.gz $DEP/Makefile $DEP/patches/* $DEP 2>/dev/null | awk '{ print $1 }') $MD5 | md5sum | awk '{ print $1 }')
done
fi
echo "$MD5"