-
Notifications
You must be signed in to change notification settings - Fork 11
/
make_snapshot.sh
executable file
·58 lines (44 loc) · 1.33 KB
/
make_snapshot.sh
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
#!/bin/sh
#
# Script to publish a snapshot package, ChangeLog and admin-manual on
# the public page at https://www.domjudge.org/snapshot/. Alternatively,
# when a git URL is passed only a snapshot package is generated.
# shellcheck disable=SC2086 # globally for PUBDIR, DJDIR, TEMPDIR
set -e
#DEBUG=1
PUBDIR=~/public_html/snapshot
DJDIR=domjudge-snapshot-$(date +%Y%m%d)
GITURL="https://github.com/DOMjudge/domjudge.git"
# If a git repo URL is passed, don't update the website.
if [ -n "$1" ]; then
GITURL="$1" ; shift
PUBDIR=
fi
[ "$DEBUG" ] && set -x
quiet()
{
if [ "$DEBUG" ]; then
"$@"
else
"$@" > /dev/null 2>&1
fi
}
TEMPDIR=$(mktemp -d /tmp/domjudge-make_snapshot-XXXXXX)
cd $TEMPDIR
git clone -q --no-checkout --depth 1 "$GITURL" dj-clone
( cd dj-clone && git archive --prefix=$DJDIR/ --format=tar refs/heads/main ) | tar x
# Add released tag for revision information:
sed -i "s/PUBLISHED =.*/PUBLISHED = $(date +%Y-%m-%d)/" "$DJDIR/paths.mk.in"
quiet make -C $DJDIR dist
tar -cf $DJDIR.tar $DJDIR
gzip -9 $DJDIR.tar
if [ -n "$PUBDIR" ]; then
rm -rf ${PUBDIR:?}/*
mkdir -p $PUBDIR/manual
cp -r $DJDIR/doc/manual/build/html/* $PUBDIR/manual/
cp $DJDIR/doc/manual/build/domjudge-team-manual.pdf $PUBDIR/
cp $DJDIR.tar.gz $DJDIR/ChangeLog $PUBDIR/
cd /
fi
[ "$DEBUG" ] || rm -rf "$TEMPDIR"
exit 0