From 989fc8d8d6e822d72b6d0b597f3fa601e0936675 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Aug 02 2020 12:26:53 +0000 Subject: Redo how IoT links work a bit Signed-off-by: Rick Elrod --- diff --git a/sites/getfedora.org/main.py b/sites/getfedora.org/main.py index f36aecd..e36f346 100644 --- a/sites/getfedora.org/main.py +++ b/sites/getfedora.org/main.py @@ -13,7 +13,6 @@ import yaml from util.link_checker import check_download_link, check_checksum_link from util.releases_json_checker import check_releases_json from util.iot_compose import iot_compose_links -from util.checksum_links import checksum_links_iot #FEDORA_LANGUAGES = { 'en' : 'English' , 'de': 'Deutsch'} @@ -145,29 +144,31 @@ app.jinja_loader = loader dl_links = set() checksum_links = set() +with open('release.yaml') as data: + r = yaml.safe_load(data) + @app.context_processor def inject_globalvars(): - r = {} - with open('release.yaml') as data: - r = yaml.safe_load(data) - iot_links = iot_compose_links(r['ga']['announcement_release_number']) - iot_checksum = checksum_links_iot(r['ga']['announcement_release_number']) def download_link(override, link): global dl_links if override != 'default': link = override dl_links.add(link) return link - def checksum_link(link): - global checksum_links - link = url_for('checksums.static', filename=link) - checksum_links.add(link) + + def checksum_link(link, local=True): + if local: + global checksum_links + link = url_for('checksums.static', filename=link) + checksum_links.add(link) + else: + global dl_links + dl_links.add(link) return link + return dict( - iot_links=iot_links, dl=download_link, checksum=checksum_link, - iot_checksum=iot_checksum, releaseinfo=r, lang_code=g.current_lang if hasattr(g, 'current_lang') else app.config['BABEL_DEFAULT_LOCALE'], languages=FEDORA_LANGUAGES, @@ -202,11 +203,13 @@ app.register_blueprint(checksums) # This is a more manual attempt at still having some automation. freeze_indexes = set() -def export_route(name, path, template=None): +def export_route(name, path, template=None, context={}): global freeze_indexes freeze_indexes.add(name) def r(): - return render_template(template or path.strip('/') + '/index.html') + return render_template( + template or path.strip('/') + '/index.html', + **context) r.__name__ = name app.route('/' + path, endpoint=name)(r) if freezing: @@ -226,7 +229,7 @@ if not freezing: export_route('index', '/') -# export_route(identifier +# export_route(function name, path) export_route('workstation', '/workstation/') export_route('workstation_download', '/workstation/download/') export_route('server', '/server/') @@ -236,10 +239,17 @@ export_route('coreos_download', '/coreos/download/') export_route('silverblue', '/silverblue/') export_route('silverblue_download', '/silverblue/download/') export_route('iot', '/iot/') -export_route('iot_download', '/iot/download/') -export_route('security', '/security/') + +# Handle this route specially because of how it does links, but still use +# export_route so i18n magic works. +iot_links = iot_compose_links(r['ga']['editions']['iot']['release_number']) +export_route('iot_download', '/iot/download/', context={'iot_links': iot_links}) +iot_checksums = iot_links['checksums'] +export_route('security', '/security/', context={'iot_checksums': iot_checksums}) export_route('sponsors', '/sponsors/') + + # This is manually updated for now by calling: # python scripts/releases-json.py > static/releases.json @app.route('/releases.json') diff --git a/sites/getfedora.org/release.yaml b/sites/getfedora.org/release.yaml index 7a95702..fd89336 100644 --- a/sites/getfedora.org/release.yaml +++ b/sites/getfedora.org/release.yaml @@ -30,6 +30,9 @@ ga: netinst_aarch64: default raw_aarch64: default + iot: + pretty_name: Fedora IoT + release_number: 32 beta: # Should we show the beta stuff at all? diff --git a/sites/getfedora.org/site/iot/download/index.html b/sites/getfedora.org/site/iot/download/index.html index 075e673..a3937b6 100644 --- a/sites/getfedora.org/site/iot/download/index.html +++ b/sites/getfedora.org/site/iot/download/index.html @@ -9,7 +9,7 @@
-

Download Fedora IoT.

+

{% trans trimmed %}Download Fedora IoT.{% endtrans %}

{% trans trimmed %}Download the latest version of Fedora IoT Edition for your architecture here.{% endtrans %}
@@ -19,17 +19,17 @@
-

Raw Images :

  +

Raw Images:

 
    {% for key, value in iot_links['type']['raw-xz'].items() %}
  • - {% trans trimmed n=releaseinfo.ga.announcement_release_number %} + {% trans trimmed n=releaseinfo.ga.editions.iot.release_number %} Fedora {{n}}: Raw Image for {{key}} {% endtrans %}
    @@ -39,17 +39,17 @@

    Latest release: {{iot_links['date']}}

-

Installer ISOs :

  +

Installer ISOs:

 
    {% for key, value in iot_links['type']['dvd-ostree'].items() %}
  • - {% trans trimmed n=releaseinfo.ga.announcement_release_number %} + {% trans trimmed n=releaseinfo.ga.editions.iot.release_number %} Fedora {{n}}: Installer ISO for {{key}} {% endtrans %}
    @@ -62,4 +62,4 @@
{{export_regulations()}} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/sites/getfedora.org/site/security/index.html b/sites/getfedora.org/site/security/index.html index d8b0162..c472ded 100644 --- a/sites/getfedora.org/site/security/index.html +++ b/sites/getfedora.org/site/security/index.html @@ -56,7 +56,7 @@
- {% for edition in releaseinfo.ga.editions %} + {% for edition, data in releaseinfo.ga.editions.items() if data.get('checksum_arches', []) %}
{{releaseinfo.ga.editions[edition].pretty_name}}
    {% for arch in releaseinfo.ga.editions[edition].checksum_arches %} @@ -83,13 +83,13 @@
    Fedora IoT
      - {% for arch, value in iot_checksum.items() %} + {% for arch, value in iot_checksums.items() %}
    • - For {{arch}} : + For {{arch}}: diff --git a/sites/getfedora.org/util/checksum_links.py b/sites/getfedora.org/util/checksum_links.py deleted file mode 100644 index e7ee0c0..0000000 --- a/sites/getfedora.org/util/checksum_links.py +++ /dev/null @@ -1,15 +0,0 @@ -import requests -import sys - -def checksum_links_iot(version): - BASEURL = 'https://dl.fedoraproject.org/pub/alt/iot/' + str(version) + '/' - json = requests.get(BASEURL + '/metadata/images.json').json() - date = json['payload']['compose']['date'] - links = {} - - for arch,lst in json['payload']['images']['IoT'].items(): - links[arch] = {} - links[arch]['ISO'] = 'https://dl.fedoraproject.org/pub/alt/iot/' + str(version) + '/IoT/' + arch + '/iso/Fedora-IoT-IoT-' + str(version) + '-' + arch + '-' + date + '.0-CHECKSUM' - if(arch!= 'armhfp'): - links[arch]['Raw Image'] = 'https://dl.fedoraproject.org/pub/alt/iot/' + str(version) + '/IoT/' + arch + '/images/Fedora-IoT-IoT-' + str(version) + '-' + arch + '-' + date + '.0-CHECKSUM' - return links \ No newline at end of file diff --git a/sites/getfedora.org/util/iot_compose.py b/sites/getfedora.org/util/iot_compose.py index bff4109..7212072 100644 --- a/sites/getfedora.org/util/iot_compose.py +++ b/sites/getfedora.org/util/iot_compose.py @@ -1,17 +1,40 @@ import requests -import sys + +def _iot_checksum_link(media_format, arch, date, version): + path = u'iso' + if media_format == u'raw.xz': + path = u'images' + + url = u'https://dl.fedoraproject.org/pub/alt/iot/{0}/IoT/{1}/{2}/' \ + 'Fedora-IoT-IoT-{3}-{4}-{5}.0-CHECKSUM'.format( + version, + arch, + path, + version, + arch, + date) + return url def iot_compose_links(version): - BASEURL = 'https://dl.fedoraproject.org/pub/alt/iot/' + str(version) + '/' - json = requests.get(BASEURL + '/metadata/images.json').json() - date = json['payload']['compose']['date'] - links = {} - links['date'] = date[0:4] + '-' + date[4:6] + '-' + date[6:8] - links['type'] = {} + BASEURL = 'https://dl.fedoraproject.org/pub/alt/iot/' + str(version) + '/' + json = requests.get(BASEURL + '/metadata/images.json').json() + date = json['payload']['compose']['date'] + links = {} + links['date'] = date[0:4] + '-' + date[4:6] + '-' + date[6:8] + links['type'] = {} + links['checksums'] = {} - for arch,lst in json['payload']['images']['IoT'].items(): - for img in lst: - if img['type'] not in links['type'].keys(): - links['type'][img['type']] = {} - links['type'][img['type']][img['arch']] = BASEURL + img['path'] - return links \ No newline at end of file + for arch, lst in json['payload']['images']['IoT'].items(): + links['checksums'][arch] = {} + for img in lst: + if img['arch'] == 'src': + continue + if img['type'] not in links['type'].keys(): + links['type'][img['type']] = {} + links['type'][img['type']][img['arch']] = BASEURL + img['path'] + links['checksums'][arch][img['format']] = _iot_checksum_link( + img['format'], + img['arch'], + date, + version) + return links