-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.build
executable file
·120 lines (105 loc) · 3.2 KB
/
Dockerfile.build
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
cd "$(dirname "$0")" # jump to curdir
set -eu
# Pass these on the command line.
oscodename=${1:-ubuntu/jammy} # ubuntu/focal
upname=gtkradiant
upversion=${2:-1.6.6} # GtkRadiant version
debepoch=
debversion=${3:-0wjd1} # deb build version, e.g. 0wjd1
echo "Usage: $0 [$oscodename [$upversion [$debversion]]]"
echo ".. continuing"
osdistro=${oscodename%/*} # debian (or ubuntu)
oscodename=${oscodename#*/} # stretch (or bionic)
case $osdistro/$oscodename in
debian/buster) osdistshort=deb; oscodenum=10;;
debian/stretch) osdistshort=deb; oscodenum=9;;
debian/jessie) osdistshort=deb; oscodenum=8;;
debian/wheezy) osdistshort=deb; oscodenum=7;;
ubuntu/jammy) osdistshort=ubu; oscodenum=22.04;;
ubuntu/focal) osdistshort=ubu; oscodenum=20.04;;
ubuntu/bionic) osdistshort=ubu; oscodenum=18.04;;
ubuntu/xenial) osdistshort=ubu; oscodenum=16.04;;
ubuntu/trusty) osdistshort=ubu; oscodenum=14.04;;
*) echo "ERROR: undefined OS: $osdistro/$oscodename" >&2 && exit 1
esac
_shortver=$osdistshort$oscodenum
# Update changelog
sed -i -e "1s/+\\(deb\\|ubu\\)[0-9.]*) [a-z]\\+;/+$_shortver) $oscodename;/" \
changelog
git_pull_or_clone() {
if test -d "$1"; then
git -C "$1" pull --rebase
else
git clone "$2" "$1"
fi
}
svn_pull_or_clone() {
if test -d "$1"; then
svn update "$1"
else
svn checkout "$2" "$1"
fi
}
# Ensure we have GtkRadiant.
git_pull_or_clone source-files/GtkRadiant https://github.com/TTimo/GtkRadiant
# Improve versioning, based on the git version.
version_suffix=$(\
git -C source-files/GtkRadiant log --date=short --format='%cd' |
tr -d '-' | uniq -c | head -n1 | awk '{print $2 "+" $1}')
# Add bspc to repo.
git_pull_or_clone source-files/GtkRadiant/tools/bspc \
https://github.com/TTimo/bspc.git
# Ensure we have all game pak files.
for svnpak in \
ETPack \
JAPack \
Q1Pack \
Q2Pack \
Q3Pack \
QLPack \
QuetooPack \
STVEFPack \
UnvanquishedPack \
UrTPack \
WolfPack \
; do
case $svnpak in
UnvanquishedPack)
svnurl="https://github.com/Unvanquished/unvanquished-mapeditor-support.git\
/trunk/build/gtkradiant"
;;
*)
svnurl=svn://svn.icculus.org/gtkradiant-gamepacks/$svnpak/trunk
;;
esac
svn_pull_or_clone source-files/GtkRadiant/install/installs/$svnpak $svnurl
done
# Update upversion adding the suffix in there.
upversion="$upversion+$version_suffix"
# Docker disallows certain tokens in versions.
dockversion=$(echo build-${upname}-${upversion}-${debversion}-${oscodename} |
sed -e 's/[^0-9A-Za-z_.-]/_/g')
# Will build files.
docker build \
--pull \
--ulimit nofile=512 \
--build-arg osdistro=$osdistro \
--build-arg osdistshort=$osdistshort \
--build-arg oscodename=$oscodename \
--build-arg upname=$upname \
--build-arg upversion=$upversion \
--build-arg debepoch=$debepoch \
--build-arg debversion=$debversion \
-t $dockversion \
-f Dockerfile \
. || ret=$?
if test ${ret:-0} != 0; then
echo "fail" >&2
exit $ret
fi
# Copy files to ./Dockerfile.out
test -d Dockerfile.out/$oscodename || mkdir -p Dockerfile.out/$oscodename
docker run $dockversion sh -c 'cd /dist; tar -zc *' |
tar -zxvC Dockerfile.out/$oscodename/ |
sed -e 's#$# -> Dockerfile.out/'$oscodename'/#'