mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Use long options wherever possible.
This makes the code a lot easier to understand
This commit is contained in:
parent
3630d72f0a
commit
e1fc5ea972
10 changed files with 28 additions and 19 deletions
|
@ -47,8 +47,11 @@ class AptUpgrade(Task):
|
||||||
|
|
||||||
def run(self, info):
|
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', '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',
|
||||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '-y', 'upgrade'])
|
'--fix-broken',
|
||||||
|
'--assume-yes',
|
||||||
|
'install'])
|
||||||
|
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', '--assume-yes', 'upgrade'])
|
||||||
|
|
||||||
|
|
||||||
class PurgeUnusedPackages(Task):
|
class PurgeUnusedPackages(Task):
|
||||||
|
|
|
@ -60,7 +60,7 @@ class MountVolume(Task):
|
||||||
raise TaskError(msg)
|
raise TaskError(msg)
|
||||||
|
|
||||||
log_check_call(['/bin/mount',
|
log_check_call(['/bin/mount',
|
||||||
'-t', info.manifest.volume['filesystem'],
|
'--types', info.manifest.volume['filesystem'],
|
||||||
info.bootstrap_device['partitions']['root_path'],
|
info.bootstrap_device['partitions']['root_path'],
|
||||||
info.root])
|
info.root])
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ class MountSpecials(Task):
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
log_check_call(['/bin/mount', '--bind', '/dev', '{root}/dev'.format(root=info.root)])
|
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', '--types', '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', '--types', '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', 'devpts', 'none', '/dev/pts'])
|
||||||
|
|
||||||
|
|
||||||
class UnmountSpecials(Task):
|
class UnmountSpecials(Task):
|
||||||
|
|
|
@ -14,7 +14,7 @@ class CheckPackages(Task):
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
for package in info.host_packages:
|
for package in info.host_packages:
|
||||||
try:
|
try:
|
||||||
log_check_call(['/usr/bin/dpkg', '-s', package])
|
log_check_call(['/usr/bin/dpkg', '--status', package])
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
msg = "The package ``{0}\'\' is not installed".format(package)
|
msg = "The package ``{0}\'\' is not installed".format(package)
|
||||||
raise TaskError(msg)
|
raise TaskError(msg)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class InstallInitScripts(Task):
|
||||||
dst = os.path.join(info.root, 'etc/init.d', name)
|
dst = os.path.join(info.root, 'etc/init.d', name)
|
||||||
copy(src, dst)
|
copy(src, dst)
|
||||||
os.chmod(dst, rwxr_xr_x)
|
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']:
|
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])
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Detach(Task):
|
||||||
after = [UnmountVolume]
|
after = [UnmountVolume]
|
||||||
|
|
||||||
def run(self, info):
|
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
|
del info.bootstrap_device
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ class PartitionVolume(Task):
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
# parted
|
# 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'])
|
'--', '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'])
|
'--', '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'])
|
'--', 'set', '1', 'boot', 'on'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ class MapPartitions(Task):
|
||||||
after = [PartitionVolume]
|
after = [PartitionVolume]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
|
root_partition_path = info.bootstrap_device['path'].replace('/dev', '/dev/mapper')+'p1'
|
||||||
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
|
log_check_call(['kpartx', '-a', '-v', info.bootstrap_device['path']])
|
||||||
info.bootstrap_device['partitions'] = {'root_path': root_partition_path}
|
info.bootstrap_device['partitions'] = {'root_path': root_partition_path}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ class FormatPartitions(Task):
|
||||||
after = [MapPartitions]
|
after = [MapPartitions]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
|
# These params will fail for mkfs.xfs
|
||||||
log_check_call(['/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']),
|
log_check_call(['/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']),
|
||||||
'-m', '1', '-v', info.bootstrap_device['partitions']['root_path']])
|
'-m', '1', '-v', info.bootstrap_device['partitions']['root_path']])
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,6 @@ class AddBackportsPackages(Task):
|
||||||
|
|
||||||
from common.tools import log_check_call
|
from common.tools import log_check_call
|
||||||
for pkg in info.manifest.plugins['backports']['packages']:
|
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])
|
||||||
|
|
|
@ -23,7 +23,8 @@ class OpenNebulaContext(Task):
|
||||||
os.chmod(script_dst, rwxr_xr_x)
|
os.chmod(script_dst, rwxr_xr_x)
|
||||||
|
|
||||||
from common.tools import log_check_call
|
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
|
# Fix start
|
||||||
from common.tools import sed_i
|
from common.tools import sed_i
|
||||||
vmcontext_def = os.path.join(info.root, 'etc/init.d/vmcontext')
|
vmcontext_def = os.path.join(info.root, 'etc/init.d/vmcontext')
|
||||||
|
|
|
@ -42,4 +42,5 @@ class AddLocalUserPackages(Task):
|
||||||
copy(script_src, script_dst)
|
copy(script_src, script_dst)
|
||||||
os.chmod(script_dst, rwxr_xr_x)
|
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)])
|
||||||
|
|
|
@ -31,4 +31,5 @@ class ConfigureGrub(Task):
|
||||||
|
|
||||||
from common.tools import log_check_call
|
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, '/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'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue