-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate
executable file
·56 lines (47 loc) · 1.69 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
#!/bin/bash
set -e -o pipefail
shopt -s dotglob extglob nullglob
cd -- "$(git -C "${0%/*}" rev-parse --show-toplevel)"
if [[ $@ != @(+([0-9a-f])|master) ]]; then
echo "Usage: ${0##*/} ( COMMIT | master )"
echo "Update upstream branch then merge changes into master."
echo "This maintainer script does not attempt to be portable."
exit 64
elif ! git diff --exit-code --quiet; then
echo "Uncommitted changes in the working directory"
exit 1
elif ! git diff --cached --exit-code --quiet; then
echo "Uncommitted changes in the index"
exit 1
fi >&2
TMP=$(mktemp -d tmp-XXXXXX)
trap 'rm -r $TMP' EXIT
echo "Cloning upstream sources for sparse checkout:"
git clone --no-checkout --filter=blob:none --shallow-since '6 months' \
https://github.com/openbsd/src $TMP
git -C $TMP sparse-checkout set lib/libutil sys/sys usr.sbin/ntpd
git -C $TMP checkout -q $1
git checkout upstream
git rm -q -r src
mkdir -p src
for FILE in $TMP/lib/libutil/imsg{,-buffer}.[ch] $TMP/sys/sys/queue.h \
$TMP/usr.sbin/ntpd/*.[chy58]; do
sed ':a;s/[ \t]*$//;/^\n*$/{$d;N;ba}' "$FILE" \
| unexpand >"src/${FILE##*/}"
git add "src/${FILE##*/}"
done
mkdir -p man openbsd
git mv -f src/*.[58] man
git mv -f src/sensors.c openbsd
if git diff --cached --exit-code --quiet; then
echo "No upstream changes to merge"
git checkout master
else
SNAPSHOT=$(git -C $TMP log -1 --abbrev=8 --pretty='%cs (%h)')
git commit -m "Update upstream files from OpenBSD $SNAPSHOT"
git checkout master
git merge -m "Merge from upstream OpenBSD $SNAPSHOT" upstream
echo "Merged openntpd ready to review, build and test"
echo "Sign: git tag -m openntpd-VERSION -s openntpd-VERSION"
echo "Push: git push --tags origin upstream master"
fi