Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • seco-ne/yocto/infrastructure/gitlab-ci
1 result
Show changes
Commits on Source (5)
/__pycache__
/__pycache__
.idea/
......@@ -8,6 +8,7 @@ import shutil
import hashlib
import tempfile
import alphaplan_fwr
from datetime import datetime
def md5(fname):
......@@ -72,6 +73,84 @@ def copy_files(files, input_dir, subdir, output_dir, outlocal_dir):
return md5sums
def generate_metadata(
machine,
version,
artifacts_image,
sdk,
output_dir,
outlocal_dir,
):
"""Generates a metainfo.json for the release"""
install_script = None
licenses = None
image_general = None
image_wic = None
# Join filepath for metadata
if output_dir is not None:
filepath = os.path.join(output_dir, machine, "metainfo.json")
elif outlocal_dir is not None:
filepath = os.path.join(outlocal_dir, machine, "metainfo.json")
else:
print("Error: Filepath is empty")
return -1
# Collect metadata and write to metainfo.json
for artifact in artifacts_image:
if artifact == "fng-install.sh":
install_script = artifact
elif artifact == "license.manifest":
licenses = artifact
elif artifact.endswith(machine + ".tar.gz"):
image_general = artifact
elif artifact.endswith(machine + ".wic"):
image_wic = artifact
metadata = dict()
metadata["files"] = []
metadata["version"] = version
metadata["machine"] = machine
metadata["date"] = datetime.today().strftime("%Y-%m-%d")
if install_script is not None:
new_file = dict()
new_file["name"] = "Install Script"
new_file["path"] = install_script
metadata["files"].append(new_file)
if image_general is not None:
new_file = dict()
new_file["name"] = "Image"
new_file["path"] = image_general
metadata["files"].append(new_file)
if image_wic is not None:
new_file = dict()
new_file["name"] = "SD-Card Image (WIC)"
new_file["path"] = image_wic
metadata["files"].append(new_file)
if sdk is not None:
new_file = dict()
new_file["name"] = "SDK"
new_file["path"] = "sdk/" + sdk + ".sh"
metadata["files"].append(new_file)
if licenses is not None:
new_file = dict()
new_file["name"] = "Licenses"
new_file["path"] = licenses
metadata["files"].append(new_file)
with open(filepath, "w", encoding="utf-8") as file:
file.write(json.dumps(metadata))
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
......@@ -79,6 +158,11 @@ def main():
help="""Yocto images directory""",
dest="images_dir",
)
parser.add_argument(
"--licenses-dir",
help="""Yocto licenses directory""",
dest="licenses_dir",
)
parser.add_argument(
"--outputdir-upload",
help="""Base directory name for uploaded artifacts""",
......@@ -177,6 +261,27 @@ def main():
artifacts_all, args.images_dir, machine, output_dir, outlocal_dir
)
# If the path for the licenses is set, we check for the list with all
# licenses. If the list is found, we copy it to the output directory
# and also add it to the artifacts dictionary.
if args.licenses_dir is not None and os.path.isdir(args.licenses_dir):
manifest = glob.glob(
os.path.join(args.licenses_dir, "**", "license.manifest")
)
if manifest:
md5sums.update(
copy_files(
["license.manifest"],
os.path.dirname(manifest[0]),
machine,
output_dir,
outlocal_dir,
)
)
artifacts_all.append("license.manifest")
# Generate alphaplan FWR articles
if args.generate_fwr_articles:
alphaplan_fwr.generate_fwr_articles(
......@@ -188,6 +293,16 @@ def main():
md5sums,
)
# Generate metadata
generate_metadata(
machine,
version,
artifacts_all,
sdkname,
output_dir,
outlocal_dir,
)
# Handle SDK if available
if args.sdk_dir is not None:
sdkfiles = glob.glob(os.path.join(args.sdk_dir, sdkname + "*"))
......