-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild-static.sh
executable file
·61 lines (53 loc) · 1.75 KB
/
build-static.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
59
60
61
#! /bin/sh
. lib.sh
fixup() {
local m=$1
local c=$2
local workdir=$3
# copy /etc/passwd from FreeBSD-runtime
cp ${workdir}/runtime/etc/master.passwd $m/etc || return $?
pwd_mkdb -p -d $m/etc $m/etc/master.passwd || return $?
cp ${workdir}/runtime/etc/group $m/etc || return $?
cp ${workdir}/runtime/etc/termcap.small $m/etc/termcap.small || return $?
cp ${workdir}/runtime/etc/termcap.small $m/usr/share/misc/termcap || return $?
if [ "${has_certctl_package}" != "yes" ]; then
# Copy /usr/share/certs from caroot to avoid pulling in openssl. In
# FreeBSD-14, certctl is split out into its own package so we can just
# install caroot.
mkdir ${workdir}/caroot || return $?
install_packages ${workdir} ${workdir}/caroot FreeBSD-caroot
tar -C ${workdir}/caroot -cf - usr/share/certs | tar -C $m -xf - || return $?
fi
# for both 13.x and 14.x we need to manually rehash
env DESTDIR=$m /usr/sbin/certctl rehash || return $?
local desc=$(cat <<EOF
Contains:
- SSL certificates
- /etc/passwd
- /etc/group
- /etc/termcap
- timezone data
EOF
)
add_annotation $c "org.opencontainers.image.title=Base image for statically linked workloads"
add_annotation $c "org.opencontainers.image.description=${desc}"
}
fixup_debug() {
local m=$1
local c=$2
local workdir=$3
buildah config --env "PATH=/rescue:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" $c
}
parse_args "$@"
if [ "${has_certctl_package}" = "yes" ]; then
packages="FreeBSD-caroot FreeBSD-zoneinfo"
else
packages="FreeBSD-zoneinfo"
fi
if [ ${BUILD} = yes ]; then
build_image mtree static "" fixup ${packages}
build_image static static "-debug" fixup_debug FreeBSD-rescue
fi
if [ ${PUSH} = yes ]; then
push_image static
fi