Skip to content

Commit 6c232bd

Browse files
committed
asu: allow the usage of branches.yml
It's easier to write and understand. It's now possible to define a file called `branches.yml` containing whatever branch information you'd like. It's loaded from the config option BRANCHES_PATH if defined, if not the internal branches.yml file is used. To stay compatible with existing setups changes only happen if BRANCHES wasn't previously defined, like it would be the case if still added in the config.py Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent 1f5172f commit 6c232bd

File tree

5 files changed

+79
-61
lines changed

5 files changed

+79
-61
lines changed

asu/asu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
import connexion
55
from flask import Flask, render_template, send_from_directory
6+
from pkg_resources import resource_filename
67
from prometheus_client import CollectorRegistry, make_wsgi_app
78
from redis import Redis
89
from werkzeug.middleware.dispatcher import DispatcherMiddleware
10+
from yaml import safe_load
911

1012
import asu.common
1113
from asu import __version__
@@ -34,7 +36,6 @@ def create_app(test_config: dict = None) -> Flask:
3436
TESTING=False,
3537
DEBUG=False,
3638
UPSTREAM_URL="https://downloads.openwrt.org",
37-
BRANCHES={},
3839
ALLOW_DEFAULTS=False,
3940
ASYNC_QUEUE=True,
4041
)

asu/branches.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
branches:
2+
'21.02':
3+
enabled: true
4+
extra_keys: []
5+
extra_repos: {}
6+
git_branch: openwrt-21.02
7+
name: '21.02'
8+
path: releases/{version}
9+
path_packages: releases/packages-{branch}
10+
pubkey: RWQviwuY4IMGvwLfs6842A0m4EZU1IjczTxKMSk3BQP8DAQLHBwdQiaU
11+
release_date: '2021-08-04'
12+
repos:
13+
- base
14+
- packages
15+
- luci
16+
- routing
17+
- telephony
18+
snapshot: false
19+
updates: features
20+
versions:
21+
- 21.02.3
22+
- 21.02-SNAPSHOT
23+
24+
'22.03':
25+
enabled: true
26+
extra_keys: []
27+
extra_repos: {}
28+
git_branch: openwrt-22.03
29+
name: '22.03'
30+
path: releases/{version}
31+
path_packages: releases/packages-{branch}
32+
pubkey: RWRNAX5vHtXWFmt+n5di7XX8rTu0w+c8X7Ihv4oCyD6tzsUwmH0A6kO0
33+
release_date: '2022-09-06'
34+
repos:
35+
- base
36+
- packages
37+
- luci
38+
- routing
39+
- telephony
40+
snapshot: false
41+
updates: features
42+
versions:
43+
- 22.03.0
44+
- 22.03.0-rc6
45+
- 22.03-SNAPSHOT
46+
package_changes:
47+
kmod-nft-nat6:
48+
firewall: firewall4
49+
50+
SNAPSHOT:
51+
enabled: true
52+
extra_keys: []
53+
extra_repos: {}
54+
git_branch: master
55+
name: SNAPSHOT
56+
path: snapshots
57+
path_packages: snapshots/packages
58+
pubkey: RWS1BD5w+adc3j2Hqg9+b66CvLR7NlHbsj7wjNVj0XGt/othDgIAOJS+
59+
repos:
60+
- base
61+
- packages
62+
- luci
63+
- routing
64+
- telephony
65+
snapshot: true
66+
updates: dev
67+
versions:
68+
- SNAPSHOT
69+
package_changes:
70+
kmod-nft-nat6:
71+
firewall: firewall4

asu/build.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
import requests
1010
from rq import get_current_job
1111

12-
from .common import (
13-
fingerprint_pubkey_usign,
14-
get_file_hash,
15-
get_packages_hash,
16-
verify_usign,
17-
)
12+
from .common import (fingerprint_pubkey_usign, get_file_hash,
13+
get_packages_hash, verify_usign)
1814

1915
log = logging.getLogger("rq.worker")
2016
log.setLevel(logging.DEBUG)
@@ -399,7 +395,9 @@ def download_file(filename: str, dest: str = None):
399395
if (cache / target_subtarget).exists():
400396
rmtree(cache / target_subtarget)
401397
for suffix in [".stamp", ".sha256sums", ".sha256sums.sig"]:
402-
(cache / target_subtarget).with_suffix(suffix).unlink(missing_ok=True)
398+
(cache / target_subtarget).with_suffix(suffix).unlink(
399+
missing_ok=True
400+
)
403401
else:
404402
log.debug("Keeping ImageBuilder for %s", target_subtarget)
405403

misc/config.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,3 @@
1717
JSON_PATH = Path.cwd() / "public/json/v1/"
1818

1919
MAPPING_ABI = {"libubus20191227": "libubus"}
20-
21-
# supported versions
22-
BRANCHES = {
23-
"SNAPSHOT": {
24-
"name": "SNAPSHOT",
25-
"updates": "dev",
26-
"enabled": True,
27-
"snapshot": True,
28-
"versions": ["SNAPSHOT"],
29-
"git_branch": "master",
30-
"path": "snapshots",
31-
"path_packages": "snapshots/packages",
32-
"pubkey": "RWS1BD5w+adc3j2Hqg9+b66CvLR7NlHbsj7wjNVj0XGt/othDgIAOJS+",
33-
"repos": ["base", "packages", "luci", "routing", "telephony"],
34-
"extra_repos": {},
35-
"extra_keys": [],
36-
},
37-
"21.02": {
38-
"name": "21.02",
39-
"updates": "features",
40-
"release_date": "2021-08-04",
41-
"enabled": True,
42-
"snapshot": False,
43-
"versions": [
44-
"21.02.0",
45-
"21.02-SNAPSHOT",
46-
],
47-
"git_branch": "openwrt-21.02",
48-
"path": "releases/{version}",
49-
"path_packages": "releases/packages-{branch}",
50-
"pubkey": "RWQviwuY4IMGvwLfs6842A0m4EZU1IjczTxKMSk3BQP8DAQLHBwdQiaU",
51-
"repos": ["base", "packages", "luci", "routing", "telephony"],
52-
"extra_repos": {},
53-
"extra_keys": [],
54-
},
55-
"19.07": {
56-
"name": "19.07",
57-
"updates": "security",
58-
"release_date": "2021-08-07",
59-
"enabled": False,
60-
"versions": [
61-
"19.07.8",
62-
"19.07-SNAPSHOT",
63-
],
64-
"git_branch": "openwrt-19.07",
65-
"path": "releases/{version}",
66-
"path_packages": "releases/packages-{branch}",
67-
"pubkey": "RWT5S53W/rrJY9BiIod3JF04AZ/eU1xDpVOb+rjZzAQBEcoETGx8BXEK",
68-
"repos": ["base", "packages", "luci", "routing", "telephony"],
69-
"extra_repos": {},
70-
"extra_keys": [],
71-
},
72-
}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "An image on demand server for OpenWrt based distributions"
55
authors = ["Paul Spooren <mail@aparcar.org>"]
66
license = "GPL-2.0"
77
readme = "README.md"
8+
include = ["asu/branches.yml"]
89

910
[tool.poetry.dependencies]
1011
python = "^3.7"

0 commit comments

Comments
 (0)