summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-02 13:10:25 +0000
committerLars Wirzenius <liw@liw.fi>2017-04-02 13:10:25 +0000
commit60be98641616b2be27c4ee35a9be50e0ca36bf32 (patch)
tree16279ed5e639e2854e900998fa04762d261cc67a
parentb4b50caf0f4f8f018125c682f3b147f2bf69013d (diff)
downloadvmdb2-60be98641616b2be27c4ee35a9be50e0ca36bf32.tar.gz
Add an apt step runner
-rw-r--r--simple.yaml2
-rw-r--r--vmdb/plugins/apt_plugin.py48
2 files changed, 49 insertions, 1 deletions
diff --git a/simple.yaml b/simple.yaml
index 165d574..713f25c 100644
--- a/simple.yaml
+++ b/simple.yaml
@@ -21,7 +21,7 @@ steps:
mirror: http://http.debian.net/debian
target: root-fs
- - kernel: linux-image-amd64
+ - apt: linux-image-amd64
fs-tag: root-fs
- shell: |
diff --git a/vmdb/plugins/apt_plugin.py b/vmdb/plugins/apt_plugin.py
new file mode 100644
index 0000000..b567e75
--- /dev/null
+++ b/vmdb/plugins/apt_plugin.py
@@ -0,0 +1,48 @@
+# Copyright 2017 Lars Wirzenius
+#
+# 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 3 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 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/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+
+import logging
+import sys
+
+import cliapp
+
+import vmdb
+
+
+class AptPlugin(cliapp.Plugin):
+
+ def enable(self):
+ self.app.step_runners.add(AptStepRunner())
+
+
+class AptStepRunner(vmdb.StepRunnerInterface):
+
+ def get_required_keys(self):
+ return ['apt', 'fs-tag']
+
+ def run(self, step, settings, state):
+ package = step['apt']
+ fstag = step['fs-tag']
+ mount_point = state.mounts[fstag]
+ vmdb.progress(
+ 'Install package {} to filesystem at {} ({})\n'.format(
+ package, mount_point, fstag))
+ vmdb.runcmd(
+ ['chroot', mount_point,
+ 'apt-get', '-y', '--no-show-progress', 'install', package])