diff options
| author | David M. Syzdek <david@syzdek.net> | 2018-05-06 22:09:28 -0800 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2018-05-06 22:09:28 -0800 |
| commit | 1aa80374e2ebe600e7d14cf0183091d66274671e (patch) | |
| tree | bae5e44d555ec848755fcaf0f4d9d886998e05d3 /src | |
| parent | df6aab47e919d95335516fd756d4361f95262ea5 (diff) | |
| download | iperd-1aa80374e2ebe600e7d14cf0183091d66274671e.tar.gz iperd-1aa80374e2ebe600e7d14cf0183091d66274671e.tar.bz2 iperd-1aa80374e2ebe600e7d14cf0183091d66274671e.tar.xz iperd-1aa80374e2ebe600e7d14cf0183091d66274671e.zip | |
Updating UEFI ISO to use Grub2 instead of pxelinux
Diffstat (limited to 'src')
| -rw-r--r-- | src/distros/slackware/cfg.footer.iso.efi | 2 | ||||
| -rw-r--r-- | src/distros/slackware/cfg.header.iso.efi | 2 | ||||
| -rw-r--r-- | src/distros/slackware/cfg.label.iso.efi | 7 | ||||
| -rw-r--r-- | src/grub/Makefile.grub | 125 | ||||
| -rw-r--r-- | src/grub/grub-header.cfg | 39 | ||||
| -rw-r--r-- | src/grub/grub-stub.cfg | 15 | ||||
| -rwxr-xr-x | src/scripts/genfiles.sh | 37 | ||||
| -rw-r--r-- | src/scripts/iso-efiboot.sh | 190 |
8 files changed, 202 insertions, 215 deletions
diff --git a/src/distros/slackware/cfg.footer.iso.efi b/src/distros/slackware/cfg.footer.iso.efi new file mode 100644 index 0000000..7e9861c --- /dev/null +++ b/src/distros/slackware/cfg.footer.iso.efi | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | } | ||
| 2 | |||
diff --git a/src/distros/slackware/cfg.header.iso.efi b/src/distros/slackware/cfg.header.iso.efi new file mode 100644 index 0000000..2926eff --- /dev/null +++ b/src/distros/slackware/cfg.header.iso.efi | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | |||
| 2 | submenu "Slackware Linux Installers" { | ||
diff --git a/src/distros/slackware/cfg.label.iso.efi b/src/distros/slackware/cfg.label.iso.efi new file mode 100644 index 0000000..a6163a9 --- /dev/null +++ b/src/distros/slackware/cfg.label.iso.efi | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | menuentry "Slackware Linux @VERSION@ Install (@CODENAME@ bits)" { | ||
| 2 | echo "Loading /boot/slack@ARCH@/@VERSION@/bzImage ..." | ||
| 3 | linux /boot/slack@ARCH@/@VERSION@/bzImage \ | ||
| 4 | load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 nomodeset | ||
| 5 | echo "Loading /boot/slack@ARCH@/@VERSION@/initrd ..." | ||
| 6 | initrd /boot/slack@ARCH@/@VERSION@/initrd | ||
| 7 | } | ||
diff --git a/src/grub/Makefile.grub b/src/grub/Makefile.grub new file mode 100644 index 0000000..fabc88d --- /dev/null +++ b/src/grub/Makefile.grub | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | # | ||
| 2 | # IP Engineering Rescue Disk | ||
| 3 | # Copyright (C) 2018 David M. Syzdek <david@syzdek.net>. | ||
| 4 | # | ||
| 5 | # @SYZDEK_BSD_LICENSE_START@ | ||
| 6 | # | ||
| 7 | # Redistribution and use in source and binary forms, with or without | ||
| 8 | # modification, are permitted provided that the following conditions are | ||
| 9 | # met: | ||
| 10 | # | ||
| 11 | # * Redistributions of source code must retain the above copyright | ||
| 12 | # notice, this list of conditions and the following disclaimer. | ||
| 13 | # * Redistributions in binary form must reproduce the above copyright | ||
| 14 | # notice, this list of conditions and the following disclaimer in the | ||
| 15 | # documentation and/or other materials provided with the distribution. | ||
| 16 | # * Neither the name of David M. Syzdek nor the | ||
| 17 | # names of its contributors may be used to endorse or promote products | ||
| 18 | # derived from this software without specific prior written permission. | ||
| 19 | # | ||
| 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| 21 | # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| 22 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 23 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR | ||
| 24 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 28 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 29 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 30 | # SUCH DAMAGE. | ||
| 31 | # | ||
| 32 | # @SYZDEK_BSD_LICENSE_END@ | ||
| 33 | # | ||
| 34 | |||
| 35 | |||
| 36 | CLEANFILES += boot/grub | ||
| 37 | GRUB_CONFIGS = \ | ||
| 38 | boot/grub/grub.cfg | ||
| 39 | GRUB_INCLUDES = \ | ||
| 40 | var/config/grub.inc | ||
| 41 | GRUB_BINARIES = \ | ||
| 42 | EFI/BOOT/efiboot.img | ||
| 43 | GRUB_MODULES = \ | ||
| 44 | efi_gop efi_uga \ | ||
| 45 | all_video video video_bochs video_cirrus video_fb \ | ||
| 46 | videoinfo \ | ||
| 47 | serial terminfo terminal \ | ||
| 48 | search search_fs_file search_fs_uuid search_label \ | ||
| 49 | udf iso9660 ext2 fat exfat ntfs hfsplus lvm \ | ||
| 50 | part_gpt part_msdos msdospart \ | ||
| 51 | diskfilter \ | ||
| 52 | parttool \ | ||
| 53 | probe \ | ||
| 54 | normal \ | ||
| 55 | acpi ohci uhci ahci ehci \ | ||
| 56 | cat ls chain configfile echo halt reboot \ | ||
| 57 | ls lsefimmap lsefisystab lsmmap lspci lsacpi lssal \ | ||
| 58 | linux | ||
| 59 | |||
| 60 | |||
| 61 | var/config/grub.inc: Makefile.config $(SYSLINUX_INC_DEPS) | ||
| 62 | bash ./src/scripts/genfiles.sh "$(@)" | ||
| 63 | @touch "$(@)" | ||
| 64 | |||
| 65 | |||
| 66 | boot/grub/grub.cfg: Makefile var/config/grub.inc src/grub/grub-header.cfg | ||
| 67 | @mkdir -p boot/grub | ||
| 68 | cat \ | ||
| 69 | src/grub/grub-header.cfg \ | ||
| 70 | var/config/grub.inc \ | ||
| 71 | > "$(@)" \ | ||
| 72 | || { rm -f "$(@)"; exit 1; } | ||
| 73 | @touch "$(@)" | ||
| 74 | |||
| 75 | |||
| 76 | boot/grub/images/bootia32.efi: Makefile | ||
| 77 | @mkdir -p boot/grub/images | ||
| 78 | grub-mkimage \ | ||
| 79 | -o "$(@)" \ | ||
| 80 | -c src/grub/grub-stub.cfg \ | ||
| 81 | -p /boot/grub \ | ||
| 82 | -O i386-efi \ | ||
| 83 | $(GRUB_MODULES) | ||
| 84 | |||
| 85 | |||
| 86 | boot/grub/images/bootx64.efi: Makefile | ||
| 87 | @mkdir -p boot/grub/images | ||
| 88 | grub-mkimage \ | ||
| 89 | -o "$(@)" \ | ||
| 90 | -c src/grub/grub-stub.cfg \ | ||
| 91 | -p /boot/grub \ | ||
| 92 | -O x86_64-efi \ | ||
| 93 | $(GRUB_MODULES) | ||
| 94 | |||
| 95 | |||
| 96 | EFI/BOOT/efiboot.img: boot/grub/images/bootia32.efi boot/grub/images/bootx64.efi | ||
| 97 | @rm -f "$(@)" | ||
| 98 | dd \ | ||
| 99 | if=/dev/zero \ | ||
| 100 | of="$(@)" \ | ||
| 101 | bs=512 \ | ||
| 102 | count=2880 \ | ||
| 103 | || { rm -f "$(@)"; exit 1; } | ||
| 104 | mkfs.msdos \ | ||
| 105 | -F 12 \ | ||
| 106 | -n 'EFIBOOT' \ | ||
| 107 | "$(@)" \ | ||
| 108 | || { rm -f $(@); exit 1; } | ||
| 109 | mmd \ | ||
| 110 | -i "$(@)" \ | ||
| 111 | ::EFI \ | ||
| 112 | || { rm -f $(@); exit 1; } | ||
| 113 | mmd \ | ||
| 114 | -i "$(@)" \ | ||
| 115 | ::EFI/BOOT \ | ||
| 116 | || { rm -f $(@); exit 1; } | ||
| 117 | mcopy \ | ||
| 118 | -i "$(@)" \ | ||
| 119 | boot/grub/images/bootx64.efi \ | ||
| 120 | ::EFI/BOOT/BOOTX64.EFI \ | ||
| 121 | || { rm -f $(@); exit 1; } | ||
| 122 | @touch "$(@)" | ||
| 123 | |||
| 124 | |||
| 125 | # end of makefile | ||
diff --git a/src/grub/grub-header.cfg b/src/grub/grub-header.cfg new file mode 100644 index 0000000..f3caa57 --- /dev/null +++ b/src/grub/grub-header.cfg | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | |||
| 2 | # configure serial console | ||
| 3 | serial --unit 0 --speed 9600 | ||
| 4 | terminal_input serial console | ||
| 5 | terminal_output serial console | ||
| 6 | |||
| 7 | # enable pager (when displaying text files) | ||
| 8 | set pager=1 | ||
| 9 | |||
| 10 | # customize terminal | ||
| 11 | terminfo -u serial vt100-color | ||
| 12 | set menu_color_normal="white/blue" | ||
| 13 | set menu_color_highlight="white/light-gray" | ||
| 14 | |||
| 15 | # load partition modules | ||
| 16 | insmod part_gpt | ||
| 17 | insmod part_msdos | ||
| 18 | insmod msdospart | ||
| 19 | insmod lvm | ||
| 20 | insmod diskfilter | ||
| 21 | insmod parttool | ||
| 22 | insmod probe | ||
| 23 | |||
| 24 | # Grub options | ||
| 25 | submenu --hotkey=g "Grub 2 (UEFI/ISO)" { | ||
| 26 | menuentry --hotkey=p 'List ACPI' { | ||
| 27 | lsacpi | ||
| 28 | } | ||
| 29 | menuentry --hotkey=p 'List PCI' { | ||
| 30 | lspci | ||
| 31 | } | ||
| 32 | menuentry --hotkey=r 'Reboot' { | ||
| 33 | reboot | ||
| 34 | } | ||
| 35 | menuentry --hotkey=h 'Halt' { | ||
| 36 | halt | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
diff --git a/src/grub/grub-stub.cfg b/src/grub/grub-stub.cfg new file mode 100644 index 0000000..dd1f9ff --- /dev/null +++ b/src/grub/grub-stub.cfg | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | |||
| 2 | insmod all_video | ||
| 3 | insmod efi_gop | ||
| 4 | insmod efi_uga | ||
| 5 | insmod video_bochs | ||
| 6 | insmod video_cirrus | ||
| 7 | |||
| 8 | insmod iso9660 | ||
| 9 | insmod udf | ||
| 10 | |||
| 11 | search --no-floppy --label IPEngRescueDisk --set root | ||
| 12 | set prefix=($root)/boot/grub | ||
| 13 | |||
| 14 | configfile /boot/grub/grub.cfg | ||
| 15 | |||
diff --git a/src/scripts/genfiles.sh b/src/scripts/genfiles.sh index 81cf4af..c257c34 100755 --- a/src/scripts/genfiles.sh +++ b/src/scripts/genfiles.sh | |||
| @@ -173,9 +173,8 @@ case "${REGEN_FILE}" in | |||
| 173 | 173 | ||
| 174 | all);; | 174 | all);; |
| 175 | makefile.config);; | 175 | makefile.config);; |
| 176 | var/config/grub.inc);; | ||
| 176 | var/config/isolinux.inc);; | 177 | var/config/isolinux.inc);; |
| 177 | var/config/isolia32.inc);; | ||
| 178 | var/config/isolx64.inc);; | ||
| 179 | var/config/pxelinux.inc);; | 178 | var/config/pxelinux.inc);; |
| 180 | var/config/pxelia32.inc);; | 179 | var/config/pxelia32.inc);; |
| 181 | var/config/pxelx64.inc);; | 180 | var/config/pxelx64.inc);; |
| @@ -186,9 +185,8 @@ case "${REGEN_FILE}" in | |||
| 186 | *) | 185 | *) |
| 187 | echo "Usage: ${PROG_NAME} all" 1>&2 | 186 | echo "Usage: ${PROG_NAME} all" 1>&2 |
| 188 | echo " ${PROG_NAME} Makefile.config" 1>&2 | 187 | echo " ${PROG_NAME} Makefile.config" 1>&2 |
| 188 | echo " ${PROG_NAME} var/config/grub.inc" 1>&2 | ||
| 189 | echo " ${PROG_NAME} var/config/isolinux.inc" 1>&2 | 189 | echo " ${PROG_NAME} var/config/isolinux.inc" 1>&2 |
| 190 | echo " ${PROG_NAME} var/config/isolia32.inc" 1>&2 | ||
| 191 | echo " ${PROG_NAME} var/config/isolx64.inc" 1>&2 | ||
| 192 | echo " ${PROG_NAME} var/config/pxelinux.inc" 1>&2 | 190 | echo " ${PROG_NAME} var/config/pxelinux.inc" 1>&2 |
| 193 | echo " ${PROG_NAME} var/config/pxelia32.inc" 1>&2 | 191 | echo " ${PROG_NAME} var/config/pxelia32.inc" 1>&2 |
| 194 | echo " ${PROG_NAME} var/config/pxelx64.inc" 1>&2 | 192 | echo " ${PROG_NAME} var/config/pxelx64.inc" 1>&2 |
| @@ -204,9 +202,8 @@ esac | |||
| 204 | if test "x${REGEN_FILE}" = "xall";then | 202 | if test "x${REGEN_FILE}" = "xall";then |
| 205 | REGEN_FILE="" | 203 | REGEN_FILE="" |
| 206 | REGEN_FILE="${REGEN_FILE} makefile.config" | 204 | REGEN_FILE="${REGEN_FILE} makefile.config" |
| 205 | REGEN_FILE="${REGEN_FILE} var/config/grub.inc" | ||
| 207 | REGEN_FILE="${REGEN_FILE} var/config/isolinux.inc" | 206 | REGEN_FILE="${REGEN_FILE} var/config/isolinux.inc" |
| 208 | REGEN_FILE="${REGEN_FILE} var/config/isolia32.inc" | ||
| 209 | REGEN_FILE="${REGEN_FILE} var/config/isolx64.inc" | ||
| 210 | REGEN_FILE="${REGEN_FILE} var/config/pxelinux.inc" | 207 | REGEN_FILE="${REGEN_FILE} var/config/pxelinux.inc" |
| 211 | REGEN_FILE="${REGEN_FILE} var/config/pxelia32.inc" | 208 | REGEN_FILE="${REGEN_FILE} var/config/pxelia32.inc" |
| 212 | REGEN_FILE="${REGEN_FILE} var/config/pxelx64.inc" | 209 | REGEN_FILE="${REGEN_FILE} var/config/pxelx64.inc" |
| @@ -223,33 +220,23 @@ for FILE in ${REGEN_FILE};do | |||
| 223 | || exit 1 | 220 | || exit 1 |
| 224 | ;; | 221 | ;; |
| 225 | 222 | ||
| 226 | var/config/isolinux.inc) | 223 | var/config/grub.inc) |
| 227 | generate_cfg \ | ||
| 228 | isolinux.inc \ | ||
| 229 | "cfg.header" \ | ||
| 230 | "cfg.label cfg.label.iso" \ | ||
| 231 | "cfg.footer" \ | ||
| 232 | "broken.iso" \ | ||
| 233 | || exit 1; | ||
| 234 | ;; | ||
| 235 | |||
| 236 | var/config/isolia32.inc) | ||
| 237 | generate_cfg \ | 224 | generate_cfg \ |
| 238 | isolia32.inc \ | 225 | grub.inc \ |
| 239 | "cfg.header.iso.efi" \ | 226 | "cfg.header.iso.efi" \ |
| 240 | "cfg.label.iso.efi" \ | 227 | "cfg.label.iso.efi" \ |
| 241 | "cfg.footer.iso.efi" \ | 228 | "cfg.footer.iso.efi" \ |
| 242 | "broken.iso broken.efi broken.efi32" \ | 229 | "broken.iso broken.efi" \ |
| 243 | || exit 1; | 230 | || exit 1; |
| 244 | ;; | 231 | ;; |
| 245 | 232 | ||
| 246 | var/config/isolx64.inc) | 233 | var/config/isolinux.inc) |
| 247 | generate_cfg \ | 234 | generate_cfg \ |
| 248 | isolx64.inc \ | 235 | isolinux.inc \ |
| 249 | "cfg.header.iso.efi" \ | 236 | "cfg.header" \ |
| 250 | "cfg.label.iso.efi" \ | 237 | "cfg.label cfg.label.iso" \ |
| 251 | "cfg.footer.iso.efi" \ | 238 | "cfg.footer" \ |
| 252 | "broken.iso broken.efi broken.efi64" \ | 239 | "broken.iso" \ |
| 253 | || exit 1; | 240 | || exit 1; |
| 254 | ;; | 241 | ;; |
| 255 | 242 | ||
diff --git a/src/scripts/iso-efiboot.sh b/src/scripts/iso-efiboot.sh deleted file mode 100644 index f3e5d68..0000000 --- a/src/scripts/iso-efiboot.sh +++ /dev/null | |||
| @@ -1,190 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # IP Engineering Rescue Disk | ||
| 4 | # Copyright (C) 2018 David M. Syzdek <david@syzdek.net>. | ||
| 5 | # | ||
| 6 | # @SYZDEK_BSD_LICENSE_START@ | ||
| 7 | # | ||
| 8 | # Redistribution and use in source and binary forms, with or without | ||
| 9 | # modification, are permitted provided that the following conditions are | ||
| 10 | # met: | ||
| 11 | # | ||
| 12 | # * Redistributions of source code must retain the above copyright | ||
| 13 | # notice, this list of conditions and the following disclaimer. | ||
| 14 | # * Redistributions in binary form must reproduce the above copyright | ||
| 15 | # notice, this list of conditions and the following disclaimer in the | ||
| 16 | # documentation and/or other materials provided with the distribution. | ||
| 17 | # * Neither the name of David M. Syzdek nor the | ||
| 18 | # names of its contributors may be used to endorse or promote products | ||
| 19 | # derived from this software without specific prior written permission. | ||
| 20 | # | ||
| 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| 22 | # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| 23 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 24 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR | ||
| 25 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 29 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 30 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 31 | # SUCH DAMAGE. | ||
| 32 | # | ||
| 33 | # @SYZDEK_BSD_LICENSE_END@ | ||
| 34 | # | ||
| 35 | |||
| 36 | # +-=-=-=-=-=-+ | ||
| 37 | # | | | ||
| 38 | # | Headers | | ||
| 39 | # | | | ||
| 40 | # +-=-=-=-=-=-+ | ||
| 41 | |||
| 42 | # set PROG_NAME and load profile | ||
| 43 | PROG_NAME="$(basename "${0}")" | ||
| 44 | IPERD_PROFILE="$(dirname "${0}")/iperd.profile" | ||
| 45 | if test ! -f "${IPERD_PROFILE}";then | ||
| 46 | echo "${PROG_NAME}: unable to find iperd.profile" 1>&2; | ||
| 47 | exit 1; | ||
| 48 | fi | ||
| 49 | . "${IPERD_PROFILE}" | ||
| 50 | |||
| 51 | |||
| 52 | # +-=-=-=-=-=-=-+ | ||
| 53 | # | | | ||
| 54 | # | Functions | | ||
| 55 | # | | | ||
| 56 | # +-=-=-=-=-=-=-+ | ||
| 57 | |||
| 58 | cleanup() | ||
| 59 | { | ||
| 60 | # unmount image | ||
| 61 | if test ! -z "${MKTEMP}";then | ||
| 62 | mount | grep "${MKTEMP}" && sudo umount -f "${MKTEMP}" | ||
| 63 | rm -Rf "${MKTEMP}" | ||
| 64 | unset MKTEMP | ||
| 65 | fi | ||
| 66 | |||
| 67 | # remove loop dev | ||
| 68 | test -z "${LOOPDEV}" || sudo losetup -d "${LOOPDEV}" | ||
| 69 | unset LOOPDEV | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | exit_witherr() | ||
| 74 | { | ||
| 75 | cleanup | ||
| 76 | rm -f "${OUTPUT}" | ||
| 77 | exit 1 | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | usage() | ||
| 82 | { | ||
| 83 | printf "Usage: %s [OPTIONS] <file>\n" "$PROG_NAME" | ||
| 84 | printf "OPTIONS:\n" | ||
| 85 | printf " -h display this message\n" | ||
| 86 | printf " -q quiet\n" | ||
| 87 | printf " -v verbose\n" | ||
| 88 | printf "\n" | ||
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | # +-=-=-=-=-=-=-+ | ||
| 93 | # | | | ||
| 94 | # | Main Body | | ||
| 95 | # | | | ||
| 96 | # +-=-=-=-=-=-=-+ | ||
| 97 | |||
| 98 | # set defaults | ||
| 99 | unset VERBOSE | ||
| 100 | unset MKTEMP | ||
| 101 | |||
| 102 | |||
| 103 | # parse CLI arguments | ||
| 104 | while getopts :hqs:t:v OPT; do | ||
| 105 | case ${OPT} in | ||
| 106 | h) usage; exit 0;; | ||
| 107 | v) VERBOSE="1";; | ||
| 108 | q) unset VERBOSE;; | ||
| 109 | ?) | ||
| 110 | echo "${PROG_NAME}: illegal option -- ${OPTARG}" 1>&2 | ||
| 111 | echo "Try '${PROG_NAME} -h' for more information." 1>&2 | ||
| 112 | exit 1; | ||
| 113 | ;; | ||
| 114 | *) | ||
| 115 | ;; | ||
| 116 | esac | ||
| 117 | done | ||
| 118 | shift "$((OPTIND-1))" | ||
| 119 | OUTPUT="${1}" | ||
| 120 | |||
| 121 | |||
| 122 | # check configuration options | ||
| 123 | if test -z "${OUTPUT}";then | ||
| 124 | echo "${PROG_NAME}: missing file" | ||
| 125 | echo "Try '${PROG_NAME} -h' for more information." 1>&2 | ||
| 126 | exit 1 | ||
| 127 | fi | ||
| 128 | |||
| 129 | |||
| 130 | # check for required files/directories/devices | ||
| 131 | for FILE in "${BASEDIR}/EFI/BOOT/BOOTX64.EFI" "${BASEDIR}/EFI/BOOT/BOOTIA32.EFI" \ | ||
| 132 | "${BASEDIR}/EFI/BOOT/ldlinux.e32" "${BASEDIR}/EFI/BOOT/ldlinux.e64" \ | ||
| 133 | "${BASEDIR}/EFI/BOOT/isolia32.cfg" "${BASEDIR}/EFI/BOOT/isolx64.cfg";do | ||
| 134 | if test ! -f "${FILE}";then | ||
| 135 | echo "${PROG_NAME}: $(basename "${FILE}"): file not found" | ||
| 136 | exit 1 | ||
| 137 | fi | ||
| 138 | done | ||
| 139 | if test -f "${OUTPUT}";then | ||
| 140 | echo "${PROG_NAME}: ${OUTPUT}: already exists" | ||
| 141 | exit 1 | ||
| 142 | fi | ||
| 143 | |||
| 144 | |||
| 145 | # set up exit traps | ||
| 146 | trap exit_witherr SIGHUP SIGINT SIGTERM | ||
| 147 | trap cleanup EXIT | ||
| 148 | |||
| 149 | |||
| 150 | # create empty 1900MB disk image | ||
| 151 | dd \ | ||
| 152 | if=/dev/zero \ | ||
| 153 | of="${OUTPUT}" \ | ||
| 154 | count=2880 \ | ||
| 155 | bs=512 \ | ||
| 156 | || { rm -f "${OUTPUT}"; exit 1; } | ||
| 157 | |||
| 158 | |||
| 159 | # create file-system | ||
| 160 | mkfs.msdos -F 12 -n 'EFIBOOT' "${OUTPUT}" || { rm -f "${OUTPUT}"; exit 1; } | ||
| 161 | |||
| 162 | |||
| 163 | # set up loop block device | ||
| 164 | LOOPDEV=$(sudo losetup -P -f --show "${OUTPUT}") | ||
| 165 | if test -z "${LOOPDEV}";then | ||
| 166 | rm -f "${OUTPUT}" | ||
| 167 | exit 1 | ||
| 168 | fi | ||
| 169 | |||
| 170 | |||
| 171 | # mount disk image | ||
| 172 | MKTEMP="$(mktemp -d -p "${BASEDIR}/tmp" efiboot.XXXXXX)" | ||
| 173 | if test -z "${MKTEMP}";then | ||
| 174 | rm -f "${OUTPUT}" | ||
| 175 | exit 1 | ||
| 176 | fi | ||
| 177 | sudo mount -o rw,uid=${USER} ${LOOPDEV} "${MKTEMP}" || exit_witherr | ||
| 178 | |||
| 179 | |||
| 180 | # create directory structure and copy files | ||
| 181 | mkdir -p "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 182 | cp "${BASEDIR}/EFI/BOOT/BOOTX64.EFI" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 183 | cp "${BASEDIR}/EFI/BOOT/BOOTIA32.EFI" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 184 | cp "${BASEDIR}/EFI/BOOT/ldlinux.e32" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 185 | cp "${BASEDIR}/EFI/BOOT/ldlinux.e64" "${MKTEMP}/EFI/BOOT/" || exit_witherr | ||
| 186 | cp "${BASEDIR}/EFI/BOOT/isolia32.cfg" "${MKTEMP}/EFI/BOOT/syslia32.cfg" || exit_witherr | ||
| 187 | cp "${BASEDIR}/EFI/BOOT/isolx64.cfg" "${MKTEMP}/EFI/BOOT/syslx64.cfg" || exit_witherr | ||
| 188 | |||
| 189 | |||
| 190 | # end of script | ||
