59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# Copyright 2020, Stormux, <storm_dragon@linux-a11y.org>
|
|
#
|
|
# This is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free
|
|
# Software Foundation; either version 3, or (at your option) any later
|
|
# version.
|
|
#
|
|
# This software is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this package; see the file COPYING. If not, write to the Free
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
# 02110-1301, USA.
|
|
#
|
|
|
|
set -e # Don't want to destroy stuff if this goes majorly wrong.
|
|
# Args: <image_name> [size]
|
|
size="4G"
|
|
if [ $# -eq 0 ] ; then
|
|
echo "Usage: $0 <image_name> [size]" >&2
|
|
exit 1
|
|
fi
|
|
if [ -e "$1" ] ; then
|
|
echo "$1 exists, please remove or move it for this script to continue." >&2
|
|
exit 1
|
|
fi
|
|
if [ $# -eq 2 ] ; then
|
|
size="$2"
|
|
fi
|
|
if [ "$(whoami)" != "root" ] ; then
|
|
echo "Error: This script must be run as root." >&2
|
|
exit 1
|
|
fi
|
|
fallocate -l $size "$1"
|
|
loopdev="$(losetup --find --show "$1")"
|
|
parted --script ${loopdev} mklabel msdos mkpart primary fat32 0% 100M mkpart primary ext4 100M 100%
|
|
mkfs.vfat -F32 ${loopdev}p1
|
|
mkfs.ext4 -F ${loopdev}p2
|
|
mount ${loopdev}p2 /mnt
|
|
mkdir /mnt/boot
|
|
mount ${loopdev}p1 /mnt/boot
|
|
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz -O- | bsdtar -xpf - -C /mnt
|
|
arch-chroot /mnt << "EOF"
|
|
pacman-key --init
|
|
pacman-key --populate archlinuxarm
|
|
pacman -Syu --needed --noconfirm vim bash-completion espeakup base base-devel
|
|
mkdir -p /etc/systemd/system/sound.target.wants
|
|
ln -s /usr/lib/systemd/system/espeakup.service /etc/systemd/system/sound.target.wants/
|
|
echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers.d/wheel
|
|
EOF
|
|
umount -R /mnt
|
|
partx -d ${loopdev}
|
|
losetup --detach ${loopdev}
|