-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.build
executable file
·57 lines (51 loc) · 1.82 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
#!/bin/sh
cd "$(dirname "$0")" # jump to curdir
set -eu
# Pass these on the command line.
oscodename=${1:-ubuntu/jammy} # ubuntu/jammy
upname=aide
upversion=${2:-0.18.6} # aide version
debepoch=
debversion=${3:-2osso3} # deb build version, e.g. 0osso2
echo "Usage: $0 [$oscodename [$upversion [$debversion]]]"
echo ".. continuing"
osdistro=${oscodename%/*} # debian (or ubuntu)
oscodename=${oscodename#*/} # stretch (or bionic)
case $osdistro/$oscodename in
debian/bookworm)osdistshort=deb; oscodenum=12;;
debian/bullseye)osdistshort=deb; oscodenum=11;;
debian/buster) osdistshort=deb; oscodenum=10;;
debian/stretch) osdistshort=deb; oscodenum=9;;
debian/jessie) osdistshort=deb; oscodenum=8;;
ubuntu/noble) osdistshort=ubu; oscodenum=24.04;;
ubuntu/jammy) osdistshort=ubu; oscodenum=22.04;;
ubuntu/focal) osdistshort=ubu; oscodenum=20.04;;
*) echo "ERROR: undefined OS: $osdistro/$oscodename" >&2 && exit 1
esac
_shortver=$osdistshort$oscodenum
# 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} -ne 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'/#'