mbp-ubuntu/files/chroot_build.sh

186 lines
5.4 KiB
Bash
Raw Normal View History

2020-04-17 05:53:48 -04:00
#!/bin/bash
set -eu -o pipefail
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Configure environment... "
2020-04-17 05:53:48 -04:00
mount none -t proc /proc
mount none -t sysfs /sys
mount none -t devpts /dev/pts
2020-04-17 12:31:32 -04:00
2020-04-17 05:53:48 -04:00
export HOME=/root
export LC_ALL=C
2023-04-30 09:12:53 -04:00
echo "ubuntu-lunar-live" >/etc/hostname
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Configure and update apt... "
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
cat <<EOF >/etc/apt/sources.list
2023-04-30 09:12:53 -04:00
deb http://archive.ubuntu.com/ubuntu/ lunar main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ lunar main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ lunar-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ lunar-updates main restricted universe multiverse
2020-04-17 05:53:48 -04:00
EOF
apt-get update
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Install systemd and Ubuntu MBP Repo... "
2020-04-17 05:53:48 -04:00
2020-04-17 12:31:32 -04:00
apt-get install -y systemd-sysv gnupg curl wget
2020-04-17 05:53:48 -04:00
2020-04-17 12:31:32 -04:00
mkdir -p /etc/apt/sources.list.d
2022-09-29 09:25:08 -04:00
curl -s --compressed "https://adityagarg8.github.io/t2-ubuntu-repo/KEY.gpg" | gpg --dearmor | tee /etc/apt/trusted.gpg.d/t2-ubuntu-repo.gpg >/dev/null
curl -s --compressed -o /etc/apt/sources.list.d/t2.list "https://adityagarg8.github.io/t2-ubuntu-repo/t2.list"
2020-04-17 12:31:32 -04:00
apt-get update
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Configure machine-id and divert... "
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
dbus-uuidgen >/etc/machine-id
2020-04-17 05:53:48 -04:00
ln -fs /etc/machine-id /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Install packages needed for Live System... "
2020-04-17 05:53:48 -04:00
export DEBIAN_FRONTEND=noninteractive
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
2020-04-24 06:19:37 -04:00
ubuntu-standard \
2020-05-03 09:04:34 -04:00
sudo \
2020-04-24 06:19:37 -04:00
casper \
discover \
laptop-detect \
os-prober \
network-manager \
resolvconf \
net-tools \
wireless-tools \
locales \
initramfs-tools \
binutils \
linux-generic \
linux-headers-generic \
2020-05-03 09:04:34 -04:00
grub-efi-amd64-signed \
intel-microcode \
2022-02-07 12:14:40 -05:00
thermald \
2022-02-13 03:59:18 -05:00
grub2 \
nautilus-admin
2020-04-24 06:19:37 -04:00
2022-10-17 12:33:21 -04:00
curl -L https://github.com/t2linux/T2-Ubuntu-Kernel/releases/download/vKVER-PREL/linux-headers-KVER-${ALTERNATIVE}_KVER-PREL_amd64.deb > /tmp/headers.deb
curl -L https://github.com/t2linux/T2-Ubuntu-Kernel/releases/download/vKVER-PREL/linux-image-KVER-${ALTERNATIVE}_KVER-PREL_amd64.deb > /tmp/image.deb
2021-11-20 01:12:54 -05:00
file /tmp/*
2022-08-19 06:37:39 -04:00
apt install /tmp/headers.deb /tmp/image.deb
2021-11-20 23:16:21 -05:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Install window manager... "
2020-04-17 05:53:48 -04:00
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
2022-11-08 02:52:10 -05:00
plymouth-theme-spinner \
plymouth-theme-ubuntu-text \
2020-04-24 06:19:37 -04:00
ubuntu-desktop-minimal \
2020-05-03 09:04:34 -04:00
ubuntu-gnome-wallpapers \
snapd
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Install Graphical installer... "
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
ubiquity \
ubiquity-casper \
ubiquity-frontend-gtk \
ubiquity-slideshow-ubuntu \
ubiquity-ubuntu-artwork
2020-04-17 05:53:48 -04:00
2022-09-29 09:25:08 -04:00
echo >&2 "===]> Info: Install useful applications and sound configuration... "
2020-04-17 05:53:48 -04:00
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
2020-04-24 06:19:37 -04:00
git \
curl \
nano \
make \
gcc \
2020-10-18 08:26:37 -04:00
dkms \
2022-09-29 09:25:08 -04:00
iwd \
2022-11-06 06:44:05 -05:00
apple-t2-audio-config
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Change initramfs format (for grub)... "
sed -i "s/COMPRESS=lz4/COMPRESS=gzip/g" "/etc/initramfs-tools/initramfs.conf"
2020-04-17 05:53:48 -04:00
2022-01-22 11:03:30 -05:00
echo >&2 "===]> Info: Configure drivers... "
2020-04-17 12:31:32 -04:00
# thunderbolt is working for me.
#printf '\nblacklist thunderbolt' >>/etc/modprobe.d/blacklist.conf
2020-04-24 06:19:37 -04:00
2022-02-06 00:27:08 -05:00
printf 'apple-bce' >>/etc/modules-load.d/t2.conf
2023-02-22 15:12:19 -05:00
#printf '\n### apple-bce start ###\nsnd\nsnd_pcm\napple-bce\n### apple-bce end ###' >>/etc/initramfs-tools/modules
#printf '\n# display f* key in touchbar\noptions apple-ib-tb fnmode=1\n' >> /etc/modprobe.d/apple-tb.conf
2022-02-06 00:27:08 -05:00
#printf '\n# delay loading of the touchbar driver\ninstall apple-ib-tb /bin/sleep 7; /sbin/modprobe --ignore-install apple-ib-tb' >> /etc/modprobe.d/delay-tb.conf
2022-02-03 08:16:56 -05:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Update initramfs... "
2020-04-17 12:31:32 -04:00
2020-04-24 06:19:37 -04:00
## Add custom drivers to be loaded at boot
/usr/sbin/depmod -a "${KERNEL_VERSION}"
update-initramfs -u -v -k "${KERNEL_VERSION}"
2020-04-17 12:31:32 -04:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Remove unused applications ... "
2020-04-17 05:53:48 -04:00
apt-get purge -y -qq \
2020-04-24 06:19:37 -04:00
transmission-gtk \
transmission-common \
gnome-mahjongg \
gnome-mines \
gnome-sudoku \
aisleriot \
hitori \
xiterm+thai \
make \
gcc \
vim \
2020-05-03 09:04:34 -04:00
binutils \
linux-generic \
2023-04-30 09:12:53 -04:00
linux-headers-6.2.0-20 \
linux-headers-6.2.0-20-generic \
2020-05-03 09:04:34 -04:00
linux-headers-generic \
2023-04-30 09:12:53 -04:00
linux-image-6.2.0-20-generic \
2020-05-03 09:04:34 -04:00
linux-image-generic \
2023-04-30 09:12:53 -04:00
linux-modules-6.2.0-20-generic \
linux-modules-extra-6.2.0-20-generic \
2023-01-18 05:19:54 -05:00
gedit
2020-04-17 05:53:48 -04:00
apt-get autoremove -y
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Reconfigure environment ... "
2020-04-17 05:53:48 -04:00
locale-gen --purge en_US.UTF-8 en_US
2020-04-24 06:19:37 -04:00
printf 'LANG="C.UTF-8"\nLANGUAGE="C.UTF-8"\n' >/etc/default/locale
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
cat <<EOF >/etc/NetworkManager/NetworkManager.conf
2020-04-17 05:53:48 -04:00
[main]
plugins=ifupdown,keyfile
2021-12-25 23:52:26 -05:00
2020-04-17 05:53:48 -04:00
[ifupdown]
managed=false
2021-12-25 23:52:26 -05:00
[device]
wifi.scan-rand-mac-address=no
2020-04-17 05:53:48 -04:00
EOF
dpkg-reconfigure network-manager
2020-10-18 08:26:37 -04:00
echo >&2 "===]> Info: Configure Network Manager to use iwd... "
mkdir -p /etc/NetworkManager/conf.d
2022-01-17 06:54:16 -05:00
printf '#[device]\n#wifi.backend=iwd\n' > /etc/NetworkManager/conf.d/wifi_backend.conf
#systemctl enable iwd.service
2020-04-17 05:53:48 -04:00
2020-04-24 06:19:37 -04:00
echo >&2 "===]> Info: Cleanup the chroot environment... "
2020-04-17 05:53:48 -04:00
truncate -s 0 /etc/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
apt-get clean
rm -rf /tmp/* ~/.bash_history
2020-04-17 12:31:32 -04:00
rm -rf /tmp/setup_files
2020-04-17 05:53:48 -04:00
umount -lf /dev/pts
umount -lf /sys
umount -lf /proc
export HISTSIZE=0