summaryrefslogtreecommitdiff
path: root/extensions/ostree.check
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-12-23 14:31:52 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2016-10-07 17:58:13 +0000
commit5bca5fc3e8215601d1e2d33ce31f6a41c4bcfcc9 (patch)
treed56cb8d83a4ee82dd2ac6ebced7c007892573782 /extensions/ostree.check
parent50e5abede697ca0cfbfce46e28f9cb7775762746 (diff)
downloaddefinitions-5bca5fc3e8215601d1e2d33ce31f6a41c4bcfcc9.tar.gz
Add ostree.write deployment extension
This is a simple deployment extension to write the results of a Baserock build to an OSTree repo. See ostree.write.help for more information. The Baserock reference systems contain static device nodes, which are not supported by OSTree, and are obsolete on Linux systems. To work around this problem, I added a strip-device-nodes.configure extension. The systems should still work the same as devtmpfs will create the device nodes. I've tested this by deploying minimal-system-x86_64 to an OSTree repo, then checking it out into a temporary directory, creating a read-only bind-mount of the temporary directory and chrooting then into it. This is only going to be useful for containers systems and chroots for the time being. We would need to make some quite major changes to the Baserock reference systems to enable deployment to VMs or bare metal using OSTree. Change-Id: I8556139d118da759360cdc1ce998590b1f50b644
Diffstat (limited to 'extensions/ostree.check')
-rw-r--r--extensions/ostree.check67
1 files changed, 67 insertions, 0 deletions
diff --git a/extensions/ostree.check b/extensions/ostree.check
new file mode 100644
index 00000000..e5fefe36
--- /dev/null
+++ b/extensions/ostree.check
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# Copyright (C) 2015 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+'''Preparatory checks for Baserock 'ostree' write extension.'''
+
+from gi.repository import GLib
+from gi.repository import Gio
+from gi.repository import OSTree
+
+import logging
+import os
+import urlparse
+
+import writeexts
+
+
+class OSTreeCheckExtension(writeexts.WriteExtension):
+
+ def process_args(self, args):
+ if len(args) != 1:
+ raise writeexts.ExtensionError(
+ 'Wrong number of command line args')
+
+ upgrade = self.get_environment_boolean('UPGRADE')
+ if upgrade:
+ raise writeexts.ExtensionError(
+ 'Use the `ssh-rsync` write extension to deploy upgrades to an '
+ 'existing remote system.')
+
+ location = args[0]
+ self.check_location(location)
+
+ self.check_ostree_parameters()
+
+ def check_location(self, location):
+ repo = OSTree.Repo.new(Gio.File.new_for_path(location))
+ try:
+ repo.open()
+ except GLib.GError as e:
+ logging.debug("Error from OSTree: %s", e)
+ if 'No such file or directory' in e.message:
+ raise writeexts.ExtensionError(
+ "OSTree repo %s was not found." % location)
+ else:
+ raise writeexts.ExtensionError(
+ "Error opening OSTree repo %s: %s" % (location, e))
+
+ def check_ostree_parameters(self):
+ required = ['OSTREE_BRANCH', 'OSTREE_COMMIT_SUBJECT']
+ for var in required:
+ if os.environ.get(var, '') == '':
+ raise writeexts.ExtensionError('%s was not given' % var)
+
+
+OSTreeCheckExtension().run()