Skip to content

Commit 7ec28ac

Browse files
committed
utils: allow overriding current architecture name ...
... acbs will now read ARCH override value from /etc/autobuild/ab4cfg.sh
1 parent 0c6cf9f commit 7ec28ac

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

acbs/ab4cfg.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@
55
from acbs import bashvar
66
from acbs.const import AUTOBUILD_CONF_DIR
77

8-
from typing import Optional
8+
from typing import Optional, Dict
99

1010

11-
def is_in_stage2_file(abcfg_path: str) -> bool:
11+
def _parse_abcfg(abcfg_path: str) -> Dict[str, str]:
1212
with open(abcfg_path) as f:
1313
vars = bashvar.eval_bashvar(f.read(), filename=abcfg_path)
1414
assert isinstance(vars, dict)
15-
stage2_val: Optional[str] = vars.get('ABSTAGE2')
16-
return stage2_val == '1'
17-
return False
15+
return vars
16+
17+
18+
def get_arch_override(abcfg_path: str) -> Optional[str]:
19+
vars = _parse_abcfg(abcfg_path)
20+
return vars.get('ARCH')
21+
22+
23+
def is_in_stage2_file(abcfg_path: str) -> bool:
24+
vars = _parse_abcfg(abcfg_path)
25+
stage2_val: Optional[str] = vars.get('ABSTAGE2')
26+
return stage2_val == '1'
1827

1928

2029
def is_in_stage2_env() -> bool:

acbs/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Dict, List, Optional, Sequence, Tuple, cast
1111

1212
from acbs import __version__
13+
from acbs.ab4cfg import get_arch_override
1314
from acbs.base import ACBSPackageInfo, ACBSSourceInfo
1415
from acbs.const import (
1516
ANSI_BROWN,
@@ -18,6 +19,7 @@
1819
ANSI_RED,
1920
ANSI_RST,
2021
ANSI_YELLOW,
22+
AUTOBUILD_CONF_DIR,
2123
)
2224
from acbs.crypto import check_hash_hashlib_inner
2325

@@ -104,7 +106,11 @@ def get_arch_name() -> Optional[str]:
104106
105107
:returns: architecture name
106108
"""
109+
abcfg_path = os.path.join(AUTOBUILD_CONF_DIR, 'ab4cfg.sh')
107110
try:
111+
arch_override = get_arch_override(abcfg_path)
112+
if arch_override:
113+
return arch_override
108114
output = subprocess.check_output(['dpkg', '--print-architecture'])
109115
return output.decode('utf-8').strip()
110116
except Exception:

0 commit comments

Comments
 (0)