-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-initial-snapshot
executable file
·40 lines (39 loc) · 1.57 KB
/
create-initial-snapshot
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
#!/bin/bash
set -e
set -x
export LC_ALL=C
version=$(git log --pretty=oneline -1 | cut -d' ' -f1)
modified=""
if [ "$(git diff)" != "" ]; then
echo "Warning: uncommited local changes are present!" 1>&2
sleep 2
modified="(local changes!)"
fi
if [ "$build_dir" = "" ]; then
build_dir="."
fi
if [ -d $build_dir/fs ]; then sudo rm -fr $build_dir/fs; fi
sudo mkdir -p $build_dir/fs/snapshot/0
if [ "$debian_mirror" = "" ]; then
debian_mirror="http://deb.debian.org/debian"
fi
sudo debootstrap bookworm $build_dir/fs/snapshot/0 $debian_mirror
sudo chroot $build_dir/fs/snapshot/0 sed -i 's@main$@main non-free-firmware@' /etc/apt/sources.list
sudo chroot $build_dir/fs/snapshot/0 apt-get update
remove="apt-utils nano tasksel vim-common vim-tiny logrotate dmidecode"
sudo chroot $build_dir/fs/snapshot/0 apt-get -y remove $remove
sudo chroot $build_dir/fs/snapshot/0 dpkg -P $remove
add="openssh-server"
add+=" busybox systemd-sysv rsync zstd"
add+=" grub-pc intel-microcode"
if [ "$(dpkg-architecture -qDEB_BUILD_ARCH)" = "amd64" ]; then
add+=" linux-image-amd64"
else
add+=" linux-image-686"
fi
echo grub-pc grub-pc/install_devices_empty boolean true | sudo chroot $build_dir/fs/snapshot/0 debconf-set-selections
sudo chroot $build_dir/fs/snapshot/0 apt-get --no-install-recommends -y install $add
sudo mkdir -p $build_dir/fs/snapshot/0/etc/ramroot
echo "$version $modified" | sudo tee $build_dir/fs/snapshot/0/etc/ramroot/origin 2> /dev/null
git log -10 -p | sudo dd of=$build_dir/fs/snapshot/0/etc/ramroot/gitlog 2> /dev/null
sudo gzip -9 $build_dir/fs/snapshot/0/etc/ramroot/gitlog