More progress, almost working but in broken state, will not successfully build currently.
This commit is contained in:
parent
b4c320c6ab
commit
9098eed102
@ -19,25 +19,93 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e # Don't want to destroy stuff if this goes majorly wrong.
|
set -e # Don't want to destroy stuff if this goes majorly wrong.
|
||||||
# Args: <image_name> [size]
|
|
||||||
size="4G"
|
|
||||||
if [ $# -eq 0 ] ; then
|
help() {
|
||||||
echo "Usage: $0 <image_name> [size]" >&2
|
echo -e "Usage:\n"
|
||||||
exit 1
|
echo "With no arguments, open the game launcher."
|
||||||
fi
|
for i in "${!command[@]}" ; do
|
||||||
if [ -e "$1" ] ; then
|
echo "-${i}: ${command[${i}]}"
|
||||||
echo "$1 exists, please remove or move it for this script to continue." >&2
|
done | sort
|
||||||
exit 1
|
exit 0
|
||||||
fi
|
}
|
||||||
if [ $# -eq 2 ] ; then
|
|
||||||
size="$2"
|
# Array of command line arguments
|
||||||
|
declare -A command=(
|
||||||
|
[h]="This help screen."
|
||||||
|
[n]="Image name, default is stormux-pi<3|4>-<yyyy-mm-dd>.img"
|
||||||
|
[s]="image size in GB, default is 4."
|
||||||
|
[v]="Version of the Raspberry Pi for which you are building. (3|4)"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Convert the keys of the associative array to a format usable by getopts
|
||||||
|
args="${!command[*]}"
|
||||||
|
args="${args//[[:space:]]/}"
|
||||||
|
while getopts "${args}" i ; do
|
||||||
|
case "$i" in
|
||||||
|
n)
|
||||||
|
shift
|
||||||
|
imageName="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
h) help;;
|
||||||
|
s)
|
||||||
|
shift
|
||||||
|
if [[ "$1" =~ ^[[:digit:]]+$ ]]; then
|
||||||
|
imageSize="${1}G"
|
||||||
|
else
|
||||||
|
echo "Image size must be numeric."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
shift
|
||||||
|
if [[ "$1" =~ ^[34]$ ]]; then
|
||||||
|
imageVersion="$1"
|
||||||
|
else
|
||||||
|
echo "Image version must be 3 for the Raspberry Pi 3, or 4 for the Raspberry Pi 4 (default)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# make sure variables are set, or use defaults.
|
||||||
|
export imageVersion="${imageVersion:-4}"
|
||||||
|
export imageSize="${imageSize:-4G}"
|
||||||
|
export imageName="${imageName:-stormux-pi${imageVersion}-$(date '+%Y-%m-%d').img}"
|
||||||
|
|
||||||
|
# Make sure the image file doesn't exist.
|
||||||
|
if [[ -e "$imageName" ]]; then
|
||||||
|
echo "${imageName} exists, please remove or move it for this script to continue."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make sure this script is ran as root.
|
||||||
if [ "$(whoami)" != "root" ] ; then
|
if [ "$(whoami)" != "root" ] ; then
|
||||||
echo "Error: This script must be run as root." >&2
|
echo "Error: This script must be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fallocate -l $size "$1"
|
|
||||||
loopdev="$(losetup --find --show "$1")"
|
# make sure the needed tools are installed
|
||||||
|
if [[ "$(uname -m)" == "x86_64" ]]; then
|
||||||
|
if ! pacman -Q qemu-user-static &> /dev/null ; then
|
||||||
|
echo "Please install pacman -Q qemu-user-static before continuing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
for i in parted wget ; do
|
||||||
|
if ! pacman -Q $i &> /dev/null ; then
|
||||||
|
echo "Please install $i before continuing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
fallocate -l $imageSize "$imageName"
|
||||||
|
loopdev="$(losetup --find --show "${imageName}")"
|
||||||
parted --script ${loopdev} mklabel msdos mkpart primary fat32 0% 100M mkpart primary ext4 100M 100%
|
parted --script ${loopdev} mklabel msdos mkpart primary fat32 0% 100M mkpart primary ext4 100M 100%
|
||||||
mkfs.vfat -F32 ${loopdev}p1
|
mkfs.vfat -F32 ${loopdev}p1
|
||||||
mkfs.ext4 -F ${loopdev}p2
|
mkfs.ext4 -F ${loopdev}p2
|
||||||
@ -46,12 +114,26 @@ mkdir /mnt/boot
|
|||||||
mount ${loopdev}p1 /mnt/boot
|
mount ${loopdev}p1 /mnt/boot
|
||||||
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz -O- | bsdtar -xpf - -C /mnt
|
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz -O- | bsdtar -xpf - -C /mnt
|
||||||
arch-chroot /mnt << "EOF"
|
arch-chroot /mnt << "EOF"
|
||||||
|
# set up pacman
|
||||||
pacman-key --init
|
pacman-key --init
|
||||||
pacman-key --populate archlinuxarm
|
pacman-key --populate archlinuxarm
|
||||||
pacman -Syu --needed --noconfirm vim bash-completion espeakup base base-devel
|
pacman -Syu --needed --noconfirm base base-devel bash-completion git
|
||||||
mkdir -p /etc/systemd/system/sound.target.wants
|
# Grant sudo privileges to the wheel group
|
||||||
ln -s /usr/lib/systemd/system/espeakup.service /etc/systemd/system/sound.target.wants/
|
|
||||||
echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers.d/wheel
|
echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers.d/wheel
|
||||||
|
# Set the distribution name.
|
||||||
|
echo 'Stormux \r (\l)' > /etc/issue
|
||||||
|
echo >> /etc/issue
|
||||||
|
# Change the alarm user to be stormux
|
||||||
|
usermod -a -g users -G wheel,audio,video -m -d /home/stormux -l stormux alarm
|
||||||
|
# Change to the stormux user and install some packages
|
||||||
|
sudo su - stormux
|
||||||
|
git clone https://aur.archlinux.org/yay.git
|
||||||
|
cd yay
|
||||||
|
makepkg -si
|
||||||
|
cd ~
|
||||||
|
rm -rf yay
|
||||||
|
yay -S fenrir-git magic-wormhole
|
||||||
|
exit
|
||||||
EOF
|
EOF
|
||||||
umount -R /mnt
|
umount -R /mnt
|
||||||
partx -d ${loopdev}
|
partx -d ${loopdev}
|
||||||
|
Loading…
Reference in New Issue
Block a user