Skip to content

Commit 05dd668

Browse files
Merge pull request #8 from RandomCoderOrg/anchror-lil-fixes
Anchror lil fixes
2 parents 03b0811 + f6e291a commit 05dd668

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

gen_data/gen-update-json.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@
55
import arch
66

77
GIT_ROOT = os.popen("git rev-parse --show-toplevel").read().strip()
8-
DIR = "fs-cook/out"
8+
DIR = "."
99
VERBOSE = False
1010
JSON_CONF = f"{GIT_ROOT}/distro-data.json"
1111

1212
def update_json_conf(file) -> None:
1313
data = strip_info(file)
1414
jdata = json.load(open(JSON_CONF, 'r'))
1515

16+
# resolv data
17+
jdata = utils.resolv_data(jdata, data[0], data[1], [data[2]])
18+
1619
# update url
17-
jdata[data[0]][data[1]][f"{data[2]}url"] = get_release_url(
18-
RELEASE_TAG, data[3])
20+
jdata[data[0]] \
21+
[data[1]] \
22+
[f"{data[2]}url"] = get_release_url(RELEASE_TAG, data[3])
1923

2024
# update sha
21-
jdata[data[0]][data[1]][f"{data[2]}sha"] = os.popen(
22-
f"sha256sum {DIR}/{data[3]}").read().split()[0]
25+
jdata[data[0]] \
26+
[data[1]] \
27+
[f"{data[2]}sha"] = os.popen(f"sha256sum {file}").read().split()[0]
2328

2429
# update JSON_CONF
2530
file = open(JSON_CONF, 'w')
@@ -31,7 +36,7 @@ def strip_info(file):
3136
name = os.path.splitext(name)[0]
3237

3338
sp = name.split("-")
34-
StoPdict = arch.translate()
39+
StoPdict = arch.translated_arch()
3540

3641
suite = sp[0]
3742
variant = sp[1]
@@ -40,8 +45,8 @@ def strip_info(file):
4045
return [suite, variant, packageArchitecture, basename]
4146

4247
def get_release_url(release_tag, file) -> str:
43-
repo="https://github.com/RandomCoderOrg/udroid-download"
44-
url="{}/releases/download/{}/{}".format(repo, release_tag, file)
48+
repo ="https://github.com/RandomCoderOrg/udroid-download"
49+
url ="{}/releases/download/{}/{}".format(repo, release_tag, file)
4550
return url
4651

4752
if __name__ == '__main__':
@@ -54,8 +59,10 @@ def get_release_url(release_tag, file) -> str:
5459
options, args = parser.parse_args()
5560
# get release tag
5661

62+
from utils import getfilesR
63+
5764
RELEASE_TAG = options.release_tag
58-
for file in os.listdir(DIR):
65+
for file in getfilesR(DIR):
5966
if file.endswith(".tar.gz"):
6067
update_json_conf(file)
6168

gen_data/utils.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import json
2-
import arch as archAlt
3-
archAltName = archAlt.ReverseTranslate()
1+
import os
42

53
def add_suite(JsonFile: dict, suite: str) -> None:
64
""" Add suite to the JsonFile
@@ -37,6 +35,9 @@ def add_arch(JsonFile: dict, suite: str, varient: str, arch:list[str]) -> None:
3735
arch (list[str]): The arch to add
3836
"""
3937

38+
import arch as archAlt
39+
archAltName = archAlt.ReverseTranslate()
40+
4041
#revArchLst = {'armhf': ['armhf', 'arm'], 'aarch64': ['arm64', 'aarch64'], 'amd64': ['amd64', 'x86_64']}
4142
revArchLst = archAltName[arch]
4243
for revArch in revArchLst:
@@ -53,14 +54,31 @@ def resolv_data(
5354
Name: str = ...,
5455
FriendlyName: str = ...,
5556
) -> dict:
57+
58+
if Name is ...:
59+
Name = f"{suite}-{variant}"
60+
61+
if FriendlyName is ...:
62+
FriendlyName = f"{suite} {variant}"
63+
5664
if suite not in json_data["suites"]:
5765
add_suite(json_data,suite)
5866

5967
if variant not in json_data[suite]["varients"]:
6068
add_varient(json_data, suite, variant, Name, FriendlyName)
6169

6270
for arc in arch:
63-
if arch not in json_data[suite][variant]["arch"]:
71+
if arc not in json_data[suite][variant]["arch"]:
6472
add_arch(json_data, suite, variant, arc)
6573

66-
return json_data
74+
return json_data
75+
76+
def getfilesR(path: str) -> list:
77+
78+
files = []
79+
# include depth
80+
for r, d, f in os.walk(path):
81+
for file in f:
82+
files.append(os.path.join(r, file))
83+
84+
return files

0 commit comments

Comments
 (0)