Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Perform more operations with sudo #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions freedommaker/vmdebootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def make_image(self):

logger.info('Moving file: %s -> %s', temp_image_file,
self.builder.image_file)
shutil.move(temp_image_file, self.builder.image_file)
self.builder._run(
['sudo', 'mv', temp_image_file, self.builder.image_file])

def _cleanup_vmdebootstrap(self, image_file):
"""Cleanup those that vmdebootstrap is supposed to have cleaned up."""
# XXX: Remove this when vmdebootstrap removes kpartx mappings properly
# after a successful build.
process = subprocess.run(['losetup', '--json'],
process = subprocess.run(['/sbin/losetup', '--json'],
stdout=subprocess.PIPE,
check=True)
output = process.stdout.decode()
Expand All @@ -128,13 +129,9 @@ def _cleanup_vmdebootstrap(self, image_file):
]
# Don't log command, ignore errors, force
for device in partition_devices:
subprocess.run(['dmsetup', 'remove', '-f', device],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.run(['sudo', 'dmsetup', 'remove', '-f', device])

subprocess.run(['losetup', '-d', loop_device],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.run(['sudo', 'losetup', '-d', loop_device])

def process_variant(self):
"""Add paramaters for deboostrap variant."""
Expand Down