Skip to content

Commit

Permalink
deb_autopkg: add building just all base images
Browse files Browse the repository at this point in the history
Adding a new command repo-build-baseimage <cf> that builds all (missing)
base images for the targets used in given repo config.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
  • Loading branch information
metux committed Sep 7, 2023
1 parent 2fad840 commit 48872e3
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deb_autopkg/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) Enrico Weigelt, metux IT consult <info@metux.net>

from metux.util.task import TaskRunner
from .tasks import pkg_build, pkg_clone, all_clone, pool_build, pool_upload, pool_deploy
from .tasks import pkg_build, pkg_clone, all_clone, all_baseimage, pool_build, pool_upload, pool_deploy
from metux.util.specobject import SpecError

class Builder:
Expand All @@ -22,6 +22,9 @@ def clone_package(self, name):
def clone_all(self):
return self._run(all_clone.alloc(self.conf))

def baseimage_all(self):
return self._run(all_baseimage.alloc(self.conf))

def build_pool(self, name):
if name is None or name == '':
name = self.conf['defaults::build-pool']
Expand Down
14 changes: 14 additions & 0 deletions deb_autopkg/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def build_package(conffile, pkg):
def clone_all(conffile):
return Builder(load(conffile)).clone_all()

@cmdfunc
def baseimage_all(conffile):
return Builder(load(conffile)).baseimage_all()

@cmdfunc
def get_builder(conffile):
return Builder(load(conffile))
Expand Down Expand Up @@ -76,3 +80,13 @@ def tool_repo_build_pool(argv):
return build_pool(argv[1], None)

return build_pool(argv[1], argv[2])

@cmdfunc
def tool_repo_build_rootfs(argv):
if len(argv) < 2:
print("%s <config-file>" % argv[0])
print("")
print("Build root filesystems for targets in given config file")
return 1

return baseimage_all(argv[1])
21 changes: 21 additions & 0 deletions deb_autopkg/tasks/all_baseimage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) Enrico Weigelt, metux IT consult <info@metux.net>

from metux.util.task import Task
from .target_rootfs import alloc as target_rootfs_alloc
from .dckbp_clone import alloc as dckbp_clone_alloc

""" Task: clone all package git repos"""
class BaseimageAllTask(Task):

def get_subtasks(self):
conf = self.param['conf']
tasks = [ dckbp_clone_alloc(conf) ]

for t in conf.get_targets():
tasks.append(target_rootfs_alloc(conf, t))

return tasks

def alloc(conf):
return conf.cached_task_alloc('baseimage-all', BaseimageAllTask, { 'conf': conf })
35 changes: 35 additions & 0 deletions deb_autopkg/tasks/target_rootfs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) Enrico Weigelt, metux IT consult <info@metux.net>

from metux.util.task import Task
from os import environ
from copy import copy
from subprocess import call

"""build for apt (docker-buildpackage)"""
class TargetBaseimageTask(Task):

"""[private]"""
def __init__(self, param):
Task.__init__(self, param)
self.target = param['target']
self.conf = param['conf']

def do_run(self):
tgt = self.target

env = copy(environ)

self.log_info('building rootfs for target "%s"' % tgt['name'])

if (call([self.conf.get_dckbp_cmd(),
'--create-baseimage',
'--target',
self.target['dck-buildpackage::target']],
env=env) != 0):
self.fail("rootfs build failed: "+tgt['name'])

return True

def alloc(conf, target):
return conf.cached_task_alloc('target-baseimage:'+target['name'], TargetBaseimageTask, { 'target': target })
4 changes: 4 additions & 0 deletions repo-build-baseimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python3
import sys, deb_autopkg
from deb_autopkg import cmd
sys.exit(cmd.tool_repo_build_rootfs(sys.argv))

0 comments on commit 48872e3

Please sign in to comment.