Skip to content

Commit

Permalink
add scripts to create ubuntu rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
ading2210 committed Jun 29, 2024
1 parent 079e1f9 commit 1a08174
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions build_complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ if [ ! "$rootfs_dir" ]; then

if [ "$distro" = "debian" ]; then
release="${release:-bookworm}"
elif [ "$distro" = "ubuntu" ]; then
release="${release:-jammy}"
elif [ "$distro" = "alpine" ]; then
release="${release:-latest-stable}"
else
Expand Down
11 changes: 11 additions & 0 deletions build_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ if [ "$distro" = "debian" ]; then
debootstrap --arch $arch $release_name $rootfs_dir http://deb.debian.org/debian/
chroot_script="/opt/setup_rootfs.sh"

elif [ "$distro" = "ubuntu" ]; then
print_info "bootstraping ubuntu chroot"
repo_url="http://archive.ubuntu.com/ubuntu"
if [ "$arch" = "amd64" ]; then
repo_url="http://archive.ubuntu.com/ubuntu"
else
repo_url="http://ports.ubuntu.com"
fi
debootstrap --arch $arch $release_name $rootfs_dir $repo_url
chroot_script="/opt/setup_rootfs.sh"

elif [ "$distro" = "alpine" ]; then
print_info "downloading alpine package list"
pkg_list_url="https://dl-cdn.alpinelinux.org/alpine/latest-stable/main/x86_64/"
Expand Down
37 changes: 34 additions & 3 deletions rootfs/opt/setup_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,36 @@ Pin: origin ${custom_repo_domain}
Pin-Priority: 1001
END

#install the patched systemd

#install certs to prevent apt ssl errors
apt-get install -y ca-certificates
apt-get update

#fix apt repos for ubuntu
if grep "ubuntu.com" /etc/apt/sources.list > /dev/null; then
ubuntu_repo="$(grep "ubuntu.com" /etc/apt/sources.list)"
ubuntu_repo="$ubuntu_repo universe"
updates_repo="$(echo "$ubuntu_repo" | sed "s/$release_name/$release_name-updates/")"
sed -i '/ubuntu.com/d' /etc/apt/sources.list
echo "$ubuntu_repo" >> /etc/apt/sources.list
echo "$updates_repo" >> /etc/apt/sources.list

#install the mozilla apt repo to avoid using snap for firefox
apt-get install -y wget gpg
install -d -m 0755 /etc/apt/keyrings
wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- > /etc/apt/keyrings/packages.mozilla.org.asc
gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}'
echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" >> /etc/apt/sources.list.d/mozilla.list
echo '
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
' > /etc/apt/preferences.d/mozilla
apt-get update
fi

#install the patched systemd
apt-get upgrade -y
installed_systemd="$(dpkg-query -W -f='${binary:Package}\n' | grep "systemd")"
apt-get clean
apt-get install -y --reinstall --allow-downgrades $installed_systemd
Expand All @@ -46,15 +73,19 @@ apt-get install -y --reinstall --allow-downgrades $installed_systemd
systemctl enable kill-frecon.service

#install base packages
if [ -z "$disable_base_pkgs" ]; then
if [ ! "$disable_base_pkgs" ]; then
apt-get install -y cloud-utils zram-tools sudo command-not-found bash-completion

#set up zram
echo "ALGO=lzo" >> /etc/default/zramswap
echo "PERCENT=50" >> /etc/default/zramswap

#update apt-file cache
apt-file update
if which apt-file >/dev/null; then
apt-file update
else #old versions of command-not-found did not use apt-file
apt-get update
fi
fi

#set up hostname and username
Expand Down

0 comments on commit 1a08174

Please sign in to comment.