[Yum-devel] [PATCH] Add a user_cachedir config. for people who don't want to use /var/tmp, yum#337

Seth Vidal skvidal at fedoraproject.org
Thu Apr 1 20:27:24 UTC 2010



On Thu, 1 Apr 2010, James Antill wrote:

> ---
> docs/yum.conf.5 |    6 ++++++
> yum/__init__.py |    5 ++++-
> yum/config.py   |    3 ++-
> 3 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
> index fe195af..241cf70 100644
> --- a/docs/yum.conf.5
> +++ b/docs/yum.conf.5
> @@ -28,6 +28,12 @@ Directory where yum should store its cache and db files. The default is
> `/var/cache/yum'.
>
> .IP
> +\fBuser_cachedir\fR
> +Directory prefix where yum should store its cache and db files, if called as a
> +non-root user. Note that <userid>-<rand>/$basearch/$releasever is added to this
> +prefix, by the yum cli. The default is `/var/tmp'.
> +
> +.IP
> \fBpersistdir\fR
> Directory where yum should store information that should persist over multiple
> runs. The default is `/var/lib/yum'.
> diff --git a/yum/__init__.py b/yum/__init__.py
> index f7dd8f2..50eac02 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -4358,13 +4358,16 @@ class YumBase(depsolve.Depsolve):
>         self.repos.enableRepo(newrepo.id)
>         return newrepo
>
> -    def setCacheDir(self, force=False, tmpdir='/var/tmp', reuse=True,
> +    def setCacheDir(self, force=False, tmpdir=None, reuse=True,
>                     suffix='/$basearch/$releasever'):
>         ''' Set a new cache dir, using misc.getCacheDir() and var. replace
>             on suffix. '''
>
>         if not force and os.geteuid() == 0:
>             return True # We are root, not forced, so happy with the global dir.
> +
> +        if tmpdir is None:
> +            tmpdir = self.conf.user_cachedir
>         try:
>             cachedir = misc.getCacheDir(tmpdir, reuse)
>         except (IOError, OSError), e:
> diff --git a/yum/config.py b/yum/config.py
> index e51e46f..8d026f6 100644
> --- a/yum/config.py
> +++ b/yum/config.py
> @@ -615,6 +615,7 @@ class YumConf(StartupConf):
>     recent = IntOption(7, range_min=0)
>
>     cachedir = Option('/var/cache/yum')
> +    user_cachedir = Option('/var/tmp')
>
>     keepcache = BoolOption(True)
>     logfile = Option('/var/log/yum.log')
> @@ -863,7 +864,7 @@ def readMainConfig(startupconf):
>     yumconf.populate(startupconf._parser, 'main')
>
>     # Apply the installroot to directory options
> -    for option in ('cachedir', 'logfile', 'persistdir'):
> +    for option in ('cachedir', 'logfile', 'persistdir', 'user_cachedir'):
>         path = getattr(yumconf, option)
>         ir_path = yumconf.installroot + path
>         ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
> -- 
> 1.6.6.1
>

No problem with the patch - but would be better off just making yum follow 
$TMPDIR in the env?

Then it's a one line patch and no new options.

-sv



More information about the Yum-devel mailing list