[node-patches] Change in ovirt-node[master]: Get edit-node to resolve dependencies from repositories on t...

rbarry at redhat.com rbarry at redhat.com
Fri Jul 5 20:34:27 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Get edit-node to resolve dependencies from repositories on the image
......................................................................

Get edit-node to resolve dependencies from repositories on the image

If an RPM or package is specified, edit-node should pull packages
from repositories present on the image in order to satisfy, so
end-users don't need to assemble it with yumdownloader

Change-Id: Ia16ef06ac763b4cddc8b45dc7b36892147882a6e
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M tools/edit-node
M tools/edit-node.8
2 files changed, 43 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/22/16522/1

diff --git a/tools/edit-node b/tools/edit-node
index 9a0409b..429cf76 100755
--- a/tools/edit-node
+++ b/tools/edit-node
@@ -31,6 +31,7 @@
 import glob
 import re
 import selinux
+from yum import YumBase
 from time import strftime as date
 from subprocess import PIPE, STDOUT
 from imgcreate.debug import *
@@ -74,6 +75,9 @@
         self.tmpdir = "/var/tmp"
         self.dd_dir = None
         """The directory in which all temporary files will be created."""
+
+        self.DEVELOPMENT_VERSION = 20
+        self.repo_pattern = ""
 
         self.compress_type = None
         """mksquashfs compressor to use. Use 'None' to force reading of the
@@ -1097,6 +1101,14 @@
         print "Configuring Yum Repo"
         self.dd_dir = tempfile.mkdtemp(dir=os.path.abspath(self.tmpdir),
                                        prefix="dd-iso")
+        #Are we running on a development version? If yes, enable testing repos
+        cmd = "rpm --eval '%{fedora}'"
+        f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+                                 stderr=STDOUT,
+                                 preexec_fn=self._chroot)
+        output, err = f.communicate()
+        self.repo_pattern = r'.*?-[(source|debug).*]' if int(output.strip()) == self.DEVELOPMENT_VERSION  or \
+            options.repo_testing else r'.*?-[(testing|source|debug)]'
         if not options.repo:
             return True
         else:
@@ -1257,6 +1269,15 @@
             print "\nERROR: Yum Is Not Installed Within The ISO\n"
             self._cleanup_editing()
             return False
+        cmd = "python -c \"from yum import YumBase; import re; yb = YumBase(); " + \
+              "print ' '.join(['--enablerepo=%s' % x.id for x in yb.repos.sort() if not re.match(r'{pat}', x.id)])\""\
+                  .format(pat=self.repo_pattern)
+        print cmd
+        f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+                                 stderr=STDOUT,
+                                 preexec_fn=self._chroot)
+        output, err = f.communicate()
+        repos = output.strip()
         if os.path.isfile(pkgs):
             os.system("mkdir %s/tmp/yumrepo" % self._instroot)
             os.system("touch %s/tmp/yumrepo/%s" % (self._instroot,
@@ -1264,10 +1285,10 @@
             os.system("mount -o bind %s %s/tmp/yumrepo/%s" %
                       (pkgs, self._instroot, os.path.basename(pkgs)))
             print os.listdir("%s/tmp/yumrepo" % self._instroot)
-            yum_cmd = "yum localinstall -y /tmp/yumrepo/%s" % \
-                os.path.basename(pkgs)
+            yum_cmd = "yum %s clean all && yum localinstall -y --setopt=sslverify=false %s /tmp/yumrepo/%s" % \
+                      (repos, repos, os.path.basename(pkgs))
         else:
-            yum_cmd = "yum install -y %s " % pkgs
+            yum_cmd = "yum %s clean all && yum install -y --setopt=sslverify=false %s %s " % (repos, repos, pkgs)
         # make sure rpm keys are imported
         rpm_cmd = "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*"
         rpm = subprocess.Popen(rpm_cmd, shell=True, stdout=PIPE,
@@ -1276,7 +1297,6 @@
         yum = subprocess.Popen(yum_cmd, shell=True, stdout=PIPE,
                                stderr=STDOUT, preexec_fn=self._chroot)
         output, err = yum.communicate()
-        print output
         if yum.returncode > 0:
             print "Yum Install Failed"
             logging.error(output)
@@ -1376,16 +1396,21 @@
 
 
 def parse_options(args):
+    """
+
+    :param args:
+    :return:
+    """
     parser = optparse.OptionParser(option_class=MultipleOption, usage="""
        %prog [-n=<name>]
                       [-o <output>]
-                      [-w <user,encrypted password>
-                      [-l <sshkeyfile>
+                      [-w <user,encrypted password>]
+                      [-l <sshkeyfile>]
                       [-t <tmpdir>]
-                      [--install-kmod <kmod_pkg_name>
-                      [--install-plugin <plugin_name>
-                      [--install <pkg_name>
-                      [--repo <plugin_repo>
+                      [--install-kmod <kmod_pkg_name>]
+                      [--install-plugin <plugin_name>]
+                      [--install <pkg_name>]
+                      [--repo <plugin_repo>]
                       <LIVEIMG.src>""")
 
     parser.add_option("-n", "--name", type="string", dest="name",
@@ -1444,6 +1469,12 @@
                       dest="repo",
                       help="Specify yum repo file or yum repository on the"
                       " filesystem")
+
+    parser.add_option("--enable-testing", action="store_true",
+                     dest="repo_testing",
+                     help="Enable *-testing repositories for package install"
+                     )
+
     parser.add_option("--nogpgcheck", action="store_false", default=True,
                       dest="gpgcheck",
                       help="Allow unsigned packages to be installed")
diff --git a/tools/edit-node.8 b/tools/edit-node.8
index 48dae4b..14d0000 100644
--- a/tools/edit-node.8
+++ b/tools/edit-node.8
@@ -31,6 +31,8 @@
 Multiple packages can be specified by comma delimited list (package1,package2)
 .IP \fB\-\-repo=REPO\fR
 Yum repository can be a local directory, a yum repository file, or a driver disk iso file. It must be used in conjunction with --install* options
+.IP \fB\-\-enable\-testing\fR
+Enable testing repositories for upstream. This will be enabled by default on development/testing versions of Fedora
 .IP \fB\-\-nogpgcheck\fR
 Skip GPG Key verification during yum install (only works with Driver Update isos and local yum repo directory)
 .IP \fB\-\-print-version\fR


-- 
To view, visit http://gerrit.ovirt.org/16522
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia16ef06ac763b4cddc8b45dc7b36892147882a6e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list