Package: fai-server
Version: 5.6

When running fai-make-nfsroot on amd64 or i386 architecture using e.g.
FAI_DEBOOTSTRAP_OPTS="--exclude=wget --arch armhf"
it does not use qemu-user-static option.

When running fai-make-nfsroot on amd64 or i386 architecture using e.g.
FAI_DEBOOTSTRAP_OPTS="--exclude=wget --arch=armhf"
it does use qemu-user-static option.

While both of above syntax are correct the following line within
fai-make-nfsroot only applies to "--arch=armhf":
263:    targetarch=$(expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch=\([^[:space:]]*\)' || true)

My suggestion is to replace this line with the following which handles
both types of given --arch parameter:
targetarch=$(echo "$(expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch=\([^[:space:]]*\)' || expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch\s\([^[:space:]]*\)'  || echo true)" | tail -n 1)

If "$targetarch" was set correctly fai-make-nfsroot fails with
following error if executed using e.g.
FAI_DEBOOTSTRAP_OPTS="--exclude=wget --arch=armhf":

Running hooks in /etc/ca-certificates/update.d...
done.
install_packages: executing chroot /srv/fai/nfsroot-armhf1 apt-get clean
install_packages: executing chroot /srv/fai/nfsroot-armhf1 dpkg
--configure --pending
install_packages: executing chroot /srv/fai/nfsroot-armhf1 dpkg -C
install_packages: executing chroot /srv/fai/nfsroot-armhf1 apt-get clean
chmod: missing operand after ‘a+r’
Try 'chmod --help' for more information.
ERROR: No initrd was created. Check the package name of the
linux-image package in /etc/fai/NFSROOT.
Log file written to /var/log/fai/fai-make-nfsroot.log

This is because armhf may be using vlinu?-* & initrd.img-* files for
booting, but not mandatory.
I have worked around this by not copy vlinu?-* & initrd.img-* if
FAI_DEBOOTSTRAP_OPTS is defined for armhf.
(Maybe there is a more general solution for this)

Below is the patch file content which applies the described changes:

--- fai-make-nfsroot    2018-04-08 12:00:46.608172000 +0200
+++ fai-make-nfsroot2   2018-04-08 12:22:15.749502200 +0200
@@ -260,7 +260,7 @@
     echo "Creating base system using debootstrap version $dversion"

     # Check if we need cross architecture debootstrap
-    targetarch=$(expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch=\([^[:space:]]*\)' || true)
+    targetarch=$(echo "$(expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch=\([^[:space:]]*\)' || expr "$FAI_DEBOOTSTRAP_OPTS" :
'.*--arch\s\([^[:space:]]*\)'  || echo true)" | tail -n 1)
     hostarch1=$(dpkg --print-architecture)
     hostarch2=$(dpkg --print-foreign-architectures)

@@ -543,8 +543,10 @@
     # tftp environment
     rm -f $NFSROOT/boot/*.bak
     mkdir -p $TFTPROOT/pxelinux.cfg
+    if [[ ! "${FAI_DEBOOTSTRAP_OPTS}" =~ '--arch'.'armhf' ]];then
     chmod a+r $NFSROOT/boot/initrd.img-* || die 9 "No initrd was
created. Check the package name of the linux-image package in
/etc/fai/NFSROOT."
     cp -p $v $NFSROOT/boot/vmlinu?-* $NFSROOT/boot/initrd.img-* $TFTPROOT
+    fi
     cp -u $v $NFSROOT/usr/lib/PXELINUX/pxelinux.0 $TFTPROOT
     if [ -f $NFSROOT/usr/lib/syslinux/modules/bios/ldlinux.c32 ]; then
        cp -u $NFSROOT/usr/lib/syslinux/modules/bios/ldlinux.c32 $TFTPROOT


Thank you for your support

Reply via email to