sources/curl: remove export functionality
Since the `sources.SourcesServer` has been removed, nothing is using the export functionality anymore. Inputs are now used to make content in the store available to stages. Remove all the export logic from org.osbuild.curl.
This commit is contained in:
parent
aa19a1c4c0
commit
5c19360cbe
1 changed files with 14 additions and 46 deletions
|
|
@ -24,6 +24,8 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
SCHEMA = """
|
SCHEMA = """
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|
@ -214,57 +216,23 @@ def download(checksums, urls, cache):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def export(checksums, cache, output):
|
def main(urls: Dict, cache: str):
|
||||||
for checksum in checksums:
|
cache = os.path.join(cache, "org.osbuild.files")
|
||||||
try:
|
|
||||||
subprocess.run(
|
if not urls:
|
||||||
[
|
json.dump({}, sys.stdout)
|
||||||
"cp",
|
return 0
|
||||||
"--reflink=auto",
|
|
||||||
f"{cache}/{checksum}",
|
os.makedirs(cache, exist_ok=True)
|
||||||
f"{output}/{checksum}",
|
res = download(urls.keys(), urls, cache)
|
||||||
],
|
if res != 0:
|
||||||
check=True,
|
return res
|
||||||
)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
json.dump({"error": e.output}, sys.stdout)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
json.dump({}, sys.stdout)
|
json.dump({}, sys.stdout)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def main(urls, options, checksums, cache, output):
|
|
||||||
cache = os.path.join(cache, "org.osbuild.files")
|
|
||||||
download_only = not output
|
|
||||||
|
|
||||||
if not urls:
|
|
||||||
urls = options.get("urls", [])
|
|
||||||
|
|
||||||
if urls:
|
|
||||||
if not checksums and download_only:
|
|
||||||
checksums = [k for k, _ in urls.items()]
|
|
||||||
|
|
||||||
os.makedirs(cache, exist_ok=True)
|
|
||||||
res = download(checksums, urls, cache)
|
|
||||||
if res != 0:
|
|
||||||
return res
|
|
||||||
|
|
||||||
if download_only:
|
|
||||||
json.dump({}, sys.stdout)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
os.makedirs(output, exist_ok=True)
|
|
||||||
res = export(checksums, cache, output)
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = json.load(sys.stdin)
|
args = json.load(sys.stdin)
|
||||||
r = main(args["items"],
|
r = main(args["items"], args["cache"])
|
||||||
args["options"],
|
|
||||||
args["checksums"],
|
|
||||||
args["cache"],
|
|
||||||
args.get("output"))
|
|
||||||
sys.exit(r)
|
sys.exit(r)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue