Refactor build scripts
This commit is contained in:
commit
4ee376a1f0
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
cache/
|
||||
out/
|
||||
raw/
|
||||
tmp/
|
1
.shellcheckrc
Normal file
1
.shellcheckrc
Normal file
|
@ -0,0 +1 @@
|
|||
external-sources=true
|
103
buildArchBase.sh
Executable file
103
buildArchBase.sh
Executable file
|
@ -0,0 +1,103 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
# Ensure that bsdtar is installed
|
||||
which bsdtar > /dev/null 2>&1 || {
|
||||
log_err "bsdtar not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Ensure that wget is installed
|
||||
which wget > /dev/null 2>&1 || {
|
||||
log_err "wget not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
IMAGE_NAME="ArchLinuxArmBase"
|
||||
|
||||
# Begin script
|
||||
|
||||
log "Start creating image: $IMAGE_NAME"
|
||||
create_image "$IMAGE_NAME"
|
||||
rootdir="$(mount_image "$IMAGE_NAME")"
|
||||
|
||||
# Prepare rootfs
|
||||
if [ ! -f ./cache/ArchLinuxARM-aarch64-latest.tar.gz ]; then
|
||||
log "Downloading rootfs tarball"
|
||||
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz -O ./cache/ArchLinuxARM-aarch64-latest.tar.gz
|
||||
fi
|
||||
|
||||
log "Extracting rootfs tarball"
|
||||
bsdtar -xpf ./cache/ArchLinuxARM-aarch64-latest.tar.gz -C "$rootdir"
|
||||
|
||||
prepare_chroot "$rootdir"
|
||||
|
||||
# Setup inet
|
||||
log "Setting up chroot"
|
||||
mv "$rootdir/etc/resolv.conf" "$rootdir/etc/resolv.conf.1"
|
||||
echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf"
|
||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||
|
||||
# Remove some junk
|
||||
log "Removing default kernel and settings"
|
||||
chroot "$rootdir" userdel -r alarm
|
||||
chroot "$rootdir" pacman -R linux-aarch64 linux-firmware --noconfirm
|
||||
|
||||
# Install minimal desktop environment
|
||||
log "Populating pacman key store"
|
||||
chroot "$rootdir" pacman-key --init
|
||||
chroot "$rootdir" pacman-key --populate archlinuxarm
|
||||
log "Updating system and installing needed packages"
|
||||
chroot "$rootdir" sed -i "s/#ParallelDownloads/ParallelDownloads/g" /etc/pacman.conf
|
||||
chroot "$rootdir" pacman -Syu sudo bluez bluez-utils vulkan-freedreno networkmanager --noconfirm
|
||||
|
||||
# Install nabu specific packages
|
||||
log "Installing nabu kernel, modules, firmwares and userspace daemons"
|
||||
cp ./packages/*.zst "$rootdir/opt/"
|
||||
chroot "$rootdir" bash -c "pacman -U /opt/*.zst --noconfirm"
|
||||
rm "$rootdir"/opt/*.zst
|
||||
|
||||
# Enable userspace daemons
|
||||
log "Enabling userspace daemons"
|
||||
chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs bluetooth NetworkManager
|
||||
|
||||
# Clean pacman cache
|
||||
log "Cleaning pacman cache"
|
||||
yes | chroot "$rootdir" pacman -Scc
|
||||
|
||||
log "Generating fstab"
|
||||
gen_fstab "$rootdir"
|
||||
|
||||
# Add %wheel to sudoers
|
||||
log "Adding %wheel to sudoers"
|
||||
echo "%wheel ALL=(ALL:ALL) ALL" > "$rootdir/etc/sudoers.d/00_image_builder"
|
||||
|
||||
# Set default timezone
|
||||
log "Setting default timezone"
|
||||
chroot "$rootdir" timedatectl set-timezone Europe/Moscow
|
||||
|
||||
# Generate en_US locale
|
||||
log "Generating en_US locale"
|
||||
sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g" "$rootdir/etc/locale.gen"
|
||||
chroot "$rootdir" locale-gen
|
||||
echo "LANG=en_US.UTF-8" > "$rootdir/etc/locale.conf"
|
||||
|
||||
# Restore resolv.conf symlink
|
||||
log "Restoring resolv.conf symlink"
|
||||
mv "$rootdir/etc/resolv.conf.1" "$rootdir/etc/resolv.conf"
|
||||
rm "$rootdir"/.* > /dev/null 2>&1
|
||||
|
||||
# Finish image
|
||||
log "Finishing image"
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
trim_image "$IMAGE_NAME"
|
||||
|
||||
log "Stop creating image: $IMAGE_NAME"
|
132
buildArchGnome.sh
Executable file
132
buildArchGnome.sh
Executable file
|
@ -0,0 +1,132 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
# Ensure that bsdtar is installed
|
||||
which bsdtar > /dev/null 2>&1 || {
|
||||
log_err "bsdtar not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
IMAGE_NAME="ArchLinuxArmGnome"
|
||||
|
||||
# Begin script
|
||||
|
||||
log "Start creating image: $IMAGE_NAME"
|
||||
create_image "$IMAGE_NAME"
|
||||
rootdir="$(mount_image "$IMAGE_NAME")"
|
||||
|
||||
# Prepare rootfs
|
||||
if [ ! -f ./cache/ArchLinuxARM-aarch64-latest.tar.gz ]; then
|
||||
log "Downloading rootfs tarball"
|
||||
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz -O ./cache/ArchLinuxARM-aarch64-latest.tar.gz
|
||||
fi
|
||||
|
||||
log "Extracting rootfs tarball"
|
||||
bsdtar -xpf ./cache/ArchLinuxARM-aarch64-latest.tar.gz -C "$rootdir"
|
||||
|
||||
prepare_chroot "$rootdir"
|
||||
|
||||
# Setup inet
|
||||
log "Setting up chroot"
|
||||
mv "$rootdir/etc/resolv.conf" "$rootdir/etc/resolv.conf.1"
|
||||
echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf"
|
||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||
|
||||
# Remove some junk
|
||||
log "Removing default kernel and settings"
|
||||
chroot "$rootdir" userdel -r alarm
|
||||
chroot "$rootdir" pacman -R linux-aarch64 linux-firmware --noconfirm
|
||||
|
||||
# Install minimal desktop environment
|
||||
log "Populating pacman key store"
|
||||
chroot "$rootdir" pacman-key --init
|
||||
chroot "$rootdir" pacman-key --populate archlinuxarm
|
||||
log "Updating system and installing needed packages"
|
||||
chroot "$rootdir" sed -i "s/#ParallelDownloads/ParallelDownloads/g" /etc/pacman.conf
|
||||
chroot "$rootdir" pacman -Syu sudo gdm gnome-menus gnome-backgrounds gnome-control-center gnome-keyring xdg-user-dirs-gtk nautilus xdg-desktop-portal-gnome gnome-console bluez bluez-utils vulkan-freedreno networkmanager --noconfirm
|
||||
|
||||
# Install nabu specific packages
|
||||
log "Installing nabu kernel, modules, firmwares and userspace daemons"
|
||||
cp ./packages/*.zst "$rootdir/opt/"
|
||||
chroot "$rootdir" bash -c "pacman -U /opt/*.zst --noconfirm"
|
||||
rm "$rootdir"/opt/*.zst
|
||||
|
||||
# Enable userspace daemons
|
||||
log "Enabling userspace daemons"
|
||||
chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs gdm bluetooth NetworkManager
|
||||
|
||||
# Clean pacman cache
|
||||
log "Cleaning pacman cache"
|
||||
yes | chroot "$rootdir" pacman -Scc
|
||||
|
||||
log "Generating fstab"
|
||||
gen_fstab "$rootdir"
|
||||
|
||||
# Add %wheel to sudoers
|
||||
log "Adding %wheel to sudoers"
|
||||
echo "%wheel ALL=(ALL:ALL) ALL" > "$rootdir/etc/sudoers.d/00_image_builder"
|
||||
|
||||
# Set default timezone
|
||||
log "Setting default timezone"
|
||||
chroot "$rootdir" timedatectl set-timezone Europe/Moscow
|
||||
|
||||
# Generate en_US locale
|
||||
log "Generating en_US locale"
|
||||
sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g" "$rootdir/etc/locale.gen"
|
||||
chroot "$rootdir" locale-gen
|
||||
echo "LANG=en_US.UTF-8" > "$rootdir/etc/locale.conf"
|
||||
|
||||
# +++ Rotate user desktop and gdm
|
||||
log "Configuring gdm and gnome"
|
||||
mkdir -p "$rootdir/etc/skel/.config"
|
||||
echo '<monitors version="2">
|
||||
<configuration>
|
||||
<logicalmonitor>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<scale>2</scale>
|
||||
<primary>yes</primary>
|
||||
<transform>
|
||||
<rotation>right</rotation>
|
||||
<flipped>no</flipped>
|
||||
</transform>
|
||||
<monitor>
|
||||
<monitorspec>
|
||||
<connector>DSI-1</connector>
|
||||
<vendor>unknown</vendor>
|
||||
<product>unknown</product>
|
||||
<serial>unknown</serial>
|
||||
</monitorspec>
|
||||
<mode>
|
||||
<width>1600</width>
|
||||
<height>2560</height>
|
||||
<rate>104.000</rate>
|
||||
</mode>
|
||||
</monitor>
|
||||
</logicalmonitor>
|
||||
</configuration>
|
||||
</monitors>
|
||||
' > "$rootdir/etc/skel/.config/monitors.xml"
|
||||
chroot "$rootdir" bash -c 'cp /etc/skel/.config/monitors.xml ~gdm/.config/'
|
||||
chroot "$rootdir" bash -c 'chown gdm: ~gdm/.config/'
|
||||
# ---
|
||||
|
||||
# Restore resolv.conf symlink
|
||||
log "Restoring resolv.conf symlink"
|
||||
mv "$rootdir/etc/resolv.conf.1" "$rootdir/etc/resolv.conf"
|
||||
rm "$rootdir"/.* > /dev/null 2>&1
|
||||
|
||||
# Finish image
|
||||
log "Finishing image"
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
trim_image "$IMAGE_NAME"
|
||||
|
||||
log "Stop creating image: $IMAGE_NAME"
|
116
buildArchPlasma.sh
Executable file
116
buildArchPlasma.sh
Executable file
|
@ -0,0 +1,116 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
# Ensure that bsdtar is installed
|
||||
which bsdtar > /dev/null 2>&1 || {
|
||||
echo "bsdtar not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
IMAGE_NAME="ArchLinuxArmPlasma"
|
||||
|
||||
# Begin script
|
||||
|
||||
log "Start creating image: $IMAGE_NAME"
|
||||
create_image "$IMAGE_NAME"
|
||||
rootdir="$(mount_image "$IMAGE_NAME")"
|
||||
|
||||
# Prepare rootfs
|
||||
if [ ! -f ./cache/ArchLinuxARM-aarch64-latest.tar.gz ]; then
|
||||
log "Downloading rootfs tarball"
|
||||
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz -O ./cache/ArchLinuxARM-aarch64-latest.tar.gz
|
||||
fi
|
||||
|
||||
log "Extracting rootfs tarball"
|
||||
bsdtar -xpf ./cache/ArchLinuxARM-aarch64-latest.tar.gz -C "$rootdir"
|
||||
|
||||
prepare_chroot "$rootdir"
|
||||
|
||||
# Setup inet
|
||||
log "Setting up chroot"
|
||||
mv "$rootdir/etc/resolv.conf" "$rootdir/etc/resolv.conf.1"
|
||||
echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf"
|
||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||
|
||||
# Remove some junk
|
||||
log "Removing default kernel and settings"
|
||||
chroot "$rootdir" userdel -r alarm
|
||||
chroot "$rootdir" pacman -R linux-aarch64 linux-firmware --noconfirm
|
||||
|
||||
# Install minimal desktop environment
|
||||
log "Populating pacman key store"
|
||||
chroot "$rootdir" pacman-key --init
|
||||
chroot "$rootdir" pacman-key --populate archlinuxarm
|
||||
log "Updating system and installing needed packages"
|
||||
chroot "$rootdir" sed -i "s/#ParallelDownloads/ParallelDownloads/g" /etc/pacman.conf
|
||||
chroot "$rootdir" pacman -Syu sudo plasma grub konsole dolphin ark bluez bluez-utils xorg-xrandr xorg-xinput qt5-virtualkeyboard vulkan-freedreno networkmanager --noconfirm
|
||||
|
||||
# Install nabu specific packages
|
||||
log "Installing nabu kernel, modules, firmwares and userspace daemons"
|
||||
cp ./packages/*.zst "$rootdir/opt/"
|
||||
chroot "$rootdir" bash -c "pacman -U /opt/*.zst --noconfirm"
|
||||
rm "$rootdir"/opt/*.zst
|
||||
|
||||
# Enable userspace daemons
|
||||
log "Enabling userspace daemons"
|
||||
chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs sddm bluetooth NetworkManager
|
||||
|
||||
# Clean pacman cache
|
||||
log "Cleaning pacman cache"
|
||||
yes | chroot "$rootdir" pacman -Scc
|
||||
|
||||
log "Generating fstab"
|
||||
gen_fstab "$rootdir"
|
||||
|
||||
# Add %wheel to sudoers
|
||||
log "Adding %wheel to sudoers"
|
||||
echo "%wheel ALL=(ALL:ALL) ALL" > "$rootdir/etc/sudoers.d/00_image_builder"
|
||||
|
||||
# Set default timezone
|
||||
log "Setting default timezone"
|
||||
chroot "$rootdir" timedatectl set-timezone Europe/Moscow
|
||||
|
||||
# Generate en_US locale
|
||||
log "Generating en_US locale"
|
||||
sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g" "$rootdir/etc/locale.gen"
|
||||
chroot "$rootdir" locale-gen
|
||||
echo "LANG=en_US.UTF-8" > "$rootdir/etc/locale.conf"
|
||||
|
||||
# +++ Setup sddm
|
||||
log "Configuring sddm"
|
||||
echo '#!/bin/sh
|
||||
# Xsetup - run as root before the login dialog appears
|
||||
xrandr --output DSI-1 --rotate right
|
||||
xinput set-prop "NVTCapacitiveTouchScreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1' > "$rootdir/usr/share/sddm/scripts/Xsetup"
|
||||
chmod 755 "$rootdir/usr/share/sddm/scripts/Xsetup"
|
||||
echo "[General]
|
||||
DisplayServer=x11
|
||||
InputMethod=qtvirtualkeyboard
|
||||
|
||||
[Theme]
|
||||
Current=breeze
|
||||
|
||||
[X11]
|
||||
DisplayCommand=/usr/share/sddm/scripts/Xsetup" > "$rootdir/usr/lib/sddm/sddm.conf.d/nabu.conf"
|
||||
chmod 644 "$rootdir/usr/lib/sddm/sddm.conf.d/nabu.conf"
|
||||
# ---
|
||||
|
||||
# Restore resolv.conf symlink
|
||||
log "Restoring resolv.conf symlink"
|
||||
mv "$rootdir/etc/resolv.conf.1" "$rootdir/etc/resolv.conf"
|
||||
rm "$rootdir"/.* > /dev/null 2>&1
|
||||
|
||||
# Finish image
|
||||
log "Finishing image"
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
trim_image "$IMAGE_NAME"
|
||||
|
||||
log "Stop creating image: $IMAGE_NAME"
|
131
buildFedoraWorkstation.sh
Executable file
131
buildFedoraWorkstation.sh
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source "common.sh"
|
||||
|
||||
# Ensure that pixz or xz is installed
|
||||
{ which pixz > /dev/null 2>&1 || which xz > /dev/null 2>&1; } || {
|
||||
log_err "pixz/xz not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Settings
|
||||
IMAGE_NAME="FedoraWorkstation"
|
||||
RAW_IMAGE=$(realpath "./cache/Fedora-Workstation.raw")
|
||||
|
||||
# Begin script
|
||||
|
||||
log "Start creating image: $IMAGE_NAME"
|
||||
|
||||
# Preparing generic image
|
||||
if [ ! -f "$RAW_IMAGE" ]; then
|
||||
log "Downloading generic image"
|
||||
wget "https://fedora.mirrorservice.org/fedora/linux/releases/40/Workstation/aarch64/images/Fedora-Workstation-40-1.14.aarch64.raw.xz" -O "$RAW_IMAGE".xz
|
||||
log "Extracting generic image"
|
||||
if which pixz > /dev/null 2>&1; then
|
||||
pixz -d "$RAW_IMAGE".xz
|
||||
elif which xz > /dev/null 2>&1; then
|
||||
xz -d "$RAW_IMAGE".xz
|
||||
fi
|
||||
fi
|
||||
|
||||
# +++ Extarct rootfs
|
||||
log "Mounting generic image"
|
||||
loop=$(losetup -Pf --show "$RAW_IMAGE")
|
||||
raw_mnt=$(mktemp --tmpdir=./tmp -d )
|
||||
mount "${loop}p3" "$raw_mnt"
|
||||
|
||||
log "Creating system image"
|
||||
create_image "$IMAGE_NAME" 30
|
||||
|
||||
rootdir=$(mount_image "$IMAGE_NAME")
|
||||
|
||||
log "Syncing system"
|
||||
rsync -a --info=progress2 --info=name0 "$raw_mnt/root/"* "$rootdir/"
|
||||
|
||||
log "Unmounting generic image"
|
||||
umount "$raw_mnt"
|
||||
rm -d "$raw_mnt"
|
||||
losetup -d "$loop"
|
||||
# ---
|
||||
|
||||
# Set hostname
|
||||
log "Setting hostname"
|
||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||
|
||||
prepare_chroot "$rootdir"
|
||||
|
||||
# Creaate mountpoins
|
||||
mkdir -p "$rootdir/tmp/"
|
||||
|
||||
# Remove some junk
|
||||
log "Removing default kernel and settings"
|
||||
rm -rf "$rootdir/usr/lib/kernel/install.d/10-devicetree.instal"
|
||||
chroot "$rootdir" /usr/bin/bash -c "rpm --noscripts -e gnome-initial-setup qcom-firmware atheros-firmware brcmfmac-firmware amd-ucode-firmware kernel-core nvidia-gpu-firmware kernel kernel-modules kernel-modules-core intel-audio-firmware cirrus-audio-firmware nvidia-gpu-firmware linux-firmware linux-firmware-whence intel-gpu-firmware amd-gpu-firmware libertas-firmware mt7xxx-firmware nxpwireless-firmware realtek-firmware tiwilink-firmware"
|
||||
chroot "$rootdir" rm -rf "/boot/*"
|
||||
|
||||
# Install nabu specific packages
|
||||
log "Installing nabu kernel, modules, firmwares and userspace daemons"
|
||||
cp ./packages/*.rpm "$rootdir/tmp/"
|
||||
chroot "$rootdir" /usr/bin/bash -c "rpm -i /tmp/*.rpm"
|
||||
chroot "$rootdir" /usr/bin/bash -c "rm /tmp/*.rpm"
|
||||
|
||||
|
||||
# Enable userspace daemons
|
||||
log "Enabling userspace daemons"
|
||||
chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs
|
||||
|
||||
log "Generating fstab"
|
||||
gen_fstab "$rootdir"
|
||||
|
||||
# Add %wheel to sudoers
|
||||
log "Adding %wheel to sudoers"
|
||||
echo "%wheel ALL=(ALL:ALL) ALL" > "$rootdir/etc/sudoers.d/00_image_builder"
|
||||
|
||||
# +++ Rotate gdm
|
||||
log "Configuring gdm and gnome"
|
||||
mkdir -p "$rootdir/etc/skel/.config"
|
||||
echo '<monitors version="2">
|
||||
<configuration>
|
||||
<logicalmonitor>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<scale>2</scale>
|
||||
<primary>yes</primary>
|
||||
<transform>
|
||||
<rotation>right</rotation>
|
||||
<flipped>no</flipped>
|
||||
</transform>
|
||||
<monitor>
|
||||
<monitorspec>
|
||||
<connector>DSI-1</connector>
|
||||
<vendor>unknown</vendor>
|
||||
<product>unknown</product>
|
||||
<serial>unknown</serial>
|
||||
</monitorspec>
|
||||
<mode>
|
||||
<width>1600</width>
|
||||
<height>2560</height>
|
||||
<rate>104.000</rate>
|
||||
</mode>
|
||||
</monitor>
|
||||
</logicalmonitor>
|
||||
</configuration>
|
||||
</monitors>
|
||||
' > "$rootdir/etc/skel/.config/monitors.xml"
|
||||
chroot "$rootdir" bash -c 'cp /etc/skel/.config/monitors.xml ~gdm/.config/'
|
||||
chroot "$rootdir" bash -c 'chown gdm: ~gdm/.config/'
|
||||
# ---
|
||||
|
||||
# Finish image
|
||||
log "Finishing image"
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
trim_image "$IMAGE_NAME"
|
||||
|
||||
log "Stop creating image: $IMAGE_NAME"
|
111
buildUbuntuDesktop.sh
Executable file
111
buildUbuntuDesktop.sh
Executable file
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
# Ensure that debootstarp is installed
|
||||
which debootstrap > /dev/null 2>&1 || {
|
||||
log_err "debootstrap not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Settings
|
||||
VERSION="noble"
|
||||
IMAGE_NAME="UbuntuDesktop_$VERSION"
|
||||
|
||||
# Begin script
|
||||
|
||||
log "Start creating image: $IMAGE_NAME"
|
||||
create_image "$IMAGE_NAME"
|
||||
rootdir="$(mount_image "$IMAGE_NAME")"
|
||||
|
||||
# Fetch base system
|
||||
log "Fetching base system"
|
||||
debootstrap --arch arm64 "$VERSION" "$rootdir" http://ports.ubuntu.com/ubuntu-ports || {
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
rm "$IMAGE_NAME"
|
||||
rm -rf "$rootdir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
prepare_chroot "$rootdir"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Setup inet
|
||||
log "Setting up chroot"
|
||||
echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf"
|
||||
echo "xiaomi-nabu" > "$rootdir/etc/hostname"
|
||||
echo "127.0.0.1 localhost
|
||||
127.0.1.1 xiaomi-nabu" > "$rootdir/etc/hosts"
|
||||
|
||||
# Update system and install desktop
|
||||
log "Updating system and installing needed packages"
|
||||
chroot "$rootdir" apt update
|
||||
chroot "$rootdir" apt upgrade -y
|
||||
chroot "$rootdir" apt install -y ubuntu-desktop bash-completion sudo ssh nano
|
||||
|
||||
# Install nabu specific packages
|
||||
log "Installing nabu kernel, modules, firmwares and userspace daemons"
|
||||
cp ./packages/*.deb "$rootdir/opt/"
|
||||
chroot "$rootdir" bash -c "dpkg -i /opt/*.deb"
|
||||
chroot "$rootdir" bash -c "rm /opt/*.deb"
|
||||
|
||||
# Clean apt cache
|
||||
log "Cleaning pacman cache"
|
||||
chroot "$rootdir" apt clean
|
||||
|
||||
# Enable userspace daemons
|
||||
log "Generating fstab"
|
||||
log "Enabling userspace daemons"
|
||||
chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs
|
||||
|
||||
gen_fstab "$rootdir"
|
||||
|
||||
# +++ Rotate gdm
|
||||
log "Configuring gdm and gnome"
|
||||
mkdir -p "$rootdir/etc/skel/.config"
|
||||
echo '<monitors version="2">
|
||||
<configuration>
|
||||
<logicalmonitor>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<scale>2</scale>
|
||||
<primary>yes</primary>
|
||||
<transform>
|
||||
<rotation>right</rotation>
|
||||
<flipped>no</flipped>
|
||||
</transform>
|
||||
<monitor>
|
||||
<monitorspec>
|
||||
<connector>DSI-1</connector>
|
||||
<vendor>unknown</vendor>
|
||||
<product>unknown</product>
|
||||
<serial>unknown</serial>
|
||||
</monitorspec>
|
||||
<mode>
|
||||
<width>1600</width>
|
||||
<height>2560</height>
|
||||
<rate>104.000</rate>
|
||||
</mode>
|
||||
</monitor>
|
||||
</logicalmonitor>
|
||||
</configuration>
|
||||
</monitors>
|
||||
' > "$rootdir/etc/skel/.config/monitors.xml"
|
||||
chroot "$rootdir" bash -c 'cp /etc/skel/.config/monitors.xml ~gdm/.config/'
|
||||
chroot "$rootdir" bash -c 'chown gdm: ~gdm/.config/'
|
||||
# ---
|
||||
|
||||
# Finish image
|
||||
log "Finishing image"
|
||||
detach_chroot "$rootdir"
|
||||
umount_image "$rootdir"
|
||||
trim_image "$IMAGE_NAME"
|
||||
|
||||
log "Stop creating image: $IMAGE_NAME"
|
23
cleanup.sh
Executable file
23
cleanup.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Restart as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
sudo -E "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
# shellcheck disable=SC2162
|
||||
if find ./tmp/ -mindepth 1 -maxdepth 1 | read; then
|
||||
for d in ./tmp/*/; do
|
||||
log "Unmounting $d"
|
||||
detach_chroot "$d"
|
||||
umount "$d/boot/simpleinit" 2> /dev/null
|
||||
umount "$d/boot/efi" 2> /dev/null
|
||||
umount ./tmp/tmp.* 2> /dev/null
|
||||
rm -d "$d"
|
||||
done
|
||||
else
|
||||
log_err "Nothing to clean"
|
||||
fi
|
120
common.sh
Executable file
120
common.sh
Executable file
|
@ -0,0 +1,120 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SIMPLEINIT_CMDLINE="root=PARTLABEL=linux loglevel=3 fbcon=rotate:1"
|
||||
|
||||
function log() {
|
||||
printf "\e[1m\e[92m==>\e[0m \e[1m%s\e[0m\n" "$*"
|
||||
}
|
||||
function log_err() {
|
||||
printf "\e[1m\e[31m==>\e[0m \e[1m%s\e[0m\n" "$*"
|
||||
}
|
||||
|
||||
function create_image() {
|
||||
name="$(realpath "./raw/${1}.img")"
|
||||
if [ -z "$2" ]; then
|
||||
size="10GB"
|
||||
else
|
||||
size="${2}GB"
|
||||
fi
|
||||
|
||||
if [ -f "$name" ]; then
|
||||
rm "$name"
|
||||
fi
|
||||
|
||||
truncate --size "$size" "$name"
|
||||
mkfs.ext4 "$name"
|
||||
}
|
||||
|
||||
function trim_image() {
|
||||
name="$(realpath "./raw/${1}.img")"
|
||||
e2fsck -f "$name"
|
||||
resize2fs -M "$name"
|
||||
}
|
||||
|
||||
function mount_image() {
|
||||
mountdir="$(mktemp --tmpdir=./tmp/ -d)"
|
||||
mountdir="$(realpath "$mountdir")"
|
||||
mount -o loop "./raw/${1}.img" "$mountdir"
|
||||
mkdir -p "$mountdir/boot/efi"
|
||||
mkdir -p "$mountdir/boot/simpleinit"
|
||||
mount -o size=512M,mode=0755 -t tmpfs nabu_esp "$mountdir/boot/efi"
|
||||
mount -o size=512M,mode=0755 -t tmpfs nabu_simpleinit "$mountdir/boot/simpleinit"
|
||||
sed "s|{cmdline}|$SIMPLEINIT_CMDLINE|g" < ./drop/simpleinit.uefi.cfg > "$mountdir/boot/simpleinit/simpleinit.uefi.cfg"
|
||||
printf "%s" "$mountdir"
|
||||
}
|
||||
|
||||
function gen_fstab() {
|
||||
if [ -d "${1}/etc/" ]; then
|
||||
[ -f "${1}/etc/fstab" ] && rm "${1}/etc/fstab"
|
||||
cp ./drop/fstab "${1}/etc/fstab"
|
||||
fi
|
||||
}
|
||||
|
||||
function umount_image() {
|
||||
if [ -d "${1}" ]; then
|
||||
rootdir="$(realpath "${1}")"
|
||||
mkdir "$rootdir/opt/nabu/" -p
|
||||
tar -cf "$rootdir/opt/nabu/efi.tar" -C "$rootdir/" boot/
|
||||
cp ./drop/postinstall "$rootdir/opt/nabu/postinstall"
|
||||
chmod +x "$rootdir/opt/nabu/postinstall"
|
||||
umount "$rootdir/boot/efi"
|
||||
umount "$rootdir/boot/simpleinit"
|
||||
umount "$rootdir"
|
||||
rm -d "$rootdir"
|
||||
fi
|
||||
}
|
||||
|
||||
function prepare_chroot() {
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\$PATH
|
||||
if [ -d "$1" ]; then
|
||||
rootdir="$(realpath "$1")"
|
||||
|
||||
mount --bind /proc "$rootdir/proc"
|
||||
mount --bind /sys "$rootdir/sys"
|
||||
mount --bind /dev "$rootdir/dev"
|
||||
mount --bind /dev/pts "$rootdir/dev/pts"
|
||||
fi
|
||||
|
||||
if uname -m | grep -q aarch64 || [ -f "/proc/sys/fs/binfmt_misc/qemu-aarch64" ]; then
|
||||
echo "Cancel qemu install for arm64"
|
||||
else
|
||||
wget -N https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static -O ./cache/qemu-aarch64-static
|
||||
install -m755 ./cache/qemu-aarch64-static "$rootdir/"
|
||||
|
||||
# shellcheck disable=SC2028
|
||||
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register
|
||||
|
||||
# shellcheck disable=SC2028
|
||||
echo ':aarch64ld:M::\x7fELF\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
function detach_chroot() {
|
||||
if [ -d "$1" ]; then
|
||||
rootdir=$(realpath "$1")
|
||||
blocking=$(lsof -t "$rootdir")
|
||||
if [ -n "$blocking" ]; then
|
||||
kill -9 "$blocking"
|
||||
fi
|
||||
killall gpg-agent > /dev/null 2>&1
|
||||
umount "$rootdir/proc"
|
||||
umount "$rootdir/sys"
|
||||
umount "$rootdir/dev/pts"
|
||||
umount "$rootdir/dev"
|
||||
fi
|
||||
|
||||
if uname -m | grep -q aarch64; then
|
||||
echo "Cancel qemu uninstall for arm64"
|
||||
else
|
||||
if [ -f "/proc/sys/fs/binfmt_misc/aarch64" ]; then
|
||||
echo -1 > /proc/sys/fs/binfmt_misc/aarch64
|
||||
fi
|
||||
if [ -f "/proc/sys/fs/binfmt_misc/aarch64ld" ]; then
|
||||
echo -1 > /proc/sys/fs/binfmt_misc/aarch64ld
|
||||
fi
|
||||
if [ -f "$rootdir/qemu-aarch64-static" ]; then
|
||||
rm "$rootdir/qemu-aarch64-static"
|
||||
fi
|
||||
fi
|
||||
}
|
3
drop/fstab
Normal file
3
drop/fstab
Normal file
|
@ -0,0 +1,3 @@
|
|||
PARTLABEL=linux / ext4 errors=remount-ro,x-systemd.growfs 0 1
|
||||
PARTLABEL=esp /boot/efi/ vfat umask=0022 0 1
|
||||
PARTLABEL=logfs /boot/simpleinit/ vfat umask=0022 0 1
|
2
drop/postinstall
Normal file
2
drop/postinstall
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
tar -xf /opt/nabu/efi.tar -C / || true
|
36
drop/simpleinit.uefi.cfg
Normal file
36
drop/simpleinit.uefi.cfg
Normal file
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## Simple Init Configuration Store For UEFI
|
||||
##
|
||||
|
||||
boot.configs.continue.mode = 10
|
||||
boot.configs.continue.show = false
|
||||
boot.configs.uefi_boot_menu.mode = 12
|
||||
boot.configs.uefi_boot_menu.show = false
|
||||
boot.configs.linux.mode = 8
|
||||
boot.configs.linux.desc = "Linux"
|
||||
boot.configs.linux.show = true
|
||||
boot.configs.linux.enabled = true
|
||||
boot.configs.linux.icon = "linux.svg"
|
||||
boot.configs.linux.extra.use_uefi = true
|
||||
boot.configs.linux.extra.kernel = "@part_esp:\\vmlinuz-6.1.10-nabu"
|
||||
boot.configs.linux.extra.dtb = "@part_esp:\\dtb-6.1.10-nabu"
|
||||
boot.configs.linux.extra.skip_kernel_fdt_cmdline = true
|
||||
boot.configs.linux.extra.update_splash = false
|
||||
boot.configs.linux.extra.cmdline = "{cmdline}"
|
||||
boot.default = "reboot-payload"
|
||||
boot.second = "simple-init"
|
||||
boot.uefi_probe = false
|
||||
boot.title = "Select OS"
|
||||
boot.timeout_text = "Timeout: %d"
|
||||
sw = 8
|
||||
gui.show_background = true
|
||||
gui.background = ""
|
||||
locates.part_logfs.by_disk_label = "gpt"
|
||||
locates.part_logfs.by_gpt_name = "logfs"
|
||||
locates.part_esp.by_disk_label = "gpt"
|
||||
locates.part_esp.by_gpt_name = "esp"
|
||||
locates.part_boot.by_disk_label = "gpt"
|
||||
locates.part_boot.by_gpt_name = "boot"
|
||||
|
||||
# vim: ts=8 sw=8
|
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1-aarch64.deb
Normal file
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1-aarch64.deb
Normal file
Binary file not shown.
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1-aarch64.pkg.tar.zst
Normal file
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1-aarch64.pkg.tar.zst
Normal file
Binary file not shown.
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1.aarch64.rpm
Normal file
BIN
packages/linux-nabu-6.1.10.c315c84157ae-1.aarch64.rpm
Normal file
Binary file not shown.
BIN
packages/linux-nabu-firmware-1.0.0-1-aarch64.deb
Executable file
BIN
packages/linux-nabu-firmware-1.0.0-1-aarch64.deb
Executable file
Binary file not shown.
BIN
packages/linux-nabu-firmware-1.0.0-1-aarch64.pkg.tar.zst
Executable file
BIN
packages/linux-nabu-firmware-1.0.0-1-aarch64.pkg.tar.zst
Executable file
Binary file not shown.
BIN
packages/linux-nabu-firmware-1.0.0-1.aarch64.rpm
Executable file
BIN
packages/linux-nabu-firmware-1.0.0-1.aarch64.rpm
Executable file
Binary file not shown.
BIN
packages/qcom-services-1.0.0-1-aarch64.deb
Executable file
BIN
packages/qcom-services-1.0.0-1-aarch64.deb
Executable file
Binary file not shown.
BIN
packages/qcom-services-1.0.0-1-aarch64.pkg.tar.zst
Executable file
BIN
packages/qcom-services-1.0.0-1-aarch64.pkg.tar.zst
Executable file
Binary file not shown.
BIN
packages/qcom-services-1.0.0-1.aarch64.rpm
Executable file
BIN
packages/qcom-services-1.0.0-1.aarch64.rpm
Executable file
Binary file not shown.
Loading…
Reference in a new issue