Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2022-06-18 06:18:26 +0300
committerGitHub <noreply@github.com>2022-06-18 06:18:26 +0300
commit445da65ee91dc5186c4b0723bbddabaa4d8f9b78 (patch)
treefc740b064bed1a581f3fca4320cbfa651600e181 /src
parent1728012cdd75a7f17c42070abcb18f6dbd644ebd (diff)
parentc4c70d2f7abb177f8475f8bde749158bcd5e076b (diff)
Merge pull request #974 from KlaraSystems/hybrid_image
Add hybrid ISO image support
Diffstat (limited to 'src')
-rw-r--r--src/share/poudriere/image.sh5
-rw-r--r--src/share/poudriere/image_hybridiso.sh97
2 files changed, 100 insertions, 2 deletions
diff --git a/src/share/poudriere/image.sh b/src/share/poudriere/image.sh
index 02367241..bb7b3600 100644
--- a/src/share/poudriere/image.sh
+++ b/src/share/poudriere/image.sh
@@ -28,6 +28,7 @@
. ${SCRIPTPREFIX}/common.sh
. ${SCRIPTPREFIX}/image_dump.sh
. ${SCRIPTPREFIX}/image_firmware.sh
+. ${SCRIPTPREFIX}/image_hybridiso.sh
. ${SCRIPTPREFIX}/image_iso.sh
. ${SCRIPTPREFIX}/image_mfs.sh
. ${SCRIPTPREFIX}/image_rawdisk.sh
@@ -44,7 +45,7 @@ poudriere image [parameters] [options]
Parameters:
-j jail -- Jail
-t type -- Type of image can be one of
- -- iso, iso+mfs, iso+zmfs, usb, usb+mfs, usb+zmfs,
+ -- hybridiso, iso, iso+mfs, iso+zmfs, usb, usb+mfs, usb+zmfs,
rawdisk, zrawdisk, tar, firmware, rawfirmware,
dump, zfs+[raw|gpt|send[+full[+be]]], zsnapshot
@@ -353,7 +354,7 @@ while getopts "A:bB:c:f:h:i:j:m:n:o:p:P:R:s:S:t:vw:X:z:" FLAG; do
t)
MEDIATYPE=${OPTARG}
case ${MEDIATYPE} in
- iso|iso+mfs|iso+zmfs|usb|usb+mfs|usb+zmfs) ;;
+ hybridiso|iso|iso+mfs|iso+zmfs|usb|usb+mfs|usb+zmfs) ;;
rawdisk|zrawdisk|tar|firmware|rawfirmware) ;;
dump|zsnapshot) ;;
zfs|zfs+gpt|zfs+raw) ;;
diff --git a/src/share/poudriere/image_hybridiso.sh b/src/share/poudriere/image_hybridiso.sh
new file mode 100644
index 00000000..34a37c47
--- /dev/null
+++ b/src/share/poudriere/image_hybridiso.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2022 Christer Edwards <christer.edwards@gmail.com>
+# Copyright (c) 2021 Emmanuel Vadot <manu@FreeBSD.org>
+# Copyright (c) 2015 Baptiste Daroussin <bapt@FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+hybridiso_check()
+{
+
+ # Limitation on isos
+ case "${IMAGENAME}" in
+ ''|*[!A-Za-z0-9]*)
+ err 1 "Name can only contain alphanumeric characters"
+ ;;
+ esac
+
+ [ -f "${mnt}/boot/kernel/kernel" ] || \
+ err 1 "The ${MEDIATYPE} media type requires a jail with a kernel"
+}
+
+hybridiso_prepare()
+{
+}
+
+hybridiso_build()
+{
+
+ imageupper=$(echo ${IMAGENAME} | tr '[:lower:]' '[:upper:]')
+ cat >> ${WRKDIR}/world/etc/fstab <<-EOF
+ /dev/iso9660/${imageupper} / cd9660 ro 0 0
+ tmpfs /tmp tmpfs rw,mode=1777 0 0
+ EOF
+ do_clone -r ${WRKDIR}/world/boot ${WRKDIR}/out/boot
+}
+
+hybridiso_generate()
+{
+
+ FINALIMAGE=${IMAGENAME}.iso
+ espfilename=$(mktemp /tmp/efiboot.XXXXXX)
+ make_esp_file ${espfilename} 10 ${WRKDIR}/world/boot/loader.efi
+
+ # Make ISO image.
+ makefs -t cd9660 -o rockridge -o label=${IMAGENAME} \
+ -o publisher="poudriere" \
+ -o bootimage="i386;${WRKDIR}/out/boot/cdboot" \
+ -o bootimage="i386;${espfilename}" \
+ -o platformid=efi \
+ -o no-emul-boot "${OUTPUTDIR}/${FINALIMAGE}" ${WRKDIR}/world
+
+ # Find the EFI System Partition on the ISO.
+ for entry in $(etdump --format shell ${OUTPUTDIR}/${FINALIMAGE}); do
+ eval $entry
+ if [ "$et_platform" = "efi" ]; then
+ espstart=$(expr $et_lba \* 2048)
+ espsize=$(expr $et_sectors \* 512)
+ espparam="-p efi::$espsize:$espstart"
+ break
+ fi
+ done
+
+ # Create a GPT image with the partitions needed for hybrid boot.
+ imgsize=$(stat -f %z "${OUTPUTDIR}/${FINALIMAGE}")
+ mkimg -s gpt \
+ --capacity $imgsize \
+ -b "$WRKDIR/out/boot/pmbr" \
+ -p freebsd-boot:="$WRKDIR/out/boot/isoboot" \
+ $espparam \
+ -o "${OUTPUTDIR}/hybridiso.img"
+
+ # Drop the PMBR, GPT, and boot code into the System Area of the ISO.
+ dd if="${OUTPUTDIR}/hybridiso.img" of="${OUTPUTDIR}/${FINALIMAGE}" bs=32k count=1 conv=notrunc
+ rm -f "${OUTPUTDIR}/hybridiso.img"
+}