Skip to contentSkip to conversation

Fix TMPDIR usage in scripts

PATCH In review Paul Eggleton 2 participants 6 messages Sep 28, 2011

lore
Share & tools
lore
#0 lore raw

cover Fix TMPDIR usage in scripts

Fix TMPDIR external environment variable usage within our scripts which is a problem on OpenSUSE within an X session (see Yocto bug #1530) by using OE_TMPDIR from the external environment instead.

Note that this will require changes to autobuilder scripts that use a TMPDIR environment variable when calling these scripts - they should now set OE_TMPDIR instead (if versions with and without this change need to be run on the same system, then setting both variables will cause no harm).

The following changes since commit 684a4b517d13884c315688967fadd5e6a4845b71:

libffi: really populate -dev package (2011-09-26 20:50:27 +0100)

are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib paule/scripts-tmpdir
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/scripts-tmpdir

Paul Eggleton (2):
scripts: use OE_TMPDIR instead of TMPDIR external variable scripts/oe-setup-rpmrepo: use setup_tmpdir from runqemu

 scripts/oe-setup-rpmrepo |   35 +++++++++++++++++++++--------------
 scripts/runqemu          |    7 ++++++-
 2 files changed, 27 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/2 scripts: use OE_TMPDIR instead of TMPDIR external variable

On OpenSUSE within an X session, TMPDIR is set to the system temporary directory (/tmp) which is incorrect for these scripts. Thus, change runqemu and oe-setup-rpmrepo to use OE_TMPDIR from the external environment rather than TMPDIR.

Fixes [YOCTO #1530]

---
 scripts/oe-setup-rpmrepo |    8 +++++++-
 scripts/runqemu          |    7 ++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
scripts/oe-setup-rpmrepo +7 -1
index 03372b6..fc2f7a8 100755
@@ -17,9 +17,15 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
+
+# Don't use TMPDIR from the external environment, it may be a distro
+# variable pointing to /tmp (e.g. within X on OpenSUSE)
+# Instead, use OE_TMPDIR for passing this in externally.
+TMPDIR="$OE_TMPDIR"
+
 function usage() {
 	echo "Usage: $0 <rpm-dir>"
-	echo "  <rpm-dir>: default is $TPMDIR/deploy/rpm"
+	echo "  <rpm-dir>: default is $TMPDIR/deploy/rpm"
 }
 
 if [ $# -gt 1 ]; then
scripts/runqemu +6 -1
index 0f943b5..31e9822 100755
@@ -55,6 +55,11 @@ SCRIPT_QEMU_OPT=""
 SCRIPT_QEMU_EXTRA_OPT=""
 SCRIPT_KERNEL_OPT=""
 
+# Don't use TMPDIR from the external environment, it may be a distro
+# variable pointing to /tmp (e.g. within X on OpenSUSE)
+# Instead, use OE_TMPDIR for passing this in externally.
+TMPDIR="$OE_TMPDIR"
+
 # Determine whether the file is a kernel or QEMU image, and set the
 # appropriate variables
 process_filename() {
@@ -260,7 +265,7 @@ SPITZ_DEFAULT_FSTYPE=ext3
 
 setup_tmpdir() {
     if [ -z "$TMPDIR" ]; then
-        # BUILDDIR unset, try and get TMPDIR from bitbake
+        # Try to get TMPDIR from bitbake
         type -P bitbake &>/dev/null || {
             echo "In order for this script to dynamically infer paths";
             echo "to kernels or filesystem images, you either need";
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/2 scripts/oe-setup-rpmrepo: use setup_tmpdir from runqemu

In reply to Paul Eggleton

Update the internal copy of setup_tmpdir in the oe-setup-rpmrepo script to be the same as the one in the runqemu script.

---
 scripts/oe-setup-rpmrepo |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
scripts/oe-setup-rpmrepo +14 -13
index fc2f7a8..ea885f6 100755
@@ -35,19 +35,20 @@ fi
 
 setup_tmpdir() {
     if [ -z "$TMPDIR" ]; then
-        if [ "x$BUILDDIR" = "x" -o ! -d "$BUILDDIR/tmp" ]; then
-            # BUILDDIR unset, try and get TMPDIR from bitbake
-            type -P bitbake &>/dev/null || {
-                echo "In order for this script to dynamically infer paths";
-                echo "to kernels or filesystem images, you either need";
-                echo "bitbake in your PATH or to source oe-init-build-env";
-                echo "before running this script" >&2;
-                exit 1; }
-
-            # We have bitbake in PATH, get TMPDIR from bitbake
-            TMPDIR=`bitbake -e | grep TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
-        else
-            TMPDIR=$BUILDDIR/tmp
+        # Try to get TMPDIR from bitbake
+        type -P bitbake &>/dev/null || {
+            echo "In order for this script to dynamically infer paths";
+            echo "to kernels or filesystem images, you either need";
+            echo "bitbake in your PATH or to source oe-init-build-env";
+            echo "before running this script" >&2;
+            exit 1; }
+
+        # We have bitbake in PATH, get TMPDIR from bitbake
+        TMPDIR=`bitbake -e | grep ^TMPDIR=\" | cut -d '=' -f2 | cut -d '"' -f2`
+        if [ -z "$TMPDIR" ]; then
+            echo "Error: this script needs to be run from your build directory,"
+            echo "or you need to explicitly set TMPDIR in your environment"
+            exit 1
         fi
     fi
 }
Signature · 1 line
1.7.4.1
#3 lore raw
In reply to Paul Eggleton
Quoted 9 lines · Paul Eggleton

Fix TMPDIR external environment variable usage within our scripts which is a problem on OpenSUSE within an X session (see Yocto bug #1530) by using OE_TMPDIR from the external environment instead.

Note that this will require changes to autobuilder scripts that use a TMPDIR environment variable when calling these scripts - they should now set OE_TMPDIR instead (if versions with and without this change need to be run on the same system, then setting both variables will cause no harm).

At the very least we need to fix the references in scripts/qemuimage-testlib so the automated image testing doesn't break.

Cheers,

Richard

#4 lore raw
Quoted 2 lines · On Wednesday 28 September 2011 12:09:57 Richard Purdie wrote:

At the very least we need to fix the references in scripts/qemuimage-testlib so the automated image testing doesn't break.

OK, v2 on its way. The scripts that call qemuimage-testlib will still need to be updated to set OE_TMPDIR though.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#5 lore raw
Quoted 6 lines · Paul Eggleton
Quoted 2 lines · On Wednesday 28 September 2011 12:09:57 Richard Purdie wrote:

At the very least we need to fix the references in scripts/qemuimage-testlib so the automated image testing doesn't break.

OK, v2 on its way. The scripts that call qemuimage-testlib will still need to be updated to set OE_TMPDIR though.

The "script" is "meta/classes/imagetest-qemu.bbclass" and you could even test this by setting IMAGETEST = "qemu" in local.conf and then "bitbake core-image-minimal" ;-).

Also, why can't scripts/qemuimage-testlib just do OE_TMPDIR=${TMPDIR} ?

Cheers,

Richard