parabola-vmbootstrap/create.sh

66 lines
2.6 KiB
Bash
Raw Normal View History

#!/bin/bash
2017-12-31 22:58:55 +01:00
##############################################################################
# parabola-arm-imagebuilder #
# #
# Copyright (C) 2017 Andreas Grapentin #
# #
# This program 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 of the License, or #
# (at your option) any later version. #
# #
# This program 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 program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
set -eu
2018-01-31 13:10:24 +01:00
die() { echo "$*" 1>&2 ; exit 1; }
2017-12-28 16:09:01 +01:00
# this script prepares an armv7h parabola image for use with start.sh
2018-01-31 13:10:24 +01:00
[ $(id -u) -ne 0 ] && die "must be root"
[ -z "${SUDO_USER:-}" ] && die "SUDO_USER not set"
2018-02-01 10:54:30 +01:00
export OUTFILE="${OUTFILE:-armv7h.img}"
export SIZE="${SIZE:-64G}"
export ARCHTARBALL="${ARCHTARBALL:-ArchLinuxARM-armv7-latest.tar.gz}"
export PARABOLATARBALL="${PARABOLATARBALL:-ParabolaARM-armv7-latest.tar.gz}"
2017-12-28 16:09:01 +01:00
export _builddir=build
2018-02-01 10:54:30 +01:00
mkdir -p "$_builddir"
chown $SUDO_USER "$_builddir"
2018-02-01 10:54:30 +01:00
export _outfile="$_builddir/$(basename "$OUTFILE")"
2017-12-28 16:09:01 +01:00
# prepare the empty image
./src/stage0.sh
if [ -z "${NOBOOTSTRAP:-}" ]; then
# install a clean archlinux-arm system in the empty image
wget -nc http://os.archlinuxarm.org/os/$ARCHTARBALL
TARBALL="$ARCHTARBALL" ./src/stage1.sh
# migrate the installed image to a clean parabola
./src/stage2.sh
else
# install a clean parabola-arm system in the empty image
2018-02-03 00:02:42 +01:00
wget -nc https://repo.parabola.nu/iso/arm/LATEST/$PARABOLATARBALL
TARBALL="$PARABOLATARBALL" ./src/stage1.sh
fi
# setup package development environment
2018-02-01 10:54:30 +01:00
[ -n "${DEVSETUP:-}" ] && ./src/stage3.sh
2017-12-28 16:09:01 +01:00
# cleanup
2018-01-31 13:10:24 +01:00
chown $SUDO_USER $_outfile
2018-02-01 10:54:30 +01:00
mv -v "$_outfile" "$OUTFILE"
rm -rf "$_builddir"
2017-12-28 16:09:01 +01:00
echo "all done :)"