scripts: use mktemp instead of relying on TMPDIR beeing in env
PATCH 1/1 scripts: use mktemp instead of relying on TMPDIR beeing in env
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to /tmp/ or just use the tool mktemp.
--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/prepare-kernel.sh +3 -3
@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=$( mktemp -d prepare-kernel-XXX ) + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
Signature · 1 line
2.4.10
PATCH v2 1/1 scripts: use mktemp instead of relying on TMPDIR beeing in env
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to /tmp/ or just use the tool mktemp.
--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/prepare-kernel.sh +3 -3
@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=$( mktemp -d prepare-kernel-XXX ) + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
Signature · 1 line
2.4.10
PATCH v3 1/1 scripts: use mktemp instead of relying on TMPDIR beeing in env
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to /tmp/ or just use the tool mktemp.
--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/prepare-kernel.sh +3 -3
@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=$( mktemp -d prepare-kernel-XXX --tmpdir ) + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
Signature · 1 line
2.4.10
Sorry for the mess. The 3rd adds the --tmpdir switch, that is the diff to the first two. The v2 is not different from v1 because i did not ammend before sending the mail.
Henning
Quoted 25 lines · On Tue, 27 Oct 2015 13:30:50 +0100 Henning Schild <[email protected]>…
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.Signed-off-by Henning Schild <[email protected]>--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/prepare-kernel.sh +0
-0@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporarytree. if test "x$output_patch" != "x"; then
scripts/prepare-kernel.sh +3
-3- temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=$( mktemp -d prepare-kernel-XXX --tmpdir ) + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
Quoted 2 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.
I am not sure mktemp is available everywhere. What about setting TMPDIR to /tmp if not set ?
Signature · 2 lines
Gilles. https://click-hack.org
Quoted 7 lines · On Tue, 27 Oct 2015 13:30:04 +0100 Gilles Chanteperdrix…
Quoted 3 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.I am not sure mktemp is available everywhere. What about setting TMPDIR to /tmp if not set ?
From what i can tell mktemp is more widely available than TMPDIR. My gentoo boxes do not have TMPDIR set and i have used a ubuntu system where it was not set either. mktemp is part of coreutils and even busybox has one.
I did not feel too good reimplementing whatever else mktemp does, why reinvent the wheel?
Henning
Quoted 11 lines · On Tue, 27 Oct 2015 13:35:40 +0100 Henning Schild <[email protected]>…
Quoted 7 lines · On Tue, 27 Oct 2015 13:30:04 +0100 Gilles Chanteperdrix…
Quoted 3 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.I am not sure mktemp is available everywhere. What about setting TMPDIR to /tmp if not set ?
Quoted 6 lines
From what i can tell mktemp is more widely available than TMPDIR. My gentoo boxes do not have TMPDIR set and i have used a ubuntu system where it was not set either. mktemp is part of coreutils and even busybox has one.
I did not feel too good reimplementing whatever else mktemp does, why reinvent the wheel?
Please let me know whether i was convincing and the current patch version will be merged.
Henning
Quoted 4 lines
_______________________________________________
Xenomai mailing list
[email protected]
http://xenomai.org/mailman/listinfo/xenomai
Quoted 21 lines · Henning Schild
Quoted 11 lines · On Tue, 27 Oct 2015 13:35:40 +0100 Henning Schild <[email protected]>…
Quoted 7 lines · On Tue, 27 Oct 2015 13:30:04 +0100 Gilles Chanteperdrix…
Quoted 3 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.I am not sure mktemp is available everywhere. What about setting TMPDIR to /tmp if not set ?
Quoted 6 lines
From what i can tell mktemp is more widely available than TMPDIR. My gentoo boxes do not have TMPDIR set and i have used a ubuntu system where it was not set either. mktemp is part of coreutils and even busybox has one.
I did not feel too good reimplementing whatever else mktemp does, why reinvent the wheel?
Quoted 2 lines
Please let me know whether i was convincing and the current patch version will be merged.
The patch is ok for me minus the use of $() which is used nowhere else in the script and not strictly necessary (no nesting needed).
Signature · 2 lines
Gilles. https://click-hack.org
PATCH v4 1/1 scripts: use mktemp instead of relying on TMPDIR beeing in env
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to /tmp/ or just use the tool mktemp.
--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/prepare-kernel.sh +3 -3
@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
Signature · 1 line
2.4.10
Philippe Gerum
AppliedQuoted 16 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.Signed-off-by Henning Schild <[email protected]>--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/prepare-kernel.sh +0
-0@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then
scripts/prepare-kernel.sh fi · line 246
Quoted 10 lines
scripts/prepare-kernel.sh +3
-3- temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
merged, thanks.
Signature · 1 line
Philippe.
Quoted 14 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.Signed-off-by Henning Schild <[email protected]>--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/prepare-kernel.sh +0
-0@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporary tree.
scripts/prepare-kernel.sh fi · line 245
Quoted 10 lines
scripts/prepare-kernel.sh +3
-3if test "x$output_patch" != "x"; then - temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists, aborting. + temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fi
The version of mktemp installed on my machine requires 6 X in the template.
Signature · 2 lines
Gilles. https://click-hack.org
Quoted 18 lines · On Wed, 4 Nov 2015 08:53:11 +0100 Gilles Chanteperdrix…
Quoted 17 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.Signed-off-by Henning Schild <[email protected]>--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/prepare-kernel.sh +0
-0@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporarytree. if test "x$output_patch" != "x"; then
Quoted 12 lines
scripts/prepare-kernel.sh fi · line 245
Quoted 9 lines
scripts/prepare-kernel.sh +0
-3- temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists,aborting.
scripts/prepare-kernel.sh +3
-0+ temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fiThe version of mktemp installed on my machine requires 6 X in the template.
That is unfortunate but easy enough to fix. The patch has already been applied, so we will need another one on top. I suggest you go ahead and expand the template since you found the problem.
The man-pages on my boxes all say "at least 3".
Henning
Quoted 34 lines · Henning Schild
Quoted 18 lines · On Wed, 4 Nov 2015 08:53:11 +0100 Gilles Chanteperdrix…
Quoted 17 lines · Henning Schild
The environment variable TMPDIR is optional and not always set. We could test for it and fall back to
/tmp/or just use the tool mktemp.Signed-off-by Henning Schild <[email protected]>--- scripts/prepare-kernel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)scripts/prepare-kernel.sh +0
-0@@ -238,9 +238,9 @@ fi # Create an empty output patch file, and initialize the temporarytree. if test "x$output_patch" != "x"; then
Quoted 12 lines
scripts/prepare-kernel.sh fi · line 245
Quoted 9 lines
scripts/prepare-kernel.sh +0
-3- temp_tree=$TMPDIR/prepare-kernel-$$ - if ! mkdir $temp_tree; then - echo Temporary directory $temp_tree already exists,aborting.
scripts/prepare-kernel.sh +3
-0+ temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + if [ $? -ne 0 ]; then + echo Temporary directory could not be created. exit 1 fiThe version of mktemp installed on my machine requires 6 X in the template.
Quoted 4 lines
That is unfortunate but easy enough to fix. The patch has already been applied, so we will need another one on top. I suggest you go ahead and expand the template since you found the problem.
The man-pages on my boxes all say "at least 3".
I suggest your fix it.
Signature · 2 lines
Gilles. https://click-hack.org
PATCH 1/1 scripts: increase number of Xs in mktemp template
In a5cfe9c9a8dbcc094b0c5043b21fa6cde7fc42e5 the use of mktemp was introduces. Some versions of mktemp seem to require a template of at least 6 Xs.
--- scripts/prepare-kernel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/prepare-kernel.sh +1 -1
@@ -238,7 +238,7 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + temp_tree=`mktemp -d prepare-kernel-XXXXXX --tmpdir` if [ $? -ne 0 ]; then echo Temporary directory could not be created. exit 1
Signature · 1 line
2.4.10
Re: [Xenomai] [PATCH] scripts: increase number of Xs in mktemp template
Quoted 3 lines · Henning Schild
In
a5cfe9c9a8dbcc094b0c5043b21fa6cde7fc42e5the use of mktemp was introduces. Some versions of mktemp seem to require a template of at least 6 Xs.
not at least. Exactly 6 Xs. And this requirement is actually part of the POSIX standard:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkstemp.html
Signature · 2 lines
Gilles. https://click-hack.org
PATCH v2 1/1 scripts: increase number of Xs in mktemp template
In a5cfe9c9a8dbcc094b0c5043b21fa6cde7fc42e5 the use of mktemp was introduces. There are version of mktemp that are ok with less than six Xs, but POSIX requires exactly six.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/mkstemp.html
--- scripts/prepare-kernel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/prepare-kernel.sh +1 -1
@@ -238,7 +238,7 @@ fi # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then - temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` + temp_tree=`mktemp -d prepare-kernel-XXXXXX --tmpdir` if [ $? -ne 0 ]; then echo Temporary directory could not be created. exit 1
Signature · 1 line
2.4.10