[Yum-devel] [PATCH 1/3] Use TMPDIR, if set, for save_ts. BZ 723280.

Ville Skyttä ville.skytta at iki.fi
Tue Jul 19 20:38:28 UTC 2011


On 07/19/2011 10:53 PM, James Antill wrote:
> ---
>  yum/__init__.py |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/yum/__init__.py b/yum/__init__.py
> index 12c2bdd..3f7f619 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -5242,7 +5242,8 @@ class YumBase(depsolve.Depsolve):
>          
>          if not filename:
>              prefix = 'yum_save_tx-%s' % time.strftime('%Y-%m-%d-%H-%M')
> -            fd,filename = tempfile.mkstemp(suffix='.yumtx', prefix=prefix)
> +            fd,filename = tempfile.mkstemp(suffix='.yumtx', prefix=prefix,
> +                                           dir=os.getenv('TMPDIR'))

I think mkstemp() takes TMPDIR into account automatically.

$ TMPDIR= python -c "import tempfile; print tempfile.mkstemp()"
(3, '/tmp/tmpGLrxRr')

$ TMPDIR=/var/tmp python -c "import tempfile; print tempfile.mkstemp()"
(3, '/var/tmp/tmpI5k6CO')


More information about the Yum-devel mailing list