commands/initramfs.py: Add outfile argument
This new argument waits for a string where the new initrd file will be
placed. If not informed, the file is printed in the stdout, which is the
current behavior.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
diff --git a/virtme/commands/mkinitramfs.py b/virtme/commands/mkinitramfs.py
index d2874ab..563c98b 100755
--- a/virtme/commands/mkinitramfs.py
+++ b/virtme/commands/mkinitramfs.py
@@ -21,6 +21,9 @@
parser.add_argument('--rw', action='store_true', default=False,
help='Mount initramfs as rw. Default is ro')
+ parser.add_argument('--outfile', action='store', default=None,
+ help='Filename of the resulting initramfs file. Default: send initramfs to stdout')
+
return parser
def main():
@@ -40,7 +43,12 @@
if args.rw:
config.access = 'rw'
- mkinitramfs.mkinitramfs(sys.stdout.buffer, config)
+ if args.outfile is None:
+ buf = sys.stdout.buffer
+ else:
+ buf = open(args.outfile, 'w+b')
+
+ mkinitramfs.mkinitramfs(buf, config)
return 0