Skip to content

Commit a95963a

Browse files
authored
chore(core): build nftables (#972)
Description Build nftables package for virt-handler Why do we need it, and what problem does it solve? We want more control when building binary files, as well as making images more secure What is the expected result? All work as expected --------- Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent 6da2b9d commit a95963a

4 files changed

Lines changed: 86 additions & 3 deletions

File tree

component_versions/version_map.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ package:
66
swtpm: 0.10.0
77
xorriso: 1.5.6
88
numactl: 2.0.19
9+
nftables: 1.1.3
910
openssl: openssl-3.4.1
1011
nbdkit: 1.39.5
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
image: {{ $.ImageType }}/{{ $.ImageName }}
3+
final: false
4+
fromImage: builder/scratch
5+
import:
6+
- image: {{ $.ImageType }}/{{ $.ImageName }}-builder
7+
add: /out
8+
to: /nftables
9+
before: setup
10+
11+
---
12+
{{- $version := get $.Package $.ImageName }}
13+
{{- $gitRepoUrl := "nftables.git" }}
14+
15+
{{- $name := print $.ImageName "-dependencies" -}}
16+
{{- define "$name" -}}
17+
packages:
18+
- gcc
19+
- git pkg-config trousers
20+
- automake autoconf make makeinfo libtool
21+
- musl-devel-static
22+
- flex bison asciidoc-a2x
23+
{{- end -}}
24+
25+
{{ $builderDependencies := include "$name" . | fromYaml }}
26+
27+
image: {{ $.ImageType }}/{{ $.ImageName }}-builder
28+
final: false
29+
fromImage: builder/alt
30+
secrets:
31+
- id: SOURCE_REPO
32+
value: {{ $.SOURCE_REPO_GIT }}
33+
shell:
34+
beforeInstall:
35+
- |
36+
apt-get update && apt-get install -y \
37+
{{ $builderDependencies.packages | join " " }}
38+
39+
cat >/etc/apt/sources.list.d/alt-sisyphus.list<<EOF
40+
rpm [alt] http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus x86_64 classic
41+
rpm [alt] http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus noarch classic
42+
EOF
43+
apt-get update
44+
apt-get install -y libmnl-devel libnftnl-devel libgmp-devel libreadline-devel libjansson-devel libedit-devel
45+
rm -f /etc/apt/sources.list.d/alt-sisyphus.list
46+
47+
apt-get update
48+
apt-get clean
49+
rm --recursive --force /var/lib/apt/lists/ftp.altlinux.org* /var/cache/apt/*.bin
50+
51+
install:
52+
- |
53+
OUTDIR=/out
54+
mkdir -p ~/.ssh && echo "StrictHostKeyChecking accept-new" > ~/.ssh/config
55+
56+
git clone --depth=1 $(cat /run/secrets/SOURCE_REPO)/{{ $gitRepoUrl }} --branch v{{ $version }} /src
57+
cd /src
58+
59+
./autogen.sh
60+
61+
./configure \
62+
--prefix=/usr \
63+
--libdir=/usr/lib64 \
64+
--with-json \
65+
--with-cli=readline
66+
67+
make -j$(nproc)
68+
69+
make DESTDIR=$OUTDIR install
70+
71+
strip $OUTDIR/usr/sbin/nft
72+
ldd $OUTDIR/usr/sbin/nft
73+
74+
# We don't need man, test and samples files
75+
rm -rf $OUTDIR/usr/include
76+
rm -rf $OUTDIR/usr/share
77+
rm -rf $OUTDIR/usr/lib64/pkgconfig

images/virt-handler/werf.inc.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ imageSpec:
5252
{{- define "$name" -}}
5353
packages:
5454
- acl
55-
- nftables
55+
- libnftnl
56+
- libjansson4
5657
binaries:
5758
- /usr/bin/mount
5859
- /usr/bin/umount
@@ -76,6 +77,10 @@ import:
7677
add: /xorriso
7778
to: /xorriso
7879
before: install
80+
- image: packages/binaries/nftables
81+
add: /nftables
82+
to: /nftables
83+
before: install
7984
- image: qemu
8085
add: /qemu-img
8186
to: /relocate
@@ -88,6 +93,7 @@ shell:
8893
- apt-get clean
8994
- rm --recursive --force /var/lib/apt/lists/ftp.altlinux.org* /var/cache/apt/*.bin
9095
- cp -a /xorriso/. /
96+
- cp -a /nftables/. /
9197
setup:
9298
- |
9399
/relocate_binaries.sh -i "{{ $virtHandlerDependencies.binaries | join " " }}" -o /relocate

images/virt-launcher/werf.inc.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ packages:
126126
- hwclock
127127
- iptables
128128
- libffi8
129-
- nftables
130129
- passt
131130
- pcre
132131
- procps
@@ -243,7 +242,6 @@ import:
243242
to: /numactl
244243
before: install
245244

246-
247245
- image: packages/binaries/xorriso
248246
add: /xorriso
249247
to: /xorriso
@@ -256,6 +254,7 @@ import:
256254
after: setup
257255
includePaths:
258256
- usr/bin/openssl
257+
259258
- image: tools/coreutils
260259
add: /
261260
to: /relocate

0 commit comments

Comments
 (0)