2017-12-27 17:08:03 +01:00
|
|
|
#!/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/>. #
|
|
|
|
##############################################################################
|
2017-12-27 17:08:03 +01:00
|
|
|
|
|
|
|
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
|
2017-12-27 17:08:03 +01:00
|
|
|
|
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}"
|
2018-02-06 20:35:54 +01:00
|
|
|
export PARABOLATARBALL="${PARABOLATARBALL:-ParabolaARM-armv7-LATEST.tar.gz}"
|
2017-12-27 17:08:03 +01:00
|
|
|
|
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"
|
2017-12-27 17:08:03 +01:00
|
|
|
|
2018-02-01 10:54:30 +01:00
|
|
|
export _outfile="$_builddir/$(basename "$OUTFILE")"
|
2017-12-27 17:08:03 +01:00
|
|
|
|
2017-12-28 16:09:01 +01:00
|
|
|
# prepare the empty image
|
|
|
|
./src/stage0.sh
|
2017-12-27 17:08:03 +01:00
|
|
|
|
2018-02-06 20:35:54 +01:00
|
|
|
if [ -n "${ARCHBOOTSTRAP:-}" ]; then
|
2018-02-02 06:50:58 +01:00
|
|
|
# install a clean archlinux-arm system in the empty image
|
|
|
|
wget -nc http://os.archlinuxarm.org/os/$ARCHTARBALL
|
|
|
|
TARBALL="$ARCHTARBALL" ./src/stage1.sh
|
2017-12-27 17:08:03 +01:00
|
|
|
|
2018-02-02 06:50:58 +01:00
|
|
|
# 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
|
2018-02-02 06:50:58 +01:00
|
|
|
TARBALL="$PARABOLATARBALL" ./src/stage1.sh
|
|
|
|
fi
|
2017-12-27 17:08:03 +01:00
|
|
|
|
2017-12-29 13:33:41 +01:00
|
|
|
# setup package development environment
|
2018-02-01 10:54:30 +01:00
|
|
|
[ -n "${DEVSETUP:-}" ] && ./src/stage3.sh
|
2017-12-29 13:33:41 +01:00
|
|
|
|
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 :)"
|