Skip to content

Commit

Permalink
arm64 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Florent CARLI <[email protected]>
  • Loading branch information
insatomcat committed Jan 6, 2025
1 parent 3289da9 commit 689a642
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM debian:12
COPY etc_fai/apt/keys/fai-project.gpg /etc/apt/trusted.gpg.d/
RUN echo "deb [arch=amd64] http://fai-project.org/download bookworm koeln" > /etc/apt/sources.list.d/fai.list && \
RUN echo "deb http://fai-project.org/download bookworm koeln" > /etc/apt/sources.list.d/fai.list && \
apt-get update && \
apt-get -y upgrade && \
apt-get -y install fai-server fai-doc fai-setup-storage && \
apt-get -y install lftp curl whiptail && \
apt-get -y install lftp curl whiptail patch && \
apt-get -y install qemu-utils && \
apt-get -y install reprepro xorriso squashfs-tools vim
27 changes: 23 additions & 4 deletions build_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ if [ "$1" == "--custom" ]; then

fi

# ARM64 or AMD64
arch=$(uname -m)
if [ "$arch" == "aarch64" ]; then
bfile="BOOKWORM_ARM64.tar.xz"
else
bfile="BOOKWORM_AMD64.tar.xz"
fi

# Creating the NFSROOT
# Removing *.profile since we don't use them
# Removing 50-host-classes to prevent DEMO and FAIBASE to be added to the list of classes
Expand All @@ -147,11 +155,15 @@ $COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup bash -c "\
rm -f /ext/srv/fai/config/class/50-host-classes && \
echo \"rm -f /ext/srv/fai/config/class/*.profile\" && \
rm -f /ext/srv/fai/config/class/*.profile && \
echo \"patch /usr/sbin/fai-cd /etc/fai/fai-cd.patch -o /ext/fai-cd\" && \
patch /usr/sbin/fai-cd /etc/fai/fai-cd.patch -o /ext/fai-cd && chmod 755 /ext/fai-cd && \
echo \"patch /ext/srv/fai/config/scripts/GRUB_EFI/10-setup /etc/fai/10-setup.patch \" && \
patch /ext/srv/fai/config/scripts/GRUB_EFI/10-setup /etc/fai/10-setup.patch && \
echo \"SED\" && \
sed -i -e \"s|-f \\\"\\\$FAI_ROOT/usr/sbin/apt-cache|-f \\\"\\\$FAI_ROOT/usr/bin/apt-cache|\" /ext/nfsroot/sbin/install_packages && \
sed -i -e \"s/ --allow-change-held-packages//\" /ext/nfsroot/sbin/install_packages && \
echo \"wget -O /ext/srv/fai/config/basefiles/BOOKWORM64.tar.xz https://fai-project.org/download/basefiles/BOOKWORM64.tar.xz\" && \
wget -O /ext/srv/fai/config/basefiles/BOOKWORM64.tar.xz https://fai-project.org/download/basefiles/BOOKWORM64.tar.xz"
echo \"wget -O /ext/srv/fai/config/basefiles/${bfile} https://fai-project.org/download/basefiles/${bfile}\" && \
wget -O /ext/srv/fai/config/basefiles/${bfile} https://fai-project.org/download/basefiles/${bfile}"

# Starting the container to add stuff in it
$COMPOSECMD -f "$wd"/docker-compose.yml up --no-start fai-setup
Expand All @@ -165,14 +177,21 @@ $COMPOSECMD -f "$wd"/docker-compose.yml down
# List user defined Classes
userClasses=$(grep -Ev "^#|^$" "$wd"/user_classes.conf | tr '\n' ',' | sed -e "s/,$//")

# ARM64 or AMD64
arch=$(uname -m)
if [ "$arch" == "aarch64" ]; then
seapatharch="SEAPATH_ARM64"
else
seapatharch="SEAPATH_AMD64"
fi
# Creating the mirror
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,SEAPATH_HOST,${finalClasses}USERCUSTOMIZATION,${userClasses},LAST"
CLASSES="FAIBASE,DEBIAN,GRUB_EFI,SEAPATH_COMMON,SEAPATH_HOST,${finalClasses}USERCUSTOMIZATION,${userClasses},${seapatharch},LAST"
$COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-setup bash -c "\
cp /etc/fai/apt/keys/* /etc/apt/trusted.gpg.d/ &&\
fai-mirror -c $CLASSES /ext/mirror"

# Creating the ISO
$COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-cd fai-cd -f -m /ext/mirror /ext/seapath.iso
$COMPOSECMD -f "$wd"/docker-compose.yml run --rm fai-cd /ext/fai-cd -f -m /ext/mirror /ext/seapath.iso

# Retrieving the ISO from the volume
$COMPOSECMD -f "$wd"/docker-compose.yml up --no-start fai-setup
Expand Down
15 changes: 15 additions & 0 deletions etc_fai/10-setup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@@ -46,7 +46,13 @@
BOOT_DEVICE=$( lvs --noheadings -o devices $BOOT_DEVICE | sed -e 's/^*\([^(]*\)(.*$/\1/' )
fi

-opts="--no-floppy --target=x86_64-efi --modules=part_gpt"
+# ARM64 or AMD64
+arch=$(uname -m)
+if [ "$arch" == "aarch64" ]; then
+ opts="--no-floppy --modules=part_gpt"
+else
+ opts="--no-floppy --target=x86_64-efi --modules=part_gpt"
+fi

# Check if RAID is used for the boot device
if [[ $BOOT_DEVICE =~ '/dev/md' ]]; then
4 changes: 2 additions & 2 deletions etc_fai/apt/sources.list
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deb http://ftp.fr.debian.org/debian-security bookworm-security main contrib non-
deb http://ftp.fr.debian.org/debian bookworm-backports main contrib non-free

# repository that may contain newer fai packages for bookworm
deb [arch=amd64] http://fai-project.org/download bookworm koeln
deb http://fai-project.org/download bookworm koeln

#Elastic
deb [arch=amd64] https://artifacts.elastic.co/packages/8.x/apt stable main
deb https://artifacts.elastic.co/packages/8.x/apt stable main
41 changes: 41 additions & 0 deletions etc_fai/fai-cd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@@ -221,11 +221,11 @@
--output=/tmp/grubaa64.efi \
--locales="" \
"boot/grub/grub.cfg=/tmp/grub.cfg"
- mv $NFSROOT/tmp/grubaa64.efi $scratch
+ mv $NFSROOT/tmp/grubaa64.efi $scratch/BOOTAA64.EFI

mkfs.vfat -C $scratch/efiboot.img 6000 >/dev/null
- mmd -i $scratch/efiboot.img efi efi/boot
- mcopy -i $scratch/efiboot.img $scratch/grubaa64.efi ::efi/boot/
+ mmd -i $scratch/efiboot.img EFI EFI/boot
+ mcopy -i $scratch/efiboot.img $scratch/BOOTAA64.EFI ::EFI/boot/
else
die 11 "No grub-efi-arm64-bin installation found in NFSROOT. Aborting."
fi
@@ -392,6 +392,25 @@

echo -n "ISO image size and filename: "; du -h $isoname

+ unhide_dirs
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - -
+mkiso_arm64() {
+
+ echo "Writing FAI CD-ROM image to $isoname. This may need some time."
+ cp $scratch/efiboot.img $tmp/boot/grub/efi.img
+ xorriso -as mkisofs -r \
+ -volid "$vname" -appid "$aname" \
+ -J -joliet-long \
+ -e boot/grub/efi.img -no-emul-boot \
+ -append_partition 2 0xef $scratch/efiboot.img \
+ -partition_cyl_align all \
+ "$tmp" \
+ -o $isoname \
+ || die 12 "xorriso failed."
+
+ echo -n "ISO image size and filename: "; du -h $isoname
+
unhide_dirs
}
# - - - - - - - - - - - - - - - - - - - - - - - - - -
8 changes: 8 additions & 0 deletions srv_fai_config/class/98-seapath
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ echo DEBIAN FAIBASE BOOKWORM64 SEAPATH_COMMON SEAPATH_HOST
[ "$flag_kerberos" ] && echo "SEAPATH_KERBEROS"
[ "$flag_cockpit" ] && echo "SEAPATH_COCKPIT"

arch=$(uname -m)

if [ "$arch" == "aarch64" ]; then
echo "SEAPATH_ARM64"
else
echo "SEAPATH_AMD64"
fi

echo "USERCUSTOMIZATION"

exit 0
7 changes: 7 additions & 0 deletions srv_fai_config/package_config/SEAPATH_AMD64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PACKAGES install-norec
msr-tools
intel-cmt-cat
linux-image-rt-amd64
intel-microcode
grub-efi-amd64-signed
amd64-microcode
3 changes: 3 additions & 0 deletions srv_fai_config/package_config/SEAPATH_ARM64
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PACKAGES install-norec
linux-image-rt-arm64
grub-efi-arm64-signed
4 changes: 0 additions & 4 deletions srv_fai_config/package_config/SEAPATH_COMMON
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PACKAGES install-norec
amd64-microcode
apparmor-utils
at
audispd-plugins
Expand All @@ -14,13 +13,10 @@ docker.io
dstat
efibootmgr
gnupg
grub-efi-amd64-signed
intel-microcode
iptables-persistent
irqbalance
jq
lbzip2
linux-image-rt-amd64
linuxptp
lm-sensors
lsb-release
Expand Down
2 changes: 0 additions & 2 deletions srv_fai_config/package_config/SEAPATH_HOST
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ firmware-misc-nonfree
firmware-linux-nonfree
firmware-linux-free
gunicorn
intel-cmt-cat
ipmitool
libsnmp-extension-passpersist-perl
libvirt-clients
Expand All @@ -15,7 +14,6 @@ libvirt-daemon-driver-storage-rbd
libvirt-daemon-system
libxml2-utils
linux-perf
msr-tools
nginx
ntfs-3g
openvswitch-switch
Expand Down

0 comments on commit 689a642

Please sign in to comment.