Commit f101b03b authored by Jérome Perrin's avatar Jérome Perrin

Don't set TMP environment variable

It was inconsistent to only set TMP and not TEMP / TEMPDIR. In the case
of slapos, it should be set by slapos node software

Most installation seem to cleanup tmp properly, so the use case cleaning
up seem not critical.

This TMP was also used to know what new files have been created, by
considering files newer that the creation date of this directory.
Compare the file dates with the creation of the source directory instead
( xxx__compile__ )
parent 17ec5a57
...@@ -269,10 +269,6 @@ will add it to environmet variables as the following: ...@@ -269,10 +269,6 @@ will add it to environmet variables as the following:
CXXFLAGS=-I${buildout:prefix} $CXXFLAGS CXXFLAGS=-I${buildout:prefix} $CXXFLAGS
LDFLAGS=-L${buildout:prefix}/lib LDFLAGS=-L${buildout:prefix}/lib
Besides, the recipe changes environment variable ``TMP`` when building
and installing, and make a corresponding directory 'tmp' in the
``location``. This temporary directory will be removed after
installing finished.
Example usage Example usage
============= =============
...@@ -308,7 +304,6 @@ default build options. ...@@ -308,7 +304,6 @@ default build options.
>>> print(system(buildout)) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE >>> print(system(buildout)) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
installing package installing package
...@@ -334,7 +329,6 @@ default build options. ...@@ -334,7 +329,6 @@ default build options.
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing packagex. Installing packagex.
packagex: [ENV] TMP = /sample_buildout/parts/packagex/tmp
configure --prefix=/sample_buildout/parts/packagex configure --prefix=/sample_buildout/parts/packagex
building package building package
installing package installing package
...@@ -371,7 +365,6 @@ a custom location within the buildout:: ...@@ -371,7 +365,6 @@ a custom location within the buildout::
>>> print(system(buildout)) >>> print(system(buildout))
Uninstalling packagex. Uninstalling packagex.
Installing foobar. Installing foobar.
foobar: [ENV] TMP = /sample_buildout/parts/foobar/tmp
building package building package
installing package installing package
...@@ -410,7 +403,6 @@ Makefile and using explicit ``make`` options to control the build process. ...@@ -410,7 +403,6 @@ Makefile and using explicit ``make`` options to control the build process.
>>> print(system(buildout)) >>> print(system(buildout))
Uninstalling foobar. Uninstalling foobar.
Installing haproxy. Installing haproxy.
haproxy: [ENV] TMP = /sample_buildout/parts/haproxy/tmp
Building HAProxy 1.4.8 (dummy package) Building HAProxy 1.4.8 (dummy package)
TARGET: linux26 TARGET: linux26
CPU: i686 CPU: i686
...@@ -451,7 +443,6 @@ and building that. ...@@ -451,7 +443,6 @@ and building that.
>>> print(system(buildout)) >>> print(system(buildout))
Uninstalling haproxy. Uninstalling haproxy.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Using local source directory: /checkout/package-0.0.0 package: Using local source directory: /checkout/package-0.0.0
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
...@@ -511,7 +502,6 @@ targets and also patches the source code before the scripts are run. ...@@ -511,7 +502,6 @@ targets and also patches the source code before the scripts are run.
Installing package. Installing package.
package: [ENV] CFLAGS = -I/sw/include package: [ENV] CFLAGS = -I/sw/include
package: [ENV] LDFLAGS = -L/sw/lib -L/some/extra/lib package: [ENV] LDFLAGS = -L/sw/lib -L/some/extra/lib
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Applying patches package: Applying patches
patching file configure patching file configure
patching file Makefile.dist patching file Makefile.dist
...@@ -594,7 +584,6 @@ and a new buildout to try it out ...@@ -594,7 +584,6 @@ and a new buildout to try it out
>>> print(system(buildout)) >>> print(system(buildout))
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Executing pre-configure-hook package: Executing pre-configure-hook
hook: This is pre-configure-hook! hook: This is pre-configure-hook!
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
...@@ -634,7 +623,6 @@ shell command in the corresponding stage. ...@@ -634,7 +623,6 @@ shell command in the corresponding stage.
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Executing pre-configure package: Executing pre-configure
Configure part: package Configure part: package
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
...@@ -675,7 +663,6 @@ are only ``pre-configure`` and ``post-install``. the output will be ...@@ -675,7 +663,6 @@ are only ``pre-configure`` and ``post-install``. the output will be
#>>> print system(buildout) #>>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Executing pre-configure package: Executing pre-configure
Configure part: Configure in common platform Configure part: Configure in common platform
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
...@@ -719,7 +706,6 @@ Let's see what happens when set prefix in the buildout section: ...@@ -719,7 +706,6 @@ Let's see what happens when set prefix in the buildout section:
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Executing pre-configure package: Executing pre-configure
configure --prefix=/sample_buildout/mylocal configure --prefix=/sample_buildout/mylocal
building package building package
...@@ -750,7 +736,6 @@ example, ...@@ -750,7 +736,6 @@ example,
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
package: Executing pre-configure package: Executing pre-configure
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
...@@ -784,13 +769,11 @@ prefix: ...@@ -784,13 +769,11 @@ prefix:
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure --prefix=/sample_buildout/mylocal configure --prefix=/sample_buildout/mylocal
building package building package
package: Executing pre-install package: Executing pre-install
installing package installing package
Installing package-2. Installing package-2.
package-2: [ENV] TMP = /sample_buildout/parts/package-2/tmp
configure --prefix=/sample_buildout/mylocal configure --prefix=/sample_buildout/mylocal
building package building package
package-2: Executing pre-install package-2: Executing pre-install
...@@ -874,9 +857,7 @@ value in the part section. For example, ...@@ -874,9 +857,7 @@ value in the part section. For example,
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
Installing package-2. Installing package-2.
package-2: [ENV] TMP = /sample_buildout/parts/package-2/tmp
package-2: Executing post-install package-2: Executing post-install
package magic prefix is /mytemp package magic prefix is /mytemp
<BLANKLINE> <BLANKLINE>
...@@ -901,7 +882,6 @@ can display "prefix" value in the stdout. ...@@ -901,7 +882,6 @@ can display "prefix" value in the stdout.
Uninstalling package-2. Uninstalling package-2.
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure configure
building package building package
package: Executing pre-install package: Executing pre-install
...@@ -927,7 +907,6 @@ replaced with the recipe final prefix. ...@@ -927,7 +907,6 @@ replaced with the recipe final prefix.
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure configure
building package building package
package: Executing pre-install package: Executing pre-install
...@@ -962,12 +941,10 @@ of "package": ...@@ -962,12 +941,10 @@ of "package":
>>> print system(buildout) >>> print system(buildout)
Uninstalling package. Uninstalling package.
Installing package-2. Installing package-2.
package-2: [ENV] TMP = /sample_buildout/parts/package-2/tmp
configure --prefix=/sample_buildout/parts/package-2 configure --prefix=/sample_buildout/parts/package-2
building package building package
installing package installing package
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
installing package installing package
...@@ -997,12 +974,10 @@ Look, "package" is reinstalled either: ...@@ -997,12 +974,10 @@ Look, "package" is reinstalled either:
Uninstalling package. Uninstalling package.
Uninstalling package-2. Uninstalling package-2.
Installing package-2. Installing package-2.
package-2: [ENV] TMP = /sample_buildout/parts/package-2/tmp
configure configure
building package building package
installing package installing package
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
installing package installing package
...@@ -1034,7 +1009,6 @@ If no shared-parts is set, and shared is True, shared feature is not used: ...@@ -1034,7 +1009,6 @@ If no shared-parts is set, and shared is True, shared feature is not used:
Uninstalling package. Uninstalling package.
Uninstalling package-2. Uninstalling package-2.
Installing package. Installing package.
package: [ENV] TMP = /sample_buildout/parts/package/tmp
configure --prefix=/sample_buildout/parts/package configure --prefix=/sample_buildout/parts/package
building package building package
installing package installing package
...@@ -1074,7 +1048,6 @@ process as the recipe tried. ...@@ -1074,7 +1048,6 @@ process as the recipe tried.
Installing package. Installing package.
package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
package: [ENV] FOO = bar package: [ENV] FOO = bar
package: [ENV] TMP = .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/.../tmp
package: Command failed with exit code 127: ./configure --prefix=".../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/..." package: Command failed with exit code 127: ./configure --prefix=".../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/..."
package: Compilation error. The package is left as is at .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...__compile__ where you can inspect what went wrong. package: Compilation error. The package is left as is at .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...__compile__ where you can inspect what went wrong.
A shell script slapos.recipe.build.env.sh has been generated. You can source it in your shell to reproduce build environment. A shell script slapos.recipe.build.env.sh has been generated. You can source it in your shell to reproduce build environment.
...@@ -1093,7 +1066,6 @@ If shared-parts is set and shared is True, package will be installed in shared_p ...@@ -1093,7 +1066,6 @@ If shared-parts is set and shared is True, package will be installed in shared_p
package: shared directory .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... set for package package: shared directory .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... set for package
Installing package. Installing package.
package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
package: [ENV] TMP = .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/.../tmp
package: Removing already existing directory .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...__compile__ package: Removing already existing directory .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...__compile__
configure --prefix=.../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... configure --prefix=.../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
building package building package
...@@ -1141,7 +1113,6 @@ If options change, reinstall in different location: ...@@ -1141,7 +1113,6 @@ If options change, reinstall in different location:
Uninstalling package. Uninstalling package.
Installing package. Installing package.
package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... package: Checking whether package is installed at shared path: .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
package: [ENV] TMP = .../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/.../tmp
configure --prefix=.../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/... configure --prefix=.../slapos.recipe.cmmi/slapos/recipe/cmmi/shared/package/...
building package building package
installing package installing package
......
...@@ -143,7 +143,6 @@ class Recipe(object): ...@@ -143,7 +143,6 @@ class Recipe(object):
# environment. # environment.
for key in self.environ: for key in self.environ:
self.environ[key] = self.environ[key] % os.environ self.environ[key] = self.environ[key] % os.environ
self.environ['TMP'] = os.path.join(options['default-location'], 'tmp')
def augmented_environment(self): def augmented_environment(self):
"""Returns a dictionary containing the current environment variables """Returns a dictionary containing the current environment variables
...@@ -152,6 +151,10 @@ class Recipe(object): ...@@ -152,6 +151,10 @@ class Recipe(object):
The dictionary is an independent copy of ``os.environ`` and The dictionary is an independent copy of ``os.environ`` and
modifications will not be reflected in back in ``os.environ``. modifications will not be reflected in back in ``os.environ``.
""" """
# Note that we don't set TMPDIR or TMP here as we use to do, because
# this path might be too deep and this will cause problem with some
# software (for example golang) who runs a test suite after build and
# use this TMPDIR to create unix sockets.
env = os.environ.copy() env = os.environ.copy()
env.update(self.environ) env.update(self.environ)
return env return env
...@@ -338,9 +341,6 @@ class Recipe(object): ...@@ -338,9 +341,6 @@ class Recipe(object):
if e.errno == errno.EEXIST: if e.errno == errno.EEXIST:
pass pass
os.chdir(compile_dir) os.chdir(compile_dir)
tmp_path = self.environ['TMP']
shutil.rmtree(tmp_path, True)
os.mkdir(tmp_path)
if self.options['shared']: if self.options['shared']:
self._signature.save(self.options["shared"]) self._signature.save(self.options["shared"])
...@@ -403,7 +403,7 @@ class Recipe(object): ...@@ -403,7 +403,7 @@ class Recipe(object):
and self.options['shared'] == '' and self.options['shared'] == ''
and os.path.exists(self.buildout_prefix)): and os.path.exists(self.buildout_prefix)):
log.info('Getting installed file lists') log.info('Getting installed file lists')
parts.extend(self.get_installed_files(tmp_path)) parts.extend(self.get_installed_files(compile_dir))
except: except:
with open('slapos.recipe.build.env.sh', 'w') as env_script: with open('slapos.recipe.build.env.sh', 'w') as env_script:
...@@ -429,9 +429,6 @@ class Recipe(object): ...@@ -429,9 +429,6 @@ class Recipe(object):
raise raise
finally: finally:
os.chdir(current_dir) os.chdir(current_dir)
# If in shared mode and have error during installed, tmp_path was already deleted
if os.path.isdir(tmp_path):
shutil.rmtree(tmp_path)
# Check promises # Check promises
self.check_promises(log) self.check_promises(log)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment