From 41611e5cf6e186b0f07e1ffb87b00ae85626773b Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 27 Dec 2015 20:20:38 +0000 Subject: [PATCH] Man-in-the-middle script to manipulate the xorriso run of grub-mkrescue --- Makefile.am | 1 + frontend/grub-mkrescue-sed.sh | 86 ++++++++++++++++++++++++++++++ xorriso/make_xorriso_standalone.sh | 23 +++++--- xorriso/xorriso_makefile_am.txt | 1 + 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100755 frontend/grub-mkrescue-sed.sh diff --git a/Makefile.am b/Makefile.am index 7d1b997c..b78120c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -263,6 +263,7 @@ EXTRA_DIST = \ frontend/xorriso-tcltk \ frontend/sh_on_named_pipes.sh \ frontend/xorriso_broker.sh \ + frontend/grub-mkrescue-sed.sh \ README \ AUTHORS \ CONTRIBUTORS \ diff --git a/frontend/grub-mkrescue-sed.sh b/frontend/grub-mkrescue-sed.sh new file mode 100755 index 00000000..37b8cb22 --- /dev/null +++ b/frontend/grub-mkrescue-sed.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +# Copyright (C) 2015 +# Thomas Schmitt , libburnia-project.org +# Provided under BSD license: Use, modify, and distribute as you like. + +echo >&2 +echo "frontend/grub-mkrescue-sed.sh manipulating xorriso arguments" >&2 +echo >&2 + +# This script may be handed by its absolute path to grub-mkrescue +# via option --xorriso= . E.g. +# +# mkdir minimal +# touch minimal/empty-file.txt +# grub-mkrescue -o output.iso minimal \ +# --xorriso=/home/thomas/xorriso-1.4.3./frontend/grub-mkrescue-sed.sh +# +# It will manipulate the xorriso arguments before +# they get executed by the neighboring ../../xorriso/xorriso program. +# +# In its current form it implements an experiment which should be +# accompanied by a xorriso from +# export CPPFLAGS="-DLibisofs_mjg_boot_for_grub2" +# ./configure && make clean && make + +# Variation settings: + +# First argument of -append_partition +partno=1 + +# Replacement for option --protective-msdos-label +protective="--protective-msdos-label" + +# "yes" make the script very verbous +debug=no + +if test "$debug" = yes +then + # Show arguments + echo "$0" >&2 + for i in "$@" + do + echo "|""$i""|" >&2 + done +fi + +# Look for the name of the /tmp directory with the GRUB2 files. +# It is the next argument after -r. +next_is_dir=0 +dir="." +for i in "$@" +do + if test x"$i" = x"-r" + then + next_is_dir=1 + elif test $next_is_dir = 1 + then + next_is_dir=0 + dir="$i" + fi +done + +if test "$debug" = yes +then + # Show files on disk + find "$dir" +fi + +# Exchange arguments for the experimental GRUB2 mjg layout +x=$(echo " $*" | sed \ + -e "s/-efi-boot-part --efi-boot-image/-no-pad -append_partition $partno 0xef \/tmp\/$(basename "$dir")\/efi.img/" \ + -e "s/--efi-boot efi\.img/-eltorito-alt-boot -e efi.img -no-emul-boot -isohybrid-gpt-basdat/" \ + -e "s/--protective-msdos-label/$protective/" \ + ) + +if test "$debug" = yes +then + echo "+ converted xorriso arguments:" >&2 + echo " $x" >&2 +fi + +# Run neighboring xorriso binary with the altered arguments +self_dir=$(dirname $(dirname "$0") ) +"$self_dir"/xorriso/xorriso $x + diff --git a/xorriso/make_xorriso_standalone.sh b/xorriso/make_xorriso_standalone.sh index 56b30fb6..201fb4ec 100755 --- a/xorriso/make_xorriso_standalone.sh +++ b/xorriso/make_xorriso_standalone.sh @@ -12,19 +12,25 @@ # libisofs jte libburn libisoburn # obtained according to instructions on http://libburnia-project.org. # -# Produce a necessary binary -# (cd libisoburn-develop/xorriso && \ -# cc -g -Wall -o unite_html_b_line unite_html_b_line.c ) -# # It creates a new directory tree # xorriso-standalone # for building GNU xorriso. +# The ./bootstrap script gets applied and a source tarball is made. # -# The ./bootstrap script gets applied and a source tarball -# is made. +# Before running this script one needs to apply autotools to libisoburn +# ./libisoburn-develop/bootstrap # -# From that tree can be build a binary xorriso/xorriso which at runtime -# does not depend on installed libburnia libraries. +# and to produce a necessary binary +# (cd libisoburn-develop/xorriso && \ +# cc -g -Wall -o unite_html_b_line unite_html_b_line.c ) +# +# Then run +# +# ./libisoburn-develop/xorriso/make_xorriso_standalone.sh +# +# From the emerging xorriso-standalone tree can be build a binary +# xorriso/xorriso +# which at runtime does not depend on installed libburnia libraries. # Execute in xorriso-standalone : # # ./configure && make @@ -246,6 +252,7 @@ copy_files \ frontend/xorriso-tcltk \ frontend/sh_on_named_pipes.sh \ frontend/xorriso_broker.sh \ + frontend/grub-mkrescue-sed.sh \ "$lone_dir"/frontend diff --git a/xorriso/xorriso_makefile_am.txt b/xorriso/xorriso_makefile_am.txt index ff7ffe05..ebf4bfbb 100644 --- a/xorriso/xorriso_makefile_am.txt +++ b/xorriso/xorriso_makefile_am.txt @@ -343,6 +343,7 @@ EXTRA_DIST = \ frontend/xorriso-tcltk \ frontend/sh_on_named_pipes.sh \ frontend/xorriso_broker.sh \ + frontend/grub-mkrescue-sed.sh \ libisofs/aaip-os-dummy.c \ libisofs/aaip-os-linux.c \ libisofs/aaip-os-freebsd.c \