Skip to content

Commit b43c47b

Browse files
committed
feat: add arg --bootstrap-ab-only
1 parent 6f6b174 commit b43c47b

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

Diff for: acbs-build

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def main() -> None:
5252
parser.add_argument('-z', '--temp-dir', nargs=1, dest='acbs_temp_dir',
5353
help='Override temp directory')
5454
parser.add_argument('--force-use-apt', help="Only use apt to install dependency", action="store_true", dest="force_use_apt")
55+
parser.add_argument('--bootstrap-ab-only', help="Only bootstrap autobuild files", action="store_true", dest="bootstrap_ab_only")
56+
5557

5658
args = parser.parse_args()
5759
if args.acbs_temp_dir:

Diff for: acbs/main.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def __init__(self, args) -> None:
9999
self.reorder = args.reorder
100100
self.save_list = args.save_list
101101
self.force_use_apt = args.force_use_apt
102+
self.bootstrap_ab_only = args.bootstrap_ab_only
103+
102104
# static vars
103105
self.autobuild_conf_dir = AUTOBUILD_CONF_DIR
104106
self.conf_dir = CONF_DIR
@@ -302,7 +304,7 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
302304
source_name = task.name
303305
if task.base_slug:
304306
source_name = os.path.basename(task.base_slug)
305-
if not has_stamp(task.build_location):
307+
if not has_stamp(task.build_location) and not self.bootstrap_ab_only:
306308
fetch_source(task.source_uri, self.dump_dir, source_name)
307309
if self.dl_only:
308310
if self.generate:
@@ -317,11 +319,13 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
317319
if not task.build_location:
318320
build_dir = make_build_dir(self.tmp_dir)
319321
task.build_location = build_dir
320-
process_source(task, source_name)
322+
if not self.bootstrap_ab_only:
323+
process_source(task, source_name)
321324
else:
322325
# First sub-package in a meta-package
323326
if not has_stamp(task.build_location):
324-
process_source(task, source_name)
327+
if not self.bootstrap_ab_only:
328+
process_source(task, source_name)
325329
Path(os.path.join(task.build_location, '.acbs-stamp')).touch()
326330
build_dir = task.build_location
327331
if task.subdir:
@@ -332,14 +336,14 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]):
332336
raise RuntimeError(
333337
'Could not determine sub-directory, please specify manually.')
334338
build_dir = os.path.join(build_dir, subdir)
335-
if task.installables:
339+
if task.installables and not self.bootstrap_ab_only:
336340
logging.info('Installing dependencies from repository...')
337341
install_from_repo(task.installables, self.force_use_apt)
338342
start = time.monotonic()
339343
task_name = f'{task.name} ({task.bin_arch} @ {task.epoch + ":" if task.epoch else ""}{task.version}-{task.rel})'
340344
try:
341345
scoped_stage2 = ACBSPackageInfo.is_in_stage2(task.modifiers) | self.stage2
342-
invoke_autobuild(task, build_dir, scoped_stage2)
346+
invoke_autobuild(task, build_dir, scoped_stage2, self.bootstrap_ab_only)
343347
check_artifact(task.name, build_dir)
344348
except Exception:
345349
# early printing of build summary before exploding

Diff for: acbs/utils.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ def start_build_capture(env: Dict[str, str], build_dir: str):
166166
f.write(footer.encode())
167167
if signal_status or exit_status:
168168
raise RuntimeError('autobuild4 did not exit successfully.')
169+
170+
def start_general_autobuild_metadata(env: Dict[str, str], script_location: str):
171+
process = pexpect.spawn('autobuild', args=["-p"], env=env, encoding='utf-8')
172+
process.expect(pexpect.EOF)
169173

174+
path = os.path.join(script_location, '..', '.srcinfo.json')
175+
with open(path, 'w') as f:
176+
f.write(process.before)
177+
logging.info(f".srcinfo.json is save to: {path}")
170178

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

230238

231-
def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool):
239+
def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool, bootstrap_ab_only: bool):
232240
dst_dir = os.path.join(build_dir, 'autobuild')
233241
if os.path.exists(dst_dir) and task.group_seq > 1:
234242
shutil.rmtree(dst_dir)
@@ -254,7 +262,11 @@ def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool):
254262
f.write(generate_metadata(task))
255263
os.chdir(build_dir)
256264
if build_logging:
257-
start_build_capture(env_dict, build_dir)
265+
if not bootstrap_ab_only:
266+
start_build_capture(env_dict, build_dir)
267+
else:
268+
start_general_autobuild_metadata(env_dict, task.script_location)
269+
exit(0)
258270
return
259271
logging.warning(
260272
'Build logging not available due to pexpect not installed.')

0 commit comments

Comments
 (0)