-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate
executable file
·86 lines (73 loc) · 2.13 KB
/
update
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
# Search for a new version tag in rsync repository.
# If found, then apply rsync-super patch and rebuild.
#
# Pass all arguments to configure.
#
# Designed to run by cron:
#
# 1. When called without arguments, use cached configure options.
# 2. Return 0 when new executable is ready, for the following cron job:
# update && custom-install
# 3. Write to stdout or stderr only on changes, for clean log or email.
#
# 'build' directory is used for data caching between
# builds (BUILT_TAG_PATH, CF_ARGS_PATH, and the repository).
#
set +e
cd "$(dirname $0)"
TOP="$(pwd)"
BUILD="$TOP/build"
SRC="$BUILD/rsync-source"
REPO="https://github.com/RsyncProject/rsync.git"
BUILT_TAG_PATH="$BUILD/latest-tag-built"
CF_ARGS_PATH="$BUILD/configure-args"
[ -d "$BUILD" ] || mkdir "$BUILD"
echo -n "$@" > "${CF_ARGS_PATH}.new"
if ! diff "${CF_ARGS_PATH}" "${CF_ARGS_PATH}.new" >/dev/null 2>/dev/null ; then
if [ -z "$*" ] && [ -s "${CF_ARGS_PATH}" ] ; then
#echo "Using cached configure arguments"
cf_args_changed=0
cf_args=$(cat "$CF_ARGS_PATH")
else
echo "Using new configure arguments"
cf_args_changed=1
cf_args="$@"
fi
else
#echo "Configure arguments aren't changed"
cf_args_changed=0
cf_args="$@"
fi
rm -f "${CF_ARGS_PATH}.new"
if [ -d "$SRC/.git" ] ; then
cd "$SRC" && git fetch -q --all && git fetch -q --tags
else
git clone "$REPO" "$SRC" && cd "$SRC"
fi
built=$(cat "$BUILT_TAG_PATH" 2>/dev/null || true)
#echo "built version: $built"
latest=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)
#echo "latest version: $latest"
if [ "$latest" '=' "$built" -a "$cf_args_changed" '!=' 1 ] ; then
#echo "Nothing to do"
exit 1
fi
echo "Building $latest"
git reset --hard && \
git clean -fd && \
git checkout "$latest" && \
rm -f configure.sh || \
exit 1
for p in ${TOP}/patches/*.patch ; do
patch -p1 < "$p" || exit 1
done
cp -av "$TOP/src/"* "${SRC}/"
./configure $cf_args && \
make && \
echo "$latest" > "$BUILT_TAG_PATH" && \
if [ "$cf_args_changed" '=' 1 ] ; then
echo -n "$cf_args" > "${CF_ARGS_PATH}"
fi && \
echo "$SRC/rsync is built." && \
exit 0