rootfsinstall: support for local-only forced installation and bind mounts before chroot

This commit is contained in:
Silvan Calarco 2015-04-30 13:12:34 +02:00
parent b1a1ff59e8
commit 9f751541bb

View File

@ -27,6 +27,7 @@ function usage() {
echo "-k kernel : extract and use specified kernel file from ROOTFS/boot/ for boot" echo "-k kernel : extract and use specified kernel file from ROOTFS/boot/ for boot"
echo "-k2 kernel : extract and use specified second kernel file from ROOTFS/boot/ for boot" echo "-k2 kernel : extract and use specified second kernel file from ROOTFS/boot/ for boot"
echo "-i packages : install packages using package manager in chroot" echo "-i packages : install packages using package manager in chroot"
echo "-l : force local installation only; don't perform installation from network"
echo "-p password : set given password for root user" echo "-p password : set given password for root user"
echo "-r mode : set given default video mode where applicable (e.g. -r 1920x1080-32@60)" echo "-r mode : set given default video mode where applicable (e.g. -r 1920x1080-32@60)"
echo "-y : assume yes to all questions (script mode)" echo "-y : assume yes to all questions (script mode)"
@ -106,6 +107,7 @@ while [ "$1" ]; do
INSTALLPACKAGES="$2" INSTALLPACKAGES="$2"
shift shift
;; ;;
-l) LOCALONLY=1 ;;
-p) [ "$2" ] || { -p) [ "$2" ] || {
echo "Error: -p option requires a password as argument; aborting." echo "Error: -p option requires a password as argument; aborting."
exit 1 exit 1
@ -264,7 +266,7 @@ mount $PARTITION2 $ROOTMP || {
echo "ERROR: unable to mount partition $PARTITION2; aborting." echo "ERROR: unable to mount partition $PARTITION2; aborting."
exit 1 exit 1
} }
trap "[ "$ROOTMP" -a -e $ROOTMP ] && umount $ROOTMP && rmdir $ROOTMP;[ "$BOOTMP" -a -e $BOOTMP ] && umount $BOOTMP && rmdir $BOOTMP" 0 HUP INT QUIT ABRT KILL TERM trap "[ "$ROOTMP" -a -e $ROOTMP ] && umount $ROOTMP/dev/pts $ROOTMP/dev $ROOTMP/proc $ROOTMP/sys $ROOTMP/run $ROOTMP && rmdir $ROOTMP;[ "$BOOTMP" -a -e $BOOTMP ] && umount $BOOTMP && rmdir $BOOTMP" 0 HUP INT QUIT ABRT KILL TERM
if [ "$BOOTFSTYPE" ]; then if [ "$BOOTFSTYPE" ]; then
mount $PARTITION1 $BOOTMP || { mount $PARTITION1 $BOOTMP || {
@ -289,6 +291,9 @@ fi
exit 1 exit 1
} }
echo "DONE" echo "DONE"
for b in dev dev/pts proc sys run; do
mount -o bind /$b $ROOTMP/$b
done
if [ "$ADDITIONALARCHIVE" ]; then if [ "$ADDITIONALARCHIVE" ]; then
echo "Uncompressing $ADDITIONALARCHIVE..." echo "Uncompressing $ADDITIONALARCHIVE..."
@ -319,7 +324,7 @@ if [ "$SETHOSTNAME" ]; then
sed -i "s|\(127\.0\.0\.1\W*\)\(.*\)|\1 $SETHOSTNAME.localdomain $SETHOSTNAME localhost.localdomain localhost|" $ROOTMP/etc/hosts sed -i "s|\(127\.0\.0\.1\W*\)\(.*\)|\1 $SETHOSTNAME.localdomain $SETHOSTNAME localhost.localdomain localhost|" $ROOTMP/etc/hosts
fi fi
if [ "$INSTALLPACKAGES" ]; then if [ "$INSTALLPACKAGES" -a "$LOCALONLY" != "1" ]; then
mv $ROOTMP/etc/resolv.conf $ROOTMP/etc/resolv.conf.rootfsinstall mv $ROOTMP/etc/resolv.conf $ROOTMP/etc/resolv.conf.rootfsinstall
cp /etc/resolv.conf $ROOTMP/etc/resolv.conf cp /etc/resolv.conf $ROOTMP/etc/resolv.conf
chroot $ROOTMP bash -c /etc/profile.d/gpg-key-openmamba.sh chroot $ROOTMP bash -c /etc/profile.d/gpg-key-openmamba.sh
@ -358,11 +363,11 @@ _EOF
elif [ "$TARGETDEVICE" = "rpi" ]; then elif [ "$TARGETDEVICE" = "rpi" ]; then
# fetch and install firmware files if missing # fetch and install firmware files if missing
RPI_FIRMWARE_FILES="bootcode.bin fixup_x.dat start_x.elf \ RPI_FIRMWARE_FILES="bootcode.bin fixup_x.dat start_x.elf \
bcm2708-rpi-b.dtb bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb" bcm2708-rpi-b.dtb cmdline.txt config.txt bcm2708-rpi-b-plus.dtb bcm2709-rpi-2-b.dtb"
for f in $RPI_FIRMWARE_FILES; do for f in $RPI_FIRMWARE_FILES; do
if [ -e $ROOTMP/boot/$f ]; then if [ -e $ROOTMP/boot/$f ]; then
cp $ROOTMP/boot/$f $BOOTMP/$f cp $ROOTMP/boot/$f $BOOTMP/$f
else elif [ "$f" != "cmdline.txt" -a "$f" != "config.txt" ]; then
echo "ERROR: firmware file $f for rpi is missing in /boot directory; aborting." echo "ERROR: firmware file $f for rpi is missing in /boot directory; aborting."
exit 1 exit 1
fi fi
@ -375,6 +380,7 @@ elif [ "$TARGETDEVICE" = "rpi" ]; then
cp $ROOTMP/boot/$USEKERNEL2 $KERNELDEST2 cp $ROOTMP/boot/$USEKERNEL2 $KERNELDEST2
# cmdline.txt : parameters passed to the kernel on boot # cmdline.txt : parameters passed to the kernel on boot
[ ! -e $ROOTMP/boot/cmdline.txt ] && \
echo "\ echo "\
dwc_otg.lpm_enable=0 \ dwc_otg.lpm_enable=0 \
root=/dev/mmcblk0p2 \ root=/dev/mmcblk0p2 \
@ -384,6 +390,7 @@ rootwait \
splash" > $BOOTMP/cmdline.txt splash" > $BOOTMP/cmdline.txt
# Create the kernel configuration file # Create the kernel configuration file
[ ! -e $ROOTMP/boot/config.txt ] && \
echo "\ echo "\
start_file=start_x.elf start_file=start_x.elf
fixup_file=fixup_x.dat fixup_file=fixup_x.dat