Make mktemp invocations portable.
This commit is contained in:
parent
30385e717e
commit
b65ea15514
9 changed files with 46 additions and 38 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2010-10-18 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||
|
||||
Make mktemp invocations portable.
|
||||
|
||||
* grub-core/genmod.sh.in: Use mktemp with an explicit template, and
|
||||
exit if mktemp fails.
|
||||
* tests/grub_script_blockarg.in: Likewise.
|
||||
* tests/partmap_test.in: Likewise.
|
||||
* tests/util/grub-shell-tester.in: Likewise.
|
||||
* tests/util/grub-shell.in: Likewise.
|
||||
* util/powerpc/ieee1275/grub-mkrescue.in: Likewise.
|
||||
* Makefile.am: Likewise, and chain shell commands with `&&'
|
||||
instead of ';'.
|
||||
* util/grub-mkrescue.in: Use the same explicit template as above, and
|
||||
exit if mktemp fails.
|
||||
|
||||
2010-10-18 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
* util/grub.d/10_linux.in: Fix built-in initramfs image mode for
|
||||
|
|
16
Makefile.am
16
Makefile.am
|
@ -189,31 +189,31 @@ kopenbsd.init.x86_64: $(srcdir)/grub-core/tests/boot/kbsd.init-x86_64.S
|
|||
$(TARGET_CC) -o $@ $< -m64 -DTARGET_OPENBSD=1 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
|
||||
|
||||
linux-initramfs.i386: linux.init.i386 Makefile
|
||||
TDIR=`mktemp -d`; cp $< $$TDIR/init; (cd $$TDIR; echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@; rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR
|
||||
|
||||
linux-initramfs.x86_64: linux.init.x86_64 Makefile
|
||||
TDIR=`mktemp -d`; cp $< $$TDIR/init; (cd $$TDIR; echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@; rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && cp $< $$TDIR/init && (cd $$TDIR && echo ./init | cpio --quiet --dereference -o -H newc) | gzip > $@ && rm -rf $$TDIR
|
||||
|
||||
kfreebsd-mfsroot.i386.img: kfreebsd.init.i386 Makefile
|
||||
TDIR=`mktemp -d`; mkdir $$TDIR/dev; mkdir $$TDIR/sbin; cp $< $$TDIR/sbin/init; makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR; rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
|
||||
knetbsd.image.i386: knetbsd.init.i386 $(srcdir)/grub-core/tests/boot/kbsd.spec.txt
|
||||
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
|
||||
kopenbsd.image.i386: kopenbsd.init.i386 $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt
|
||||
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
|
||||
|
||||
kopenbsd.image.x86_64: kopenbsd.init.x86_64 $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt
|
||||
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 128k -f 10 -o minfree=0,version=1 $@ $$TDIR && bsdlabel -f -R $@ $(srcdir)/grub-core/tests/boot/kopenbsdlabel.txt && rm -rf $$TDIR || rm -f $@
|
||||
|
||||
knetbsd.miniroot-image.i386.img: knetbsd.image.i386 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386
|
||||
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.i386 $@
|
||||
|
||||
kfreebsd-mfsroot.x86_64.img: kfreebsd.init.x86_64 Makefile
|
||||
TDIR=`mktemp -d`; mkdir $$TDIR/dev; mkdir $$TDIR/sbin; cp $< $$TDIR/sbin/init; makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR; rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -t ffs -s 30m -f 1000 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
|
||||
knetbsd.image.x86_64: knetbsd.init.x86_64 $(srcdir)/grub-core/tests/boot/kbsd.spec.txt
|
||||
TDIR=`mktemp -d` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
TDIR=`mktemp -d "$${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` && mkdir $$TDIR/dev && mkdir $$TDIR/sbin && cp $< $$TDIR/sbin/init && makefs -F $(srcdir)/grub-core/tests/boot/kbsd.spec.txt -t ffs -s 64k -f 10 -o minfree=0,version=1 $@ $$TDIR && rm -rf $$TDIR
|
||||
|
||||
knetbsd.miniroot-image.x86_64.img: knetbsd.image.x86_64 $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64
|
||||
$(OBJCOPY) --add-section=miniroot=$< $(GRUB_PAYLOADS_DIR)/knetbsd.miniroot.x86_64 $@
|
||||
|
|
|
@ -38,10 +38,10 @@ rm -f $tmpfile $outfile
|
|||
objcopy -R .modname -R .moddeps $infile $tmpfile
|
||||
|
||||
# Attach .modname and .moddeps sections
|
||||
t1=`mktemp`
|
||||
t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
printf "$modname\0" >$t1
|
||||
|
||||
t2=`mktemp`
|
||||
t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
for dep in $deps; do printf "$dep\0" >> $t2; done
|
||||
|
||||
if test -n "$deps"; then
|
||||
|
|
|
@ -27,7 +27,7 @@ cmd='test_blockarg { true }'
|
|||
v=`echo "$cmd" | @builddir@/grub-shell`
|
||||
error_if_not "$v" '{ true }'
|
||||
|
||||
tmp=`mktemp`
|
||||
tmp=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
cmd='test_blockarg { test_blockarg { true } }'
|
||||
echo "$cmd" | @builddir@/grub-shell >$tmp
|
||||
error_if_not "`head -n1 $tmp|tail -n1`" '{ test_blockarg { true } }'
|
||||
|
|
|
@ -51,8 +51,8 @@ list_parts () {
|
|||
echo
|
||||
}
|
||||
|
||||
imgfile=`mktemp`
|
||||
outfile=`mktemp`
|
||||
imgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
outfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
|
||||
#
|
||||
# MSDOS partition types
|
||||
|
|
|
@ -83,17 +83,17 @@ for option in "$@"; do
|
|||
done
|
||||
|
||||
if [ "x${source}" = x ] ; then
|
||||
tmpfile=`mktemp`
|
||||
tmpfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
while read REPLY; do
|
||||
echo $REPLY >> ${tmpfile}
|
||||
done
|
||||
source=${tmpfile}
|
||||
fi
|
||||
|
||||
outfile1=`mktemp`
|
||||
outfile1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
@builddir@/grub-shell --qemu-opts="${qemuopts}" --modules=${modules} ${source} >${outfile1}
|
||||
|
||||
outfile2=`mktemp`
|
||||
outfile2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
bash ${source} >${outfile2}
|
||||
|
||||
if ! diff -q ${outfile1} ${outfile2} >/dev/null
|
||||
|
|
|
@ -107,14 +107,14 @@ for option in "$@"; do
|
|||
done
|
||||
|
||||
if [ "x${source}" = x ] ; then
|
||||
tmpfile=`mktemp`
|
||||
tmpfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
while read REPLY; do
|
||||
echo "$REPLY" >> ${tmpfile}
|
||||
done
|
||||
source=${tmpfile}
|
||||
fi
|
||||
|
||||
cfgfile=`mktemp`
|
||||
cfgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
cat <<EOF >${cfgfile}
|
||||
grubshell=yes
|
||||
insmod serial
|
||||
|
@ -123,7 +123,7 @@ terminal_input serial
|
|||
terminal_output serial
|
||||
EOF
|
||||
|
||||
rom_directory=`mktemp -d`
|
||||
rom_directory=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
|
||||
for mod in ${modules}
|
||||
do
|
||||
|
@ -135,7 +135,7 @@ source /boot/grub/testcase.cfg
|
|||
halt
|
||||
EOF
|
||||
|
||||
isofile=`mktemp`
|
||||
isofile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
if [ x$boot != xnet ]; then
|
||||
sh @builddir@/grub-mkrescue --grub-mkimage=${builddir}/grub-mkimage --output=${isofile} --override-directory=${builddir}/grub-core \
|
||||
--rom-directory="${rom_directory}" \
|
||||
|
@ -161,7 +161,7 @@ if [ x$boot = xqemu ]; then
|
|||
fi
|
||||
|
||||
if [ x$boot = xcoreboot ]; then
|
||||
imgfile=`mktemp`
|
||||
imgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
cp "${GRUB_COREBOOT_ROM}" "${imgfile}"
|
||||
"${GRUB_CBFSTOOL}" "${imgfile}" add-payload "${rom_directory}/coreboot.elf" fallback/payload
|
||||
bootdev="-bios ${imgfile}"
|
||||
|
@ -169,7 +169,7 @@ if [ x$boot = xcoreboot ]; then
|
|||
fi
|
||||
|
||||
if [ x$boot = xnet ]; then
|
||||
netdir=`mktemp -d`
|
||||
netdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
sh @builddir@/grub-mknetdir --grub-mkimage=${builddir}/grub-mkimage --override-directory=${builddir}/grub-core --net-directory=$netdir
|
||||
cp ${cfgfile} $netdir/boot/grub/grub.cfg
|
||||
cp ${source} $netdir/boot/grub/testcase.cfg
|
||||
|
|
|
@ -152,15 +152,7 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if test "x$TMP" != x; then
|
||||
MKTEMP_TEMPLATE="$TMP/grub-mkrescue.XXXXXXXXXX"
|
||||
elif test "x$TEMP" != x; then
|
||||
MKTEMP_TEMPLATE="$TEMP/grub-mkrescue.XXXXXXXXXX"
|
||||
else
|
||||
MKTEMP_TEMPLATE="/tmp/grub-mkrescue.XXXXXXXXXX"
|
||||
fi
|
||||
|
||||
iso9660_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
iso9660_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
mkdir -p ${iso9660_dir}/boot/grub
|
||||
|
||||
process_input_dir ()
|
||||
|
@ -197,8 +189,8 @@ make_image ()
|
|||
|
||||
echo "Enabling $2 support ..."
|
||||
|
||||
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
memdisk_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
memdisk_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
mkdir -p ${memdisk_dir}/boot/grub
|
||||
|
||||
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
|
||||
|
@ -263,12 +255,12 @@ grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${i
|
|||
# build BIOS core.img
|
||||
if test -e "${pc_dir}" ; then
|
||||
echo "Enabling BIOS support ..."
|
||||
core_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
core_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
$grub_mkimage -O i386-pc -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
|
||||
iso9660 biosdisk
|
||||
cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
|
||||
|
||||
embed_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||
embed_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
cat ${pc_dir}/boot.img ${core_img} > ${embed_img}
|
||||
|
||||
rm -f ${core_img}
|
||||
|
@ -287,7 +279,7 @@ fi
|
|||
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "ata at_keyboard"
|
||||
|
||||
if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
|
||||
efi_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||
efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
mkdir -p "${efi_dir}/efi/boot"
|
||||
|
||||
# build bootx64.efi
|
||||
|
|
|
@ -121,13 +121,13 @@ if [ "x${modules}" = "x" ] ; then
|
|||
modules=`cd ${input_dir}/ && ls *.mod`
|
||||
fi
|
||||
|
||||
map_file=`mktemp`
|
||||
map_file=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
cat >${map_file} <<EOF
|
||||
# EXTN XLate CREATOR TYPE Comment
|
||||
grub.img Raw 'UNIX' 'tbxi' "bootstrap"
|
||||
EOF
|
||||
|
||||
iso_dir=`mktemp -d`
|
||||
iso_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
boot_dir=${iso_dir}/boot/grub
|
||||
mkdir ${iso_dir}/boot
|
||||
mkdir ${boot_dir}
|
||||
|
|
Loading…
Reference in a new issue