diff --git a/acbs-build b/acbs-build index f04afef..2a2db1b 100755 --- a/acbs-build +++ b/acbs-build @@ -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('--general-pkg-metadata-only', help="Only bootstrap autobuild files", action="store_true", dest="general_pkg_metadata_only") + args = parser.parse_args() if args.acbs_temp_dir: diff --git a/acbs/main.py b/acbs/main.py index e171a04..cc05aff 100644 --- a/acbs/main.py +++ b/acbs/main.py @@ -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.general_pkg_metadata_only = args.general_pkg_metadata_only + # static vars self.autobuild_conf_dir = AUTOBUILD_CONF_DIR self.conf_dir = CONF_DIR @@ -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.general_pkg_metadata_only: fetch_source(task.source_uri, self.dump_dir, source_name) if self.dl_only: if self.generate: @@ -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.general_pkg_metadata_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.general_pkg_metadata_only: + process_source(task, source_name) Path(os.path.join(task.build_location, '.acbs-stamp')).touch() build_dir = task.build_location if task.subdir: @@ -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.general_pkg_metadata_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.general_pkg_metadata_only) check_artifact(task.name, build_dir) except Exception: # early printing of build summary before exploding diff --git a/acbs/utils.py b/acbs/utils.py index b3192cb..8b1af1f 100644 --- a/acbs/utils.py +++ b/acbs/utils.py @@ -166,7 +166,15 @@ 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) + path = os.path.join(script_location, '..', '.srcinfo.json') + with open(path, 'w') as f: + f.write(process.before) + logging.info(f".srcinfo.json is save to: {path}") def generate_metadata(task: ACBSPackageInfo) -> str: tree_commit = 'unknown\n' @@ -228,7 +236,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, general_pkg_metadata_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) @@ -254,7 +262,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 general_pkg_metadata_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.')