Skip to content

Commit 2bc044e

Browse files
add build_container
1 parent ec467b5 commit 2bc044e

File tree

3 files changed

+65
-16
lines changed

3 files changed

+65
-16
lines changed

build_container.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
set -xe
3+
4+
# generic system setup
5+
apt install -y debootstrap systemd-container
6+
systemctl enable machines.target
7+
echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/nspawn.conf
8+
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/nspawn.conf
9+
systemctl restart systemd-sysctl.service
10+
systemctl enable systemd-networkd
11+
systemctl start systemd-networkd
12+
13+
# params
14+
name=test
15+
container=/var/lib/machines/$name/
16+
17+
# destroy existing setup
18+
systemctl disable systemd-nspawn@$name.service
19+
systemctl stop systemd-nspawn@$name.service
20+
rm -f /etc/systemd/nspawn/$name.nspawn
21+
rm -rf $container
22+
23+
# create new setup
24+
debootstrap --include=systemd-container,ca-certificates buster $container
25+
echo 'deb http://security.debian.org/ buster/updates main contrib non-free' >> $container/etc/apt/sources.list
26+
echo 'deb http://deb.debian.org/debian buster-updates main contrib non-free' >> $container/etc/apt/sources.list
27+
echo 'deb [trusted=yes] file:///repo ./' >> $container/etc/apt/sources.list
28+
cp -rv repo $container/
29+
systemd-nspawn -D $container -E DEBIAN_FRONTEND=noninteractive apt update -y
30+
systemd-nspawn -D $container -E DEBIAN_FRONTEND=noninteractive apt upgrade -y
31+
systemd-nspawn -D $container -E DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y
32+
33+
systemd-nspawn -D $container systemctl enable systemd-networkd.service
34+
35+
mkdir -p /etc/systemd/nspawn/
36+
echo "[Network]" > /etc/systemd/nspawn/$name.nspawn
37+
echo "Zone=$name" >> /etc/systemd/nspawn/$name.nspawn
38+
systemctl enable systemd-nspawn@$name.service
39+
systemctl start systemd-nspawn@$name.service

build_packages.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ub_default="$ub_android $ub_int $ub_null $ub_bound"
5959

6060
# PACKAGES
6161

62-
FLAGS="$st $ub_default" # TODO try to enable some CFI
62+
FLAGS="$ub_default" # TODO try to enable some CFI
6363
export DEB_CFLAGS_APPEND="$FLAGS"
6464
export DEB_CXXFLAGS_APPEND="$FLAGS"
6565
export DEB_LDFLAGS_APPEND="$FLAGS"
@@ -69,9 +69,14 @@ build_package bzip2
6969
build_package icu
7070
build_package lua5.3
7171

72+
FLAGS="$cfi $ub_default"
73+
export DEB_CFLAGS_APPEND="$FLAGS"
74+
export DEB_CXXFLAGS_APPEND="$FLAGS"
75+
export DEB_LDFLAGS_APPEND="$FLAGS"
76+
build_package opensmtpd
77+
7278
FLAGS="$st $cfi $ub_default"
7379
export DEB_CFLAGS_APPEND="$FLAGS"
7480
export DEB_CXXFLAGS_APPEND="$FLAGS"
7581
export DEB_LDFLAGS_APPEND="$FLAGS"
7682
build_package opensmtpd
77-
build_package lzma

build_repo.sh

+19-14
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
set -xe
33

44

5-
mkdir -p repo/dists/buster/main/binary-amd64
6-
mkdir -p repo/pool/main
5+
#mkdir -p repo/dists/buster/main/binary-amd64
6+
#mkdir -p repo/pool/main
7+
#
8+
#mv debs/*.deb repo/pool/main/
9+
#cd repo
10+
#dpkg-scanpackages . > dists/buster/main/binary-amd64/Packages
11+
#
12+
#cat <<EOF > dists/buster/Release
13+
#Origin: Debian
14+
#Label: Debian
15+
#Suite: stable
16+
#Codename: buster
17+
#Components: main contrib non-free
18+
#SHA256:
19+
#$(sha256sum dists/buster/main/binary-amd64/Packages |cut -d' ' -f1) $(ls -l dists/buster/main/binary-amd64/Packages|cut -d' ' -f5) main/binary-amd64/Packages
20+
#EOF
721

8-
mv debs/*.deb repo/pool/main/
22+
mkdir -p repo
23+
mv debs/*.deb repo/
924
cd repo
10-
dpkg-scanpackages . > dists/buster/main/binary-amd64/Packages
11-
12-
cat <<EOF > dists/buster/Release
13-
Origin: Debian
14-
Label: Debian
15-
Suite: stable
16-
Codename: buster
17-
Components: main contrib non-free
18-
SHA256:
19-
$(sha256sum dists/buster/main/binary-amd64/Packages |cut -d' ' -f1) $(ls -l dists/buster/main/binary-amd64/Packages|cut -d' ' -f5) main/binary-amd64/Packages
20-
EOF
25+
dpkg-scanpackages . > Packages
2126

0 commit comments

Comments
 (0)