2020-05-09 11:00:02 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
2018-07-11 00:32:08 +02:00
|
|
|
|
2020-06-15 23:27:21 +02:00
|
|
|
# This file is part of PrawnOS (https://www.prawnos.com)
|
2018-10-11 22:09:25 +02:00
|
|
|
# Copyright (c) 2018 Hal Emmerich <hal@halemmerich.com>
|
|
|
|
|
|
|
|
# PrawnOS is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
# PrawnOS 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 PrawnOS. If not, see <https://www.gnu.org/licenses/>.
|
2018-07-11 00:32:08 +02:00
|
|
|
|
2019-02-27 20:20:11 +01:00
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
|
|
|
echo "No kernel version supplied"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$2" ]
|
|
|
|
then
|
2020-01-11 21:56:45 +01:00
|
|
|
echo "No filesystem image supplied"
|
2019-02-27 20:20:11 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-01-11 21:56:45 +01:00
|
|
|
|
|
|
|
KVER=$1
|
|
|
|
OUTNAME=$2
|
|
|
|
|
2018-07-11 00:32:08 +02:00
|
|
|
outmnt=$(mktemp -d -p `pwd`)
|
|
|
|
outdev=/dev/loop7
|
|
|
|
|
2018-09-07 18:56:22 +02:00
|
|
|
build_resources=resources/BuildResources
|
2018-07-11 00:32:08 +02:00
|
|
|
|
2018-09-07 18:56:22 +02:00
|
|
|
#A hacky way to ensure the loops are properly unmounted and the temp files are properly deleted.
|
2019-10-13 00:39:17 +02:00
|
|
|
#Without this, a reboot is sometimes required to properly clean the loop devices and ensure a clean build
|
2018-07-11 00:32:08 +02:00
|
|
|
cleanup() {
|
|
|
|
set +e
|
|
|
|
|
2018-09-07 18:56:22 +02:00
|
|
|
umount -l $outmnt > /dev/null 2>&1
|
|
|
|
rmdir $outmnt > /dev/null 2>&1
|
|
|
|
losetup -d $outdev > /dev/null 2>&1
|
|
|
|
|
|
|
|
set +e
|
2018-07-11 00:32:08 +02:00
|
|
|
|
|
|
|
umount -l $outmnt > /dev/null 2>&1
|
|
|
|
rmdir $outmnt > /dev/null 2>&1
|
|
|
|
losetup -d $outdev > /dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2018-09-07 18:56:22 +02:00
|
|
|
trap cleanup INT TERM EXIT
|
2018-07-11 00:32:08 +02:00
|
|
|
|
|
|
|
#Mount the build filesystem image
|
|
|
|
|
2020-01-11 21:56:45 +01:00
|
|
|
losetup -P $outdev $OUTNAME
|
2019-09-21 06:50:08 +02:00
|
|
|
#mount the root filesystem
|
2019-10-13 00:39:17 +02:00
|
|
|
mount -o noatime ${outdev}p2 $outmnt
|
2018-07-11 00:32:08 +02:00
|
|
|
|
|
|
|
# put the kernel in the kernel partition, modules in /lib/modules and AR9271
|
|
|
|
# firmware in /lib/firmware
|
2020-06-19 23:21:18 +02:00
|
|
|
kernel_size=65536
|
|
|
|
#blank the kernel partition first, with 32MiB of zeros
|
|
|
|
dd if=/dev/zero of=${outdev}p1 conv=notrunc bs=512 count=$kernel_size
|
|
|
|
#now write the new kernel
|
2018-09-07 18:56:22 +02:00
|
|
|
dd if=build/linux-$KVER/vmlinux.kpart of=${outdev}p1 conv=notrunc
|
|
|
|
make -C build/linux-$KVER ARCH=arm INSTALL_MOD_PATH=$outmnt modules_install
|
2019-09-21 06:50:08 +02:00
|
|
|
|
|
|
|
# the ath9k firmware is built into the kernel image, so nothing else must be done
|
2018-07-11 00:32:08 +02:00
|
|
|
|
2018-09-15 22:19:54 +02:00
|
|
|
umount -l $outmnt > /dev/null 2>&1
|
|
|
|
rmdir $outmnt > /dev/null 2>&1
|
|
|
|
losetup -d $outdev > /dev/null 2>&1
|
2018-07-11 00:32:08 +02:00
|
|
|
echo "DONE!"
|
2018-09-15 22:19:54 +02:00
|
|
|
trap - INT TERM EXIT
|