3# Generate flatpak sources from URLs
5# Copyright (c) 2021 SIL International. MIT License.
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
14# The above copyright notice and this permission notice shall be included in all
15# copies or substantial portions of the Software.
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25# Output a flatpak yaml sources list from an input yaml file specifying files at
26# base URLs. Files will be downloaded (and cached) to compute their checksums.
27# Usage: compose-url-sources input.yml output.yml
28# Dependencies: xonsh wget
30# Input should be formatted like the following example:
32# baseurl: https://www.example.com/my-assembly/
36# - My.Assembly.dll.config
37# - name: Something else
38# baseurl: https://project.example.com/something-else/
39# dest: other-dependencies
43# output.yml will then specify to download the following files:
44# https://www.example.com/my-assembly/My.Assembly.dll
45# https://www.example.com/my-assembly/My.Assembly.dll.config
46# https://project.example.com/something-else/deps.tar.xz
47# https://project.example.com/something-else/icon.png
51$RAISE_SUBPROC_ERROR = True
54# $XONSH_TRACE_SUBPROC = True
56inputsPath = sys.argv[1]
57outputSourcesPath = sys.argv[2]
60if 'XDG_CACHE_HOME' in ${...}:
61 cacheHome = $XDG_CACHE_HOME
63 cacheHome = '{}/.cache'.format($HOME)
64cachePath = '{}/nuget-sources-flatpak'.format(cacheHome)
67def processInputSourcesList(path):
68 with open(path, 'r') as inputStream:
69 inputSources = yaml.safe_load(inputStream)
70 for source in inputSources:
71 print('Processing group {} ...'.format(source['name']))
72 for file in source['files']:
73 prepareSourceRecord(source['name'], source['baseurl'], source['dest'], file)
75def prepareSourceRecord(name, baseurl, dest, file):
76 url = '{}{}'.format(baseurl, file)
77 cacheOutputPath = '{}/{}'.format(cachePath, file)
78 wget @(url) -O @(cacheOutputPath)
79 pathToCachedFile = '{}/{}'.format(cachePath,file)
80 sha512 = $(sha512sum @(pathToCachedFile) | perl -p -e 's/ .*$//').rstrip()
88processInputSourcesList(inputsPath)
90with open(outputSourcesPath, 'w') as out:
91 yaml.dump(nugetSources, out)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list