Skip to content

Commit

Permalink
feat: add arg --bootstrap-ab-only
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Aug 9, 2024
1 parent 6f6b174 commit 80093cc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions acbs-build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def main() -> None:
parser.add_argument('-z', '--temp-dir', nargs=1, dest='acbs_temp_dir',
help='Override temp directory')
parser.add_argument('--force-use-apt', help="Only use apt to install dependency", action="store_true", dest="force_use_apt")
parser.add_argument('--bootstrap-ab-only', help="Only bootstrap autobuild files", action="store_true", dest="bootstrap_ab_only")


args = parser.parse_args()
if args.acbs_temp_dir:
Expand Down
14 changes: 9 additions & 5 deletions acbs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def __init__(self, args) -> None:
self.reorder = args.reorder
self.save_list = args.save_list
self.force_use_apt = args.force_use_apt
self.bootstrap_ab_only = args.bootstrap_ab_only

# static vars
self.autobuild_conf_dir = AUTOBUILD_CONF_DIR
self.conf_dir = CONF_DIR
Expand Down Expand Up @@ -302,7 +304,7 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
source_name = task.name
if task.base_slug:
source_name = os.path.basename(task.base_slug)
if not has_stamp(task.build_location):
if not has_stamp(task.build_location) and not self.bootstrap_ab_only:
fetch_source(task.source_uri, self.dump_dir, source_name)
if self.dl_only:
if self.generate:
Expand All @@ -317,11 +319,13 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
if not task.build_location:
build_dir = make_build_dir(self.tmp_dir)
task.build_location = build_dir
process_source(task, source_name)
if not self.bootstrap_ab_only:
process_source(task, source_name)
else:
# First sub-package in a meta-package
if not has_stamp(task.build_location):
process_source(task, source_name)
if not self.bootstrap_ab_only:
process_source(task, source_name)
Path(os.path.join(task.build_location, '.acbs-stamp')).touch()
build_dir = task.build_location
if task.subdir:
Expand All @@ -332,14 +336,14 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
raise RuntimeError(
'Could not determine sub-directory, please specify manually.')
build_dir = os.path.join(build_dir, subdir)
if task.installables:
if task.installables and not self.bootstrap_ab_only:
logging.info('Installing dependencies from repository...')
install_from_repo(task.installables, self.force_use_apt)
start = time.monotonic()
task_name = f'{task.name} ({task.bin_arch} @ {task.epoch + ":" if task.epoch else ""}{task.version}-{task.rel})'
try:
scoped_stage2 = ACBSPackageInfo.is_in_stage2(task.modifiers) | self.stage2
invoke_autobuild(task, build_dir, scoped_stage2)
invoke_autobuild(task, build_dir, scoped_stage2, self.bootstrap_ab_only)
check_artifact(task.name, build_dir)
except Exception:
# early printing of build summary before exploding
Expand Down
14 changes: 12 additions & 2 deletions acbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ def start_build_capture(env: Dict[str, str], build_dir: str):
f.write(footer.encode())
if signal_status or exit_status:
raise RuntimeError('autobuild4 did not exit successfully.')

def start_general_autobuild_metadata(env: Dict[str, str], script_location: str):
process = pexpect.spawn('autobuild', args=["-p"], env=env, encoding='utf-8')
process.expect(pexpect.EOF)

with open(os.path.join(script_location, '..', '.srcinfo.json'), 'w') as f:
f.write(process.before)

def generate_metadata(task: ACBSPackageInfo) -> str:
tree_commit = 'unknown\n'
Expand Down Expand Up @@ -228,7 +234,7 @@ def check_artifact(name: str, build_dir: str):
'STOP! Autobuild3 malfunction detected! Returned zero status with no artifact.')


def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool):
def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool, bootstrap_ab_only: bool):
dst_dir = os.path.join(build_dir, 'autobuild')
if os.path.exists(dst_dir) and task.group_seq > 1:
shutil.rmtree(dst_dir)
Expand All @@ -254,7 +260,11 @@ def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool):
f.write(generate_metadata(task))
os.chdir(build_dir)
if build_logging:
start_build_capture(env_dict, build_dir)
if not bootstrap_ab_only:
start_build_capture(env_dict, build_dir)
else:
start_general_autobuild_metadata(env_dict, task.script_location)
exit(0)
return
logging.warning(
'Build logging not available due to pexpect not installed.')
Expand Down

0 comments on commit 80093cc

Please sign in to comment.