Use long options wherever possible.

This makes the code a lot easier to understand
This commit is contained in:
Anders Ingemann 2013-08-17 15:00:53 +00:00
parent 3630d72f0a
commit e1fc5ea972
10 changed files with 28 additions and 19 deletions

View file

@ -47,8 +47,11 @@ class AptUpgrade(Task):
def run(self, info):
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'update'])
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '-f', '-y', 'install'])
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '-y', 'upgrade'])
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get',
'--fix-broken',
'--assume-yes',
'install'])
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '--assume-yes', 'upgrade'])
class PurgeUnusedPackages(Task):

View file

@ -60,7 +60,7 @@ class MountVolume(Task):
raise TaskError(msg)
log_check_call(['/bin/mount',
'-t', info.manifest.volume['filesystem'],
'--types', info.manifest.volume['filesystem'],
info.bootstrap_device['partitions']['root_path'],
info.root])
@ -72,9 +72,9 @@ class MountSpecials(Task):
def run(self, info):
log_check_call(['/bin/mount', '--bind', '/dev', '{root}/dev'.format(root=info.root)])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '-t', 'proc', 'none', '/proc'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '-t', 'sysfs', 'none', '/sys'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '-t', 'devpts', 'none', '/dev/pts'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '--types', 'proc', 'none', '/proc'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '--types', 'sysfs', 'none', '/sys'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/mount', '--types', 'devpts', 'none', '/dev/pts'])
class UnmountSpecials(Task):

View file

@ -14,7 +14,7 @@ class CheckPackages(Task):
from subprocess import CalledProcessError
for package in info.host_packages:
try:
log_check_call(['/usr/bin/dpkg', '-s', package])
log_check_call(['/usr/bin/dpkg', '--status', package])
except CalledProcessError:
msg = "The package ``{0}\'\' is not installed".format(package)
raise TaskError(msg)

View file

@ -42,7 +42,7 @@ class InstallInitScripts(Task):
dst = os.path.join(info.root, 'etc/init.d', name)
copy(src, dst)
os.chmod(dst, rwxr_xr_x)
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-d', name])
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--default', name])
for name in info.initd['disable']:
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '-r', name])
log_check_call(['/usr/sbin/chroot', info.root, '/sbin/insserv', '--remove', name])

View file

@ -46,7 +46,7 @@ class Detach(Task):
after = [UnmountVolume]
def run(self, info):
log_check_call(['/sbin/losetup', '-d', info.bootstrap_device['path']])
log_check_call(['/sbin/losetup', '--detach', info.bootstrap_device['path']])
del info.bootstrap_device

View file

@ -11,11 +11,11 @@ class PartitionVolume(Task):
def run(self, info):
# parted
log_check_call(['parted', '-a', 'optimal', '-s', info.bootstrap_device['path'],
log_check_call(['parted', '--align', 'optimal', '--script', info.bootstrap_device['path'],
'--', 'mklabel', 'msdos'])
log_check_call(['parted', '-a', 'optimal', '-s', info.bootstrap_device['path'],
log_check_call(['parted', '--align', 'optimal', '--script', info.bootstrap_device['path'],
'--', 'mkpart', 'primary', 'ext4', '32k', '-1'])
log_check_call(['parted', '-s', info.bootstrap_device['path'],
log_check_call(['parted', '--script', info.bootstrap_device['path'],
'--', 'set', '1', 'boot', 'on'])
@ -25,8 +25,8 @@ class MapPartitions(Task):
after = [PartitionVolume]
def run(self, info):
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
info.bootstrap_device['partitions'] = {'root_path': root_partition_path}
@ -37,6 +37,7 @@ class FormatPartitions(Task):
after = [MapPartitions]
def run(self, info):
# These params will fail for mkfs.xfs
log_check_call(['/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']),
'-m', '1', '-v', info.bootstrap_device['partitions']['root_path']])

View file

@ -33,4 +33,6 @@ class AddBackportsPackages(Task):
from common.tools import log_check_call
for pkg in info.manifest.plugins['backports']['packages']:
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'install', '-y', '-t', info.manifest.system['release'] + '-backports', pkg])
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'install',
'--assume-yes', '--target-release', info.manifest.system['release'] + '-backports',
pkg])

View file

@ -23,7 +23,8 @@ class OpenNebulaContext(Task):
os.chmod(script_dst, rwxr_xr_x)
from common.tools import log_check_call
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/dpkg', '-i', '/tmp/one-context_3.8.1.deb'])
log_check_call(['/usr/sbin/chroot', info.root,
'/usr/bin/dpkg', '--install', '/tmp/one-context_3.8.1.deb'])
# Fix start
from common.tools import sed_i
vmcontext_def = os.path.join(info.root, 'etc/init.d/vmcontext')

View file

@ -42,4 +42,5 @@ class AddLocalUserPackages(Task):
copy(script_src, script_dst)
os.chmod(script_dst, rwxr_xr_x)
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/dpkg', '-i', '/tmp/'+os.path.basename(script_src)])
log_check_call(['/usr/sbin/chroot', info.root,
'/usr/bin/dpkg', '--install', '/tmp/'+os.path.basename(script_src)])

View file

@ -31,4 +31,5 @@ class ConfigureGrub(Task):
from common.tools import log_check_call
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
log_check_call(['/usr/sbin/chroot', info.root, '/bin/ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])
log_check_call(['/usr/sbin/chroot', info.root,
'/bin/ln', '--symbolic', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])