-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-rootfs.sh
executable file
·66 lines (54 loc) · 2.47 KB
/
create-rootfs.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
62
63
64
65
66
#!/bin/bash
set -e
# Pistachio Linux rootfs creation script
# requires some stuff, like debootstrap.
# a lot of this was taken from https://salsa.debian.org/debian/WSL/-/blob/master/create-targz.sh.
echo_info() {
echo -e "[\e[34mINFO\e[39m] $1"
}
BUILDDIR=$(pwd)
TMPDIR=$(mktemp -d)
DIST="testing"
cd $TMPDIR
# start timer
start=$SECONDS
echo_info "📦 Creating Pistachio Linux rootfs. Timer started. Debian version: $DIST, build directory: $BUILDDIR, temporary directory: $TMPDIR. "
# initialize rootfs
sudo debootstrap --arch "amd64" --exclude=debfoster --include sudo,locales,curl $DIST $DIST http://deb.debian.org/debian
echo_info "📦 Rootfs initialized."
# clean up apt
sudo chroot $DIST apt-get clean
echo_info "📦 Cleaned up apt."
# set up locale
sudo chroot $DIST /bin/bash -c "update-locale LANGUAGE=en_US.UTF-8 LC_ALL=C"
sudo chroot $DIST /bin/bash -c "echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen"
echo_info "📦 Set up locale."
# start installing packages
sudo chroot $DIST apt install -y podman distrobox ca-certificates jq
echo_info "📦 Installed packages."
# move files
sudo cp $BUILDDIR/files/sources.list $TMPDIR/$DIST/etc/apt/sources.list
sudo cp $BUILDDIR/files/wsl.conf $TMPDIR/$DIST/etc/wsl.conf
sudo cp $BUILDDIR/files/containers.conf $TMPDIR/$DIST/etc/containers/containers.conf
sudo cp $BUILDDIR/files/motd $TMPDIR/$DIST/etc/motd
sudo chmod +x $TMPDIR/$DIST/etc/motd
echo_info "📦 Installed files."
# install pistachio scripts
sudo curl -L https://raw.githubusercontent.com/PistachioLinux/pistachio-scripts/master/pistachio-manager -o $TMPDIR/$DIST/usr/bin/pistachio-manager
sudo curl -L https://raw.githubusercontent.com/PistachioLinux/pistachio-scripts/master/pistachio-update -o $TMPDIR/$DIST/usr/bin/pistachio-update
sudo curl -L https://raw.githubusercontent.com/PistachioLinux/pistachio-scripts/master/pistachio-setup -o $TMPDIR/$DIST/usr/bin/pistachio-setup
sudo chmod +x $TMPDIR/$DIST/usr/bin/pistachio-manager
sudo chmod +x $TMPDIR/$DIST/usr/bin/pistachio-update
sudo chmod +x $TMPDIR/$DIST/usr/bin/pistachio-setup
echo_info "📦 Installed Pistachio scripts."
# pack it up
cd $DIST
echo_info "📦 Packing up rootfs."
sudo tar --ignore-failed-read -czvf $TMPDIR/pistachio-$(date +%Y%m%d).tar.gz *
echo_info "📦 Moving rootfs to build directory."
mkdir -p $BUILDDIR/build
mv -f $TMPDIR/pistachio-$(date +%Y%m%d).tar.gz $BUILDDIR/build
cd $BUILDDIR
# im like a math genius
duration=$(( SECONDS - start ))
echo_info "⏱️ Finished in $duration seconds."