summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
a45f454)
Only x86_64 machines (i386, i686 etc.) use BIOS and have a 'syslinux'
package (currently a dependency of ipa-deployer).
Make ipa-deployer produce arch-specific binaries, adding support for
AArch64 architecture:
- syslinux should be a build dependency only on x86_64;
- diskimage-builder provided by CentOS repos is too old to properly
support AArch64, rely on PIP to install a working version;
- add EFI system partition (ESP) handling requirements (util-linux,
dosfstools, gdisk);
- DIB elements: AArch64 requires block-device-efi;
- iso-image-create: Add support for creating EFI images (new args
"-e", "-E" may be used to specify the path to efiboot.img,
respectively the EFI directory), handle syslinux only
on x86, bail if mkisofs fails;
- enable EFI support for x86_64 image too;
Change-Id: Id37164d5eadf5729b8aeb6da0617d3310ba1109b
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Source0: %{name}-%{version}.tar.gz
Vendor: %{_platform_vendor}
Source0: %{name}-%{version}.tar.gz
Vendor: %{_platform_vendor}
-BuildArch: noarch
-BuildRequires: diskimage-builder qemu-img-ev which sudo PyYAML e2fsprogs syslinux genisoimage wget kernel python2-ironic-python-agent python-ironic-lib python-devel
+BuildRequires: qemu-img-ev which sudo PyYAML e2fsprogs genisoimage wget kernel python2-ironic-python-agent python-ironic-lib python-devel xz python-pip gdisk dosfstools util-linux
+%ifarch x86_64 amd64
+BuildRequires: syslinux
+%endif
%define dib_selinuxfile elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore
%define dib_epel elements/epel/pre-install.d/05-rpm-epel-release
%define dib_selinuxfile elements/rpm-distro/cleanup.d/99-selinux-fixfiles-restore
%define dib_epel elements/epel/pre-install.d/05-rpm-epel-release
+%ifarch x86_64 amd64
+%define centos_cloudimg https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1801-01.qcow2
+%define centos_mirror http://mirror.centos.org/centos/7
+%else
+%define centos_cloudimg https://cloud.centos.org/altarch/7/images/aarch64/CentOS-7-aarch64-GenericCloud-1708.qcow2.xz
+%define centos_cloudimg_xz 1
+%define centos_mirror http://mirror.centos.org/altarch/7
+%define dib_block_device_efi 1
+%endif
+%define centos_efibootimg %{centos_mirror}/os/%{_arch}/images/efiboot.img
+%define centos_efidir %{centos_mirror}/os/%{_arch}/EFI
%description
Deployment image for ironic python agent image
%description
Deployment image for ironic python agent image
+sudo pip install diskimage-builder==2.26.1
sudo rm -rf %{python2_sitelib}/diskimage_builder/%{dib_selinuxfile} %{_datarootdir}§/diskimage-builder/%{dib_selinuxfile} %{python2_sitelib}/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release
cp /etc/yum.conf work/local.repo
sudo rm -rf %{python2_sitelib}/diskimage_builder/%{dib_selinuxfile} %{_datarootdir}§/diskimage-builder/%{dib_selinuxfile} %{python2_sitelib}/diskimage_builder/elements/epel/pre-install.d/05-rpm-epel-release
cp /etc/yum.conf work/local.repo
-wget --progress=dot:giga https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1801-01.qcow2 -O CentOS.qcow2
+wget --progress=dot:giga %{centos_cloudimg} -O CentOS.qcow2%{?centos_cloudimg_xz:.xz}
+%if 0%{?centos_cloudimg_xz:1}
+unxz CentOS.qcow2.xz
+%endif
+url=%{centos_efidir}/
+wget --progress=dot:giga %{centos_efibootimg} -O efiboot.img
+cut_dirs=$(echo $url | sed -re 's|.*://[^/]+/(.+)|\1|' -e 's|/$||' | grep -o / | wc -l)
+wget -N -r --no-host-directories --no-verbose --cut-dirs=${cut_dirs} --reject index.html* --no-parent $url
DIB_DEBUG_TRACE=1 \
ELEMENTS_PATH="${PWD}/work/dib-ipa-element/" \
DIB_LOCAL_IMAGE="file://${PWD}/CentOS.qcow2" \
DIB_YUM_REPO_CONF="work/local.repo" \
DIB_LOCAL_REPO="/usr/localrepo/" \
DIB_DEBUG_TRACE=1 \
ELEMENTS_PATH="${PWD}/work/dib-ipa-element/" \
DIB_LOCAL_IMAGE="file://${PWD}/CentOS.qcow2" \
DIB_YUM_REPO_CONF="work/local.repo" \
DIB_LOCAL_REPO="/usr/localrepo/" \
- break=after-error /usr/bin/disk-image-create --install-type package localrepo centos7 virtmedia-netconf ironic-agent
+ break=after-error /usr/bin/disk-image-create --install-type package localrepo centos7 virtmedia-netconf ironic-agent %{?dib_block_device_efi:block-device-efi}
- work/iso-image-create -o ./ironic-deploy.iso -i ./image.initramfs -k ./image.vmlinuz
+ work/iso-image-create -o ./ironic-deploy.iso -i ./image.initramfs -k ./image.vmlinuz -e ./efiboot.img -E ./EFI
else
echo "Failed to run disk-image-create"
fi
else
echo "Failed to run disk-image-create"
fi
-unlink /etc/udev/rules.d/80-net-name-slot.rules
+if [ -e /etc/udev/rules.d/80-net-name-slot.rules ]; then
+ unlink /etc/udev/rules.d/80-net-name-slot.rules
+fi
echo " -o output filename "
echo " -i initrd "
echo " -k kernel "
echo " -o output filename "
echo " -i initrd "
echo " -k kernel "
+ echo " -e efiboot.img "
+ echo " -E EFI directory "
# Parse command line options
# Parse command line options
-ARGS=`getopt -o "o:i:k:" -l "output,initrd,kernel:" \
+ARGS=`getopt -o "o:i:k:e:E:" -l "output,initrd,kernel,efiboot,EFI:" \
-n "$SCRIPTNAME" -- "$@"`
if [ $? -ne 0 ];
then
-n "$SCRIPTNAME" -- "$@"`
if [ $? -ne 0 ];
then
-o) OUTPUT_FILENAME=$2; shift 2 ;;
-i) INITRD=$2; shift 2 ;;
-k) KERNEL=$2; shift 2 ;;
-o) OUTPUT_FILENAME=$2; shift 2 ;;
-i) INITRD=$2; shift 2 ;;
-k) KERNEL=$2; shift 2 ;;
+ -e) EFIBOOT=$2; shift 2 ;;
+ -E) EFIDIR=$2; shift 2 ;;
# *) show_options ; exit 1 ;;
--) shift; break ;;
esac
# *) show_options ; exit 1 ;;
--) shift; break ;;
esac
+if [ -z "$EFIBOOT" ]; then
+ err_print "efiboot.img not provided."
+ show_options
+ exit 1
+fi
+
+if [ -z "$EFIDIR" ]; then
+ err_print "EFI directory not provided."
+ show_options
+ exit 1
+fi
+
# Create a temporary build directory for holiding the contents of iso
TMP_IMAGE_DIR="$TMP_BUILD_DIR/image"
v_print "Creating temporary directory $TMP_IMAGE_DIR"
mkdir -p "$TMP_IMAGE_DIR"
# Create a temporary build directory for holiding the contents of iso
TMP_IMAGE_DIR="$TMP_BUILD_DIR/image"
v_print "Creating temporary directory $TMP_IMAGE_DIR"
mkdir -p "$TMP_IMAGE_DIR"
-# Copy isolinux bin to the isolinux directory
-mkdir -p "$TMP_IMAGE_DIR/isolinux"
-v_print "Copying isolinux.bin"
-if [ -f /usr/share/syslinux/isolinux.bin ]
-then
- cp /usr/share/syslinux/isolinux.bin "$TMP_IMAGE_DIR/isolinux"
-
-elif [ -f /usr/lib/syslinux/isolinux.bin ]
-then
- cp /usr/lib/syslinux/isolinux.bin "$TMP_IMAGE_DIR/isolinux"
-else
- err_print "Could not find isolinux.bin. Install syslinux?"
- cleanup
- exit 1
+if [ "$(uname -m)" = 'x86_64' ]; then
+ # Copy isolinux bin to the isolinux directory
+ mkdir -p "$TMP_IMAGE_DIR/isolinux"
+ v_print "Copying isolinux.bin"
+ if [ -f /usr/share/syslinux/isolinux.bin ]
+ then
+ cp /usr/share/syslinux/isolinux.bin "$TMP_IMAGE_DIR/isolinux"
+
+ elif [ -f /usr/lib/syslinux/isolinux.bin ]
+ then
+ cp /usr/lib/syslinux/isolinux.bin "$TMP_IMAGE_DIR/isolinux"
+ else
+ err_print "Could not find isolinux.bin. Install syslinux?"
+ cleanup
+ exit 1
+ fi
# Copy initrd, kernel
v_print "Copying kernel to $TMP_IMAGE_DIR/vmlinuz"
cp $KERNEL "$TMP_IMAGE_DIR/vmlinuz"
# Copy initrd, kernel
v_print "Copying kernel to $TMP_IMAGE_DIR/vmlinuz"
cp $KERNEL "$TMP_IMAGE_DIR/vmlinuz"
-# Generate isolinux.cfg for default booting
-v_print "Generating isolinux.cfg"
+mkdir -p "$TMP_IMAGE_DIR/images"
+v_print "Copying efiboot image to $TMP_IMAGE_DIR/images/efiboot.img"
+cp $EFIBOOT "$TMP_IMAGE_DIR/images/efiboot.img"
+if [ $? -ne 0 ]; then
+ err_print "Failed to copy $EFIBOOT to $TMP_IMAGE_DIR/images"
+ cleanup
+ exit 1
+fi
+
+v_print "Copying EFI directory to $TMP_IMAGE_DIR/EFI"
+cp -r $EFIDIR "$TMP_IMAGE_DIR/EFI"
+if [ $? -ne 0 ]; then
+ err_print "Failed to copy $EFIDIR to $TMP_IMAGE_DIR/EFI"
+ cleanup
+ exit 1
+fi
+# Generate grub.cfg for default booting
+sed -i '/BEGIN/q' "$TMP_IMAGE_DIR/EFI/BOOT/grub.cfg"
+menuentry 'Install image' --class red --class gnu-linux --class gnu --class os {
+ linux /vmlinuz boot_method=vmedia console=tty0 console=ttyS1,115200 console=ttyS0,115200 console=ttyAMA0,115200 selinux=0
+ initrd /initrd
+}" >> "$TMP_IMAGE_DIR/EFI/BOOT/grub.cfg"
+
+if [ "$(uname -m)" = 'x86_64' ]; then
+ # Generate isolinux.cfg for default booting
+ v_print "Generating isolinux.cfg"
+ echo "\
DEFAULT install
LABEL install
menu label "Install image"
DEFAULT install
LABEL install
menu label "Install image"
append initrd=/initrd boot_method=vmedia console=tty0 console=ttyS1,115200 selinux=0 --
TIMEOUT 5
PROMPT 0 " > "$TMP_IMAGE_DIR/isolinux/isolinux.cfg"
append initrd=/initrd boot_method=vmedia console=tty0 console=ttyS1,115200 selinux=0 --
TIMEOUT 5
PROMPT 0 " > "$TMP_IMAGE_DIR/isolinux/isolinux.cfg"
# Convert relative path output filename to absolute path
echo $OUTPUT_FILENAME | grep -q '^/'
# Convert relative path output filename to absolute path
echo $OUTPUT_FILENAME | grep -q '^/'
OUTPUT_FILENAME="$PWD/$OUTPUT_FILENAME"
fi
OUTPUT_FILENAME="$PWD/$OUTPUT_FILENAME"
fi
+# On x86_64 platforms, use isolinux for BIOS support
+if [ "$(uname -m)" = 'x86_64' ]; then
+ MKISOFS_ARGS+=" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
+ -boot-load-size 4 -boot-info-table"
+fi
+
+# efiboot.img path is hard set, create an EFI compatible ISO
+MKISOFS_ARGS+=" -eltorito-alt-boot -e images/efiboot.img -no-emul-boot"
+
# Create the ISO
v_print "Generating the ISO"
# Create the ISO
v_print "Generating the ISO"
-cd $TMP_IMAGE_DIR && $MKISOFS -r -V "INSTALL_IMAGE" -cache-inodes -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o $OUTPUT_FILENAME .
+cd $TMP_IMAGE_DIR && $MKISOFS -r -V "INSTALL_IMAGE" -cache-inodes -J -l $MKISOFS_ARGS -o $OUTPUT_FILENAME .
+
+if [ $? -ne 0 ]; then
+ err_print "Failed generating the ISO"
+ cleanup
+ exit 1
+fi