* Portable mktemp invocation?
@ 2010-09-23 16:27 Grégoire Sutre
2010-09-25 11:10 ` Grégoire Sutre
2010-10-11 17:14 ` Grégoire Sutre
0 siblings, 2 replies; 5+ messages in thread
From: Grégoire Sutre @ 2010-09-23 16:27 UTC (permalink / raw)
To: The development of GRUB 2
Hi,
We use `mktemp' or `mktemp -d' (with no argument) in the shell scripts:
- grub-core/genmod.sh.in
- tests/util/grub-shell.in
- tests/util/grub-shell-tester.in
- tests/grub_script_blockarg.in
- tests/partmap_test.in
- util/powerpc/ieee1275/grub-mkrescue.in
But such invocations of mktemp fail on some systems (NetBSD, and,
according to their man pages, FreeBSD and MacOS X).
A simple solution would be to replace those invocations with:
mktemp [-d] ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX
What do you think? Is there a better alternative?
Grégoire
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Portable mktemp invocation?
2010-09-23 16:27 Portable mktemp invocation? Grégoire Sutre
@ 2010-09-25 11:10 ` Grégoire Sutre
2010-10-11 17:14 ` Grégoire Sutre
1 sibling, 0 replies; 5+ messages in thread
From: Grégoire Sutre @ 2010-09-25 11:10 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
On 09/23/2010 06:27 PM, Grégoire Sutre wrote:
> A simple solution would be to replace those invocations with:
>
> mktemp [-d] ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX
The attached patch implements this solution. Build tested on Debian
GNU/Linux and NetBSD.
Grégoire
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mktemp-fix.diff --]
[-- Type: text/x-patch; name="mktemp-fix.diff", Size: 10189 bytes --]
=== modified file 'ChangeLog'
--- ChangeLog 2010-09-25 05:18:48 +0000
+++ ChangeLog 2010-09-25 10:59:05 +0000
@@ -1,3 +1,16 @@
+2010-09-25 Grégoire Sutre <gregoire.sutre@gmail.com>
+
+ Make mktemp invocations portable.
+
+ * grub-core/genmod.sh.in: Use mktemp with an explicit template.
+ * 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 ';'.
+
2010-09-25 BVK Chaitanya <bvk.groups@gmail.com>
* grub-core/kern/emu/full.c (grub_emu_post_init): Fix typo.
=== modified file 'Makefile.am'
--- Makefile.am 2010-09-20 12:55:49 +0000
+++ Makefile.am 2010-09-25 10:45:56 +0000
@@ -189,31 +189,31 @@ kopenbsd.init.x86_64: $(srcdir)/grub-cor
$(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 $@
=== modified file 'grub-core/genmod.sh.in'
--- grub-core/genmod.sh.in 2010-09-19 13:59:36 +0000
+++ grub-core/genmod.sh.in 2010-09-25 09:51:57 +0000
@@ -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
=== modified file 'tests/grub_script_blockarg.in'
--- tests/grub_script_blockarg.in 2010-08-09 16:12:24 +0000
+++ tests/grub_script_blockarg.in 2010-09-25 09:09:19 +0000
@@ -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 } }'
=== modified file 'tests/partmap_test.in'
--- tests/partmap_test.in 2010-09-09 15:54:17 +0000
+++ tests/partmap_test.in 2010-09-25 09:10:03 +0000
@@ -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
=== modified file 'tests/util/grub-shell-tester.in'
--- tests/util/grub-shell-tester.in 2010-08-19 12:20:05 +0000
+++ tests/util/grub-shell-tester.in 2010-09-25 09:08:23 +0000
@@ -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
=== modified file 'tests/util/grub-shell.in'
--- tests/util/grub-shell.in 2010-09-13 12:03:05 +0000
+++ tests/util/grub-shell.in 2010-09-25 09:06:21 +0000
@@ -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
=== modified file 'util/powerpc/ieee1275/grub-mkrescue.in'
--- util/powerpc/ieee1275/grub-mkrescue.in 2010-06-29 15:20:49 +0000
+++ util/powerpc/ieee1275/grub-mkrescue.in 2010-09-25 09:14:44 +0000
@@ -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}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Portable mktemp invocation?
2010-09-23 16:27 Portable mktemp invocation? Grégoire Sutre
2010-09-25 11:10 ` Grégoire Sutre
@ 2010-10-11 17:14 ` Grégoire Sutre
2010-10-16 14:04 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 1 reply; 5+ messages in thread
From: Grégoire Sutre @ 2010-10-11 17:14 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
This is a new version of the patch. Changes with respect to the previous
version:
- use double quotes (i.e. "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")
- apply the same scheme to util/grub-mkrescue.in (intead of MKTEMP_TEMPLATE)
Grégoire
[-- Attachment #2: ChangeLog.mktemp --]
[-- Type: text/plain, Size: 575 bytes --]
2010-10-11 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.
[-- Attachment #3: mktemp-fix_v2.diff --]
[-- Type: text/plain, Size: 11532 bytes --]
=== modified file 'Makefile.am'
--- Makefile.am 2010-09-20 12:55:49 +0000
+++ Makefile.am 2010-10-11 15:16:54 +0000
@@ -189,31 +189,31 @@ kopenbsd.init.x86_64: $(srcdir)/grub-cor
$(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 $@
=== modified file 'grub-core/genmod.sh.in'
--- grub-core/genmod.sh.in 2010-09-19 13:59:36 +0000
+++ grub-core/genmod.sh.in 2010-10-11 15:34:47 +0000
@@ -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
=== modified file 'tests/grub_script_blockarg.in'
--- tests/grub_script_blockarg.in 2010-08-09 16:12:24 +0000
+++ tests/grub_script_blockarg.in 2010-10-11 15:34:24 +0000
@@ -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 } }'
=== modified file 'tests/partmap_test.in'
--- tests/partmap_test.in 2010-09-09 15:54:17 +0000
+++ tests/partmap_test.in 2010-10-11 15:34:19 +0000
@@ -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
=== modified file 'tests/util/grub-shell-tester.in'
--- tests/util/grub-shell-tester.in 2010-08-19 12:20:05 +0000
+++ tests/util/grub-shell-tester.in 2010-10-11 15:34:53 +0000
@@ -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
=== modified file 'tests/util/grub-shell.in'
--- tests/util/grub-shell.in 2010-09-13 12:03:05 +0000
+++ tests/util/grub-shell.in 2010-10-11 15:34:40 +0000
@@ -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
=== modified file 'util/grub-mkrescue.in'
--- util/grub-mkrescue.in 2010-09-20 12:14:44 +0000
+++ util/grub-mkrescue.in 2010-10-11 15:33:56 +0000
@@ -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_a
# 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
=== modified file 'util/powerpc/ieee1275/grub-mkrescue.in'
--- util/powerpc/ieee1275/grub-mkrescue.in 2010-06-29 15:20:49 +0000
+++ util/powerpc/ieee1275/grub-mkrescue.in 2010-10-11 15:34:02 +0000
@@ -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}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Portable mktemp invocation?
2010-10-11 17:14 ` Grégoire Sutre
@ 2010-10-16 14:04 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-10-18 21:11 ` Grégoire Sutre
0 siblings, 1 reply; 5+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-10-16 14:04 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
Go ahead for mainline
On 10/11/2010 07:14 PM, Grégoire Sutre wrote:
> This is a new version of the patch. Changes with respect to the previous
> version:
>
> - use double quotes (i.e. "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")
> - apply the same scheme to util/grub-mkrescue.in (intead of
> MKTEMP_TEMPLATE)
>
> Grégoire
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Portable mktemp invocation?
2010-10-16 14:04 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2010-10-18 21:11 ` Grégoire Sutre
0 siblings, 0 replies; 5+ messages in thread
From: Grégoire Sutre @ 2010-10-18 21:11 UTC (permalink / raw)
To: The development of GNU GRUB
On 10/16/2010 04:04 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Go ahead for mainline
Thanks, it's committed.
Grégoire
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-10-18 21:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-23 16:27 Portable mktemp invocation? Grégoire Sutre
2010-09-25 11:10 ` Grégoire Sutre
2010-10-11 17:14 ` Grégoire Sutre
2010-10-16 14:04 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-10-18 21:11 ` Grégoire Sutre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).