[yum-commits] 3 commits - docs/package-cleanup.1 docs/yum-security.8 plugins/local yum-utils.spec

James Antill james at osuosl.org
Tue Nov 24 22:55:29 UTC 2009


 docs/package-cleanup.1   |    3 -
 docs/yum-security.8      |   24 ++++++---
 plugins/local/local.conf |   14 +++++
 plugins/local/local.py   |  124 +++++++++++++++++++++++++++++++++++++++++++++++
 yum-utils.spec           |   20 +++++++
 5 files changed, 176 insertions(+), 9 deletions(-)

New commits:
commit 3ca1d0df6f6e68f57fe221c7fbbd282e58b240d8
Author: James Antill <james at and.org>
Date:   Tue Nov 24 17:53:37 2009 -0500

    Add local plugin, so Fedora people can download/etc.

diff --git a/plugins/local/local.conf b/plugins/local/local.conf
new file mode 100644
index 0000000..ca23ac1
--- /dev/null
+++ b/plugins/local/local.conf
@@ -0,0 +1,14 @@
+[main]
+enabled=1
+
+# Createreop options. See man createrepo
+[createrepo]
+# If you want to speedup createrepo with the --cachedir option. Eg.
+# cachedir = /tmp/createrepo-local-plugin-cachedir
+# If you need to override the checksum with the --checksum option. Eg.
+# checksum = sha
+
+skip_stat = false
+unique_md_filenames = true
+update = true
+databases = true
diff --git a/plugins/local/local.py b/plugins/local/local.py
new file mode 100644
index 0000000..b750b28
--- /dev/null
+++ b/plugins/local/local.py
@@ -0,0 +1,124 @@
+#! /usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#
+# Copyright Red Hat Inc. 2009
+#
+# Author: James Antill <james.antill at redhat.com>
+#
+
+# FIXME: Doesn't copy updateinfo over
+# TODO: Add command to explicitly download pkgs and add them to the repo.
+# TODO: Some way to say "don't copy from these repos." or "only copy from these"
+#       so we can just get updates/rawhide and not fedora (which doesn't lose
+#       packages).
+
+import os
+import shutil
+import yum
+from yum.plugins import TYPE_CORE
+
+requires_api_version = '2.5'
+plugin_type = (TYPE_CORE,)
+
+def_local_repo_dir = '/var/lib/yum/plugins/local'
+
+def postdownload_hook(conduit):
+    if conduit.getErrors() or os.geteuid():
+        return
+
+    local_repo_dir  = conduit.confString('main', 'repodir',
+                                         default=def_local_repo_dir)
+
+    reg  = False
+    done = 0
+    for pkg in conduit.getDownloadPackages():
+        fname = pkg.localPkg()
+        if fname.startswith(local_repo_dir):
+            reg = True
+            continue
+
+        dest = local_repo_dir + '/' + os.path.basename(fname)
+        if os.path.exists(dest):
+            continue
+
+        if not done and not os.path.exists(local_repo_dir):
+            os.makedirs(local_repo_dir)
+        done += 1
+        shutil.copy2(fname, dest)
+
+    if reg:
+        if hasattr(conduit, 'registerPackageName'):
+            conduit.registerPackageName("yum-plugin-local")
+
+    if not done:
+        return
+
+    cache_dir = conduit.confString('createrepo', 'cachedir', default=None)
+    checksum  = conduit.confString('createrepo', 'checksum', default=None)
+
+    skip_stat = conduit.confBool('createrepo', 'skip_stat', default=False)
+    unique_md = conduit.confBool('createrepo', 'unique_md_filenames',
+                                 default=False)
+    update = conduit.confBool('createrepo', 'update', default=True)
+    databases = conduit.confBool('createrepo', 'databases', default=True)
+
+    args = ["createrepo"]
+    if databases:
+        args.append("--database")
+    if update:
+        args.append("--update")
+    if unique_md:
+        args.append("--unique-md-filenames")
+    if checksum is not None:
+        args.append("--checksum")
+        args.append(checksum)
+    if skip_stat:
+        args.append("--skip-stat")
+    if cache_dir is not None:
+        args.append("--cachedir")
+        args.append(cache_dir)
+    args.append(local_repo_dir)
+    conduit.info(2, "== Rebuilding _local repo. with %u new packages ==" % done)
+    os.spawnvp(os.P_WAIT, "createrepo", args)
+    conduit.info(2, "== Done rebuild of _local repo. ==")
+
+    lrepo = [repo for repo in conduit._base.repos.listEnabled()
+             if repo.id == "_local"]
+    if lrepo:
+        lrepo = lrepo[0]
+        os.unlink("%s/cachecookie" % lrepo.cachedir)
+        return
+
+    conf_fname = '/etc/yum.repos.d/_local.repo'
+    if os.path.exists(conf_fname):
+        return
+
+    open(conf_fname, "wb").write("""\
+[_local]
+name=Automatic local repo. (manged by the "local" yum plugin).
+baseurl=file:%s
+enabled=1
+gpgcheck=true
+#  Metadata expire could be set to "never" because the local plugin will
+# automatically cause a cache refresh when new packages are added. However
+# it's really cheap to check, and this way people can dump stuff in whenever
+# and it never gets out of sync. for long.
+metadata_expire=1h
+#  Make cost smaller, as we know it's "local". If you really want to be sure,
+# you can do this ... but the name will do pretty much the same thing, and that
+# way we can also see the other packages (with: --showduplicates list).
+# cost=500
+""" % local_repo_dir)
diff --git a/yum-utils.spec b/yum-utils.spec
index 9b6105f..7e62b05 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -340,6 +340,19 @@ Requires: yum >= 3.2.23
 Yum plugin which shows newly installed leaf packages
 and packages that became leaves after a transaction
 
+%package -n yum-plugin-local
+Summary: Yum plugin to automatically manage a local repo. of downloaded packages
+Group: System Environment/Base
+# Who the hell knows what version :)
+Requires: yum >= 3.2.22
+Requires: createrepo
+
+%description -n yum-plugin-local
+When this plugin is installed it will automatically copy all downloaded packages
+to a repository on the local filesystem, and (re)build that repository. This
+means that anything you've downloaded will always exist, even if the original
+repo. removes it (and can thus. be reinstalled/downgraded/etc.).
+
 %prep
 %setup -q
 
@@ -373,6 +386,7 @@ plugins="\
  rpm-warm-cache \
  auto-update-debuginfo \
  show-leaves \
+ local \
 "
 
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/yum/pluginconf.d/ $RPM_BUILD_ROOT/usr/lib/yum-plugins/
@@ -578,6 +592,12 @@ fi
 /usr/lib/yum-plugins/show-leaves.*
 %config(noreplace) %{_sysconfdir}/yum/pluginconf.d/show-leaves.conf
 
+%files -n yum-plugin-local
+%defattr(-, root, root)
+%ghost %{_sysconfdir}/yum.repos.d/_local.repo
+%config(noreplace) %{_sysconfdir}/yum/pluginconf.d/local.conf
+/usr/lib/yum-plugins/local.*
+
 
 %changelog
 * Sun Nov 8 2009 Tim Lauridsen <timlau at fedoraproject.org>
commit 674c79a41cf49cbc36cc3c7071bd989befd78546
Author: James Antill <james at and.org>
Date:   Tue Nov 24 16:48:19 2009 -0500

    Minor cleanup for new-packages explanation

diff --git a/docs/yum-security.8 b/docs/yum-security.8
index e901578..43cf572 100644
--- a/docs/yum-security.8
+++ b/docs/yum-security.8
@@ -39,23 +39,27 @@ Is used to display information about one or more advisories.
 .PP 
 .IP "\fBlist-updateinfo\fP" "\fBinfo-updateinfo\fP" "\fBsummary-updateinfo\fP"
 Is used to list all of the relevant errata notice information, from the
-updateinfo.xml data in yum. This includes bugzillas, CVEs and security updates.
-You can also list "new" packages, by passing new as the first argument.
+updateinfo.xml data in yum. This includes bugzillas, CVEs, security updates and
+new.
 .IP 
 .IP "\fBbugzillas / bzs\fP"
-Is the subset of the security information, pertaining to the bugzillas.
+Is the subset of the updateinfo information, pertaining to the bugzillas.
 .IP 
 .IP "\fBcves\fP"
-Is the subset of the security information, pertaining to the CVEs.
+Is the subset of the updateinfo information, pertaining to the CVEs.
 .IP 
 .IP "\fBsecurity / sec\fP"
-Is the subset of the security information, pertaining to security.
+Is the subset of the updateinfo information, pertaining to security.
 .IP "\fBbugfix\fP"
-Is the subset of the security information, pertaining to bugfixes.
+Is the subset of the updateinfo information, pertaining to bugfixes.
 .IP "\fBenhancement\fP"
-Is the subset of the security information, pertaining to enhancements.
+Is the subset of the updateinfo information, pertaining to enhancements.
 .IP "\fBrecommended\fP"
-Is the subset of the security information, pertaining to recommended updates.
+Is the subset of the updateinfo information, pertaining to recommended updates.
+.IP "\fBnew-packages\fP"
+Is the subset of the updateinfo information, pertaining to new packages. These
+are packages which weren't available at the initial release of your
+distribution.
 .IP
 .PP
 .SH "GENERAL OPTIONS"
@@ -109,6 +113,10 @@ yum --bz 123 --bz 456 --bz 789 --security update-minimal
 To get an info list of the latest packages which contain fixes for Bugzilla 123; CVEs CVE-2207-0123 and CVE-2207-3210; and Fedora advisories FEDORA-2707-4567 and FEDORA-2707-7654 use:
 .IP
 yum --bz 123 --cve CVE-2207-0123 --cve CVE-2207-3210 --advisory FEDORA-2707-4567 --advisory FEDORA-2707-7654 info updates
+.PP
+To get a list of packages which are "new".
+.IP
+yum list-updateinfo new
 
 
 .SH "SEE ALSO"
commit 228e9a1278e0ff57de6c1b26b46c2f7b1c9791cd
Author: James Antill <james at and.org>
Date:   Tue Nov 24 16:41:45 2009 -0500

    Add docs. explaining that orphans == extras

diff --git a/docs/package-cleanup.1 b/docs/package-cleanup.1
index a29c46f..0b5c8a6 100644
--- a/docs/package-cleanup.1
+++ b/docs/package-cleanup.1
@@ -24,7 +24,8 @@ List leaf nodes in the local RPM database.  Leaf nodes are RPMs that
 are not relied upon by any other RPM.
 .IP "\fB\-\-orphans\fP"
 List installed packages which are not available from currenly configured
-repositories.
+repositories. This is identical to "yum list extras", which may provide better
+output.
 .IP "\fB\-\-oldkernels\fP"
 Remove old kernel and kernel-devel packages.
 .IP "\fB\-\-problems\fP"


More information about the Yum-commits mailing list