-
Notifications
You must be signed in to change notification settings - Fork 18
/
debian.sh
executable file
·40 lines (30 loc) · 1.06 KB
/
debian.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
#!/bin/bash -uxe
version="buster"
date=$(date +%Y%m%d)
rootfs=$(mktemp --directory --tmpdir="/tmp")
sudo debootstrap --variant=minbase --include=ssh,curl,libicu63,git,xz-utils,bzip2,unzip,p7zip,zstd,expect,locales,libgomp1 $version "$rootfs"
# Set up the one true locale
echo "en_US.UTF-8 UTF-8" | sudo tee "$rootfs"/etc/locale.gen
sudo chroot "$rootfs" locale-gen
# Clean some files
sudo chroot "$rootfs" apt-get clean
sudo rm -rf "$rootfs"/var/lib/apt/lists/*
# Remove special `dev` files
sudo rm -rf "$rootfs"/dev/*
# Remove `_apt` user so that `apt` doesn't try to `setgroups()`
sudo sed '/_apt:/d' -i "$rootfs"/etc/passwd
sudo chown "$(id -u)":"$(id -g)" -R "$rootfs"
pushd "$rootfs"
# replace hardlinks with softlinks (working around JuliaIO/Tar.jl#101)
target_inode=-1
find . -type f -links +1 -printf "%i %p\n" | sort -nk1 | while read inode path; do
if [[ $target_inode != $inode ]]; then
target_inode=$inode
target_path=$path
else
ln -sf $target_path $path
fi
done
tar -cJf "/tmp/debian-$version-$date.tar.xz" .
popd
rm -rf "$rootfs"