docker: move to component

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-10-24 00:00:00 +00:00
parent 3980974e91
commit a410100f3f

View File

@@ -1,29 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import common
import subprocess import subprocess
import tarfile import tarfile
import time
parser = common.get_argparse(argparse_args={ import common
class DockerComponent(common.Component):
def get_argparse_args(self):
return {
'description': '''\ 'description': '''\
Build a guest root filesystem based on prebuilt Docker Ubuntu root filesystems. Build a guest root filesystem based on prebuilt Docker Ubuntu root filesystems.
See also:https://github.com/cirosantilli/linux-kernel-module-cheat#ubuntu-guest-setup See also:https://github.com/cirosantilli/linux-kernel-module-cheat#ubuntu-guest-setup
''' '''
}, }
default_args={'docker': True},
) def do_build(self, args):
common.add_build_arguments(parser) build_dir = self.get_build_dir(args)
args = common.setup(parser)
container_name = 'lkmc-guest' container_name = 'lkmc-guest'
#common.rmrf(common.docker_build_dir)
if not args.clean:
start_time = time.time()
target_dir = os.path.join('/root', 'linux-kernel-module-cheat') target_dir = os.path.join('/root', 'linux-kernel-module-cheat')
os.makedirs(common.docker_build_dir, exist_ok=True) os.makedirs(build_dir, exist_ok=True)
containers = subprocess.check_output([ containers = subprocess.check_output([
'docker', 'docker',
'ps', 'ps',
@@ -71,5 +69,11 @@ if not args.clean:
common.docker_rootfs_raw_file, common.docker_rootfs_raw_file,
]) ])
common.raw_to_qcow2(prebuilt=True) common.raw_to_qcow2(prebuilt=True)
end_time = time.time()
common.print_time(end_time - start_time) def get_build_dir(self, args):
return common.docker_build_dir
def get_default_args(self):
return {'docker': True}
DockerComponent().build()