forked from freeciv/freeciv-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl_freeciv_default.sh
executable file
·44 lines (34 loc) · 1.59 KB
/
dl_freeciv_default.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
#!/bin/bash -e
# Places the specified revision of Freeciv in freeciv/freeciv/
# This is the default. The script dl_freeciv.sh will run instead of
# dl_freeciv_default.sh if it exists.
# If you want to modify this file copy it to dl_freeciv.sh and edit it.
if test "$2" != "" ; then
GIT_PATCHING="$2"
else
GIT_PATCHING="yes"
fi
echo "Updating freeciv to commit $1, git patching: $GIT_PATCHING"
# Remove old version
echo " removing existing source"
rm -Rf freeciv
if test "$GIT_PATCHING" = "yes" ; then
# Fetch one commit from freeciv
git clone --no-tags --branch=master --single-branch https://github.com/freeciv/freeciv.git freeciv
( cd freeciv && git checkout $1 )
else
# Download the wanted Freeciv revision from GitHub unless it is here already.
# The download step saves having to merge in Freeciv's history each time the
# Freeciv server revision is updated.
echo " fetching missing revisions"
git cat-file -e $1 || git fetch --no-tags --depth=1 https://github.com/freeciv/freeciv.git $1:freeciv
# Place the requested Freeciv revision in the freeciv/freeciv folder.
# The checkout isn't owned by git. This means that the patches automatically
# applied during the build won't accidentally end up in commits. It also
# means that committing unrelated changes won't accidentally revert the
# Freeciv server revision because a command didn't run.
echo " checking out commit $1"
git read-tree --prefix=freeciv/freeciv/ --index-output=.freeciv_index $1
mkdir freeciv && cd freeciv && GIT_INDEX_FILE=.freeciv_index git checkout-index -af && cd ..
rm -f ../.freeciv_index
fi