netgod / rpms / anaconda

Forked from rpms/anaconda 2 years ago
Clone
Karanbir Singh 17adf5
From c72f979499f5af3091ad8f2017442b3728cdff2f Mon Sep 17 00:00:00 2001
Karanbir Singh 17adf5
From: Colin Walters <walters@verbum.org>
Karanbir Singh 17adf5
Date: Tue, 16 Jun 2015 11:24:20 -0400
Karanbir Singh 17adf5
Subject: [PATCH] Rebase
Karanbir Singh 17adf5
Karanbir Singh 17adf5
---
Karanbir Singh 17adf5
 pyanaconda/packaging/rpmostreepayload.py | 67 ++++++++++++++++++++------------
Karanbir Singh 17adf5
 1 file changed, 43 insertions(+), 24 deletions(-)
Karanbir Singh 17adf5
Karanbir Singh 17adf5
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
Karanbir Singh 17adf5
index 5eacd9f..f979c3e 100644
Karanbir Singh 17adf5
--- a/pyanaconda/packaging/rpmostreepayload.py
Karanbir Singh 17adf5
+++ b/pyanaconda/packaging/rpmostreepayload.py
Karanbir Singh 17adf5
@@ -138,24 +138,25 @@ class RPMOSTreePayload(ArchivePayload):
Karanbir Singh 17adf5
             ["admin", "--sysroot=" + iutil.getTargetPhysicalRoot(),
Karanbir Singh 17adf5
              "init-fs", iutil.getTargetPhysicalRoot()])
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        repo_arg = "--repo=" + iutil.getTargetPhysicalRoot() + '/ostree/repo'
Karanbir Singh 17adf5
+        self._sysroot_path = Gio.File.new_for_path(iutil.getTargetPhysicalRoot())
Karanbir Singh 17adf5
+        sysroot = OSTree.Sysroot.new(self._sysroot_path)
Karanbir Singh 17adf5
+        sysroot.load(cancellable)
Karanbir Singh 17adf5
+        repo = sysroot.get_repo(None)[1]
Karanbir Singh 17adf5
+        # We don't support resuming from interrupted installs
Karanbir Singh 17adf5
+        repo.set_disable_fsync(True)
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        # Store this for use in postInstall too, where we need to
Karanbir Singh 17adf5
-        # undo/redo this step.
Karanbir Singh 17adf5
-        self._base_remote_args = ["remote", "add"]
Karanbir Singh 17adf5
+        self._remoteOptions = {}
Karanbir Singh 17adf5
+
Karanbir Singh 17adf5
+        # Handle variations in pykickstart
Karanbir Singh 17adf5
         if ((hasattr(ostreesetup, 'noGpg') and ostreesetup.noGpg) or
Karanbir Singh 17adf5
             (hasattr(ostreesetup, 'nogpg') and ostreesetup.nogpg)):
Karanbir Singh 17adf5
-            self._base_remote_args.append("--set=gpg-verify=false")
Karanbir Singh 17adf5
-        self._base_remote_args.extend([ostreesetup.remote,
Karanbir Singh 17adf5
-                                     ostreesetup.url])
Karanbir Singh 17adf5
-        self._safeExecWithRedirect("ostree", [repo_arg] + self._base_remote_args)
Karanbir Singh 17adf5
+            self._remoteOptions['gpg-verify'] = GLib.Variant('b', False)
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        self._sysroot_path = sysroot_path = Gio.File.new_for_path(iutil.getTargetPhysicalRoot())
Karanbir Singh 17adf5
-        sysroot = OSTree.Sysroot.new(sysroot_path)
Karanbir Singh 17adf5
-        sysroot.load(cancellable)
Karanbir Singh 17adf5
+        repo.remote_change(None, OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS,
Karanbir Singh 17adf5
+                           ostreesetup.remote, ostreesetup.url,
Karanbir Singh 17adf5
+                           GLib.Variant('a{sv}', self._remoteOptions),
Karanbir Singh 17adf5
+                           cancellable)
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        repo = sysroot.get_repo(None)[1]
Karanbir Singh 17adf5
-        repo.set_disable_fsync(True)
Karanbir Singh 17adf5
         progressQ.send_message(_("Starting pull of %(branchName)s from %(source)s") % \
Karanbir Singh 17adf5
                                {"branchName": ostreesetup.ref, "source": ostreesetup.remote})
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
@@ -174,6 +175,14 @@ class RPMOSTreePayload(ArchivePayload):
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
         progressQ.send_message(_("Preparing deployment of %s") % (ostreesetup.ref, ))
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
+        # Now that we have the data pulled, delete the remote for now.
Karanbir Singh 17adf5
+        # This will allow a remote configuration defined in the tree
Karanbir Singh 17adf5
+        # (if any) to override what's in the kickstart.  Otherwise,
Karanbir Singh 17adf5
+        # we'll re-add it in post.  Ideally, ostree would support a
Karanbir Singh 17adf5
+        # pull without adding a remote, but that would get quite
Karanbir Singh 17adf5
+        # complex.
Karanbir Singh 17adf5
+        repo.remote_delete(self.data.ostreesetup.remote, None)
Karanbir Singh 17adf5
+
Karanbir Singh 17adf5
         self._safeExecWithRedirect("ostree",
Karanbir Singh 17adf5
             ["admin", "--sysroot=" + iutil.getTargetPhysicalRoot(),
Karanbir Singh 17adf5
              "os-init", ostreesetup.osname])
Karanbir Singh 17adf5
@@ -250,24 +259,34 @@ class RPMOSTreePayload(ArchivePayload):
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
     def postInstall(self):
Karanbir Singh 17adf5
         super(RPMOSTreePayload, self).postInstall()
Karanbir Singh 17adf5
-
Karanbir Singh 17adf5
+        
Karanbir Singh 17adf5
         from gi.repository import OSTree
Karanbir Singh 17adf5
         cancellable = None
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        # Reload this data - we couldn't keep it open across
Karanbir Singh 17adf5
-        # the remounts happening.
Karanbir Singh 17adf5
         sysroot = OSTree.Sysroot.new(self._sysroot_path)
Karanbir Singh 17adf5
         sysroot.load(cancellable)
Karanbir Singh 17adf5
         repo = sysroot.get_repo(None)[1]
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-        # This is an ugly hack - we didn't have /etc/ostree/remotes.d,
Karanbir Singh 17adf5
-        # so the remote went into /ostree/repo/config.  But we want it
Karanbir Singh 17adf5
-        # in /etc, so delete that remote, then re-add it to
Karanbir Singh 17adf5
-        # /etc/ostree/remotes.d, executing ostree inside the sysroot
Karanbir Singh 17adf5
-        # so that it understands it's a "system repository" and should
Karanbir Singh 17adf5
-        # modify /etc.
Karanbir Singh 17adf5
-        repo.remote_delete(self.data.ostreesetup.remote, None)
Karanbir Singh 17adf5
-        self._safeExecWithRedirect("ostree", self._base_remote_args, root=iutil.getSysroot())
Karanbir Singh 17adf5
+        # CentOS specific patch (for now) - pull the remote config from usr/etc if it exists.
Karanbir Singh 17adf5
+        # The OSTree handling here was buggy in that it wasn't looking in the sysroot
Karanbir Singh 17adf5
+        # for existing remotes.
Karanbir Singh 17adf5
+        default_remote_path = iutil.getSysroot() + '/usr/etc/ostree/remotes.d/' + self.data.ostreesetup.osname + '.conf'
Karanbir Singh 17adf5
+        if os.path.isfile(default_remote_path):
Karanbir Singh 17adf5
+            destpath = iutil.getSysroot() + '/etc/ostree/remotes.d/' + os.path.basename(default_remote_path)
Karanbir Singh 17adf5
+            self._safeExecWithRedirect('cp', ['-r', '-p', default_remote_path, destpath])
Karanbir Singh 17adf5
+        else:
Karanbir Singh 17adf5
+            # Following up on the "remote delete" above, we removed the
Karanbir Singh 17adf5
+            # remote from /ostree/repo/config.  But we want it in /etc, so
Karanbir Singh 17adf5
+            # re-add it to /etc/ostree/remotes.d, using the sysroot path.
Karanbir Singh 17adf5
+            #
Karanbir Singh 17adf5
+            # However, we ignore the case where the remote already exists,
Karanbir Singh 17adf5
+            # which occurs when the content itself provides the remote
Karanbir Singh 17adf5
+            # config file.
Karanbir Singh 17adf5
+            repo.remote_change(Gio.File.new_for_path(iutil.getSysroot()),
Karanbir Singh 17adf5
+                               OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS,
Karanbir Singh 17adf5
+                               self.data.ostreesetup.remote, self.data.ostreesetup.url,
Karanbir Singh 17adf5
+                               GLib.Variant('a{sv}', self._remoteOptions),
Karanbir Singh 17adf5
+                               cancellable)
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
         boot = iutil.getSysroot() + '/boot'
Karanbir Singh 17adf5
 
Karanbir Singh 17adf5
-- 
Karanbir Singh 17adf5
1.8.3.1
Karanbir Singh 17adf5