Skip to content

Commit 79a3ce2

Browse files
Cyanoxygenliushuyu
andcommitted
main, parser, utils: reorganize utility funttions and reflect ab3cfg changes
Co-Authored-By: liushuyu <[email protected]>
1 parent 450956c commit 79a3ce2

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

acbs/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from pathlib import Path
88
from typing import List, Tuple
99

10-
import acbs.ab3cfg
1110
import acbs.fetch
1211
import acbs.parser
1312

1413
from acbs import __version__
14+
from acbs.ab3cfg import is_in_stage2
1515
from acbs.base import ACBSPackageInfo
1616
from acbs.checkpoint import ACBSShrinkWrap, do_shrink_wrap, checkpoint_to_group
1717
from acbs.const import CONF_DIR, DUMP_DIR, LOG_DIR, TMP_DIR, AUTOBUILD_CONF_DIR
@@ -39,15 +39,13 @@ def __init__(self, args) -> None:
3939
self.package_cursor = 0
4040
self.reorder = args.reorder
4141
self.save_list = args.save_list
42-
self.stage2 = False
4342
# static vars
4443
self.autobuild_conf_dir = AUTOBUILD_CONF_DIR
4544
self.conf_dir = CONF_DIR
4645
self.dump_dir = DUMP_DIR
4746
self.tmp_dir = TMP_DIR
4847
self.log_dir = LOG_DIR
49-
self.ab3 = acbs.ab3cfg.AB3Cfg(os.path.join(AUTOBUILD_CONF_DIR, 'ab3cfg.sh'))
50-
self.stage2 = self.ab3.is_in_stage2()
48+
self.stage2 = is_in_stage2()
5149
if args.acbs_tree:
5250
self.tree = args.acbs_tree[0]
5351
self.init()

acbs/parser.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@
88
from acbs import bashvar
99
from acbs.base import ACBSPackageInfo, ACBSSourceInfo
1010
from acbs.pm import filter_dependencies
11-
from acbs.utils import get_arch_name, tarball_pattern, fail_arch_regex, get_defines_file_path
11+
from acbs.utils import get_arch_name, tarball_pattern, fail_arch_regex
1212

1313
generate_mode = False
1414

1515

16+
def get_defines_file_path(location: str, stage2: bool=False) -> str:
17+
'''
18+
Return ${location}/defines or ${location}/defines.stage2 depending on the value of stage2 and whether the .stage2 file exists.
19+
'''
20+
if stage2 and os.path.exists(os.path.join(location, 'defines.stage2')):
21+
return os.path.join(location, 'defines.stage2')
22+
else:
23+
return os.path.join(location, 'defines')
24+
25+
1626
def parse_url_schema(url: str, checksum: str) -> ACBSSourceInfo:
1727
acbs_source_info = ACBSSourceInfo('none', '', '')
1828
url_split = url.split('::', 2)

acbs/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,3 @@ def format(self, record):
326326
logging.INFO, logging.DEBUG):
327327
record.msg = f'[{lvl_map[record.levelname]}]: \033[1m{record.msg}\033[0m'
328328
return super(ACBSLogFormatter, self).format(record)
329-
330-
def get_defines_file_path(location, stage2=False) -> str:
331-
'''
332-
Return ${location}/defines or ${location}/defines.stage2 on various conditions.
333-
'''
334-
if stage2 == False:
335-
return os.path.join(location, 'defines')
336-
if os.path.exists(os.path.join(location, 'defines.stage2')):
337-
return os.path.join(location, 'defines.stage2')

0 commit comments

Comments
 (0)