Skip to content
Snippets Groups Projects
Commit 68f1959f authored by Felix Gerking's avatar Felix Gerking
Browse files

package_release:manifest-CI: split alphaplan FWR generation and package_release

The alphaplan FWR generation is now separated to make the manifest gitlab-ci
file more easy to understand and reduce the complexity of the
package_release file.

BCS 746-000637
parent 5c3ac7a2
No related branches found
No related tags found
1 merge request!120package_release:manifest-CI: split alphaplan FWR generation and package_release
#!/usr/bin/env python3
import argparse
import json
import os
import shutil
import sys
import requests
import glob
from alphaplan_keys import ApKeys, ApSubKeys, get_ap_dict
def ap_send_json(jsonobj):
print("##### Currently in debug mode: No data is send to AlphaPlan webservice")
return
"""Sends the generated files to the Alphaplan webservice"""
url = os.environ.get("AP_WEBSERVICE_URL")
usr = os.environ.get("AP_WEBSERVICE_USR")
......@@ -263,3 +267,79 @@ def generate_fwr_articles(
shutil.copyfile(jsonfile_local, jsonfile_output, follow_symlinks=True)
# Send data object to AlphaPlan webservice
ap_send_json(data)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--images-dir",
help="""Yocto images directory""",
dest="images_dir",
)
parser.add_argument(
"--outputdir-upload",
help="""Base directory name for uploaded artifacts""",
dest="outputdir_upload",
)
parser.add_argument(
"--outputdir-local",
help="""Base directory for locally deployed artifacts, should contain absolut path.""",
dest="outputdir_local",
)
args, _ = parser.parse_known_args()
if args.outputdir_upload is None or args.outputdir_local is None:
sys.exit(
"ERROR: outputdir-local and outputdir-upload needs to be specified."
)
# Get bitbake variables from testdata.json file
testdata_files = []
if args.images_dir is not None:
testdata_files += glob.glob(os.path.join(args.images_dir, "*.testdata.json"))
with open(testdata_files[0], "r", encoding="utf-8") as f:
buildvars = json.load(f)
machine = buildvars["MACHINE"]
version = buildvars["DISTRO_VERSION"]
artifacts_all = buildvars["DISTRO_RELEASE_ARTEFACTS"].split()
artifacts_all.append("BUILD_SRCREVS.log")
if version.startswith("fngsystem"):
release_name_local = version.replace("fngsystem", "FNGSystem")
release_name = release_name_local
else:
release_name = "GUF-Yocto-%s" % version
release_name_local = "Yocto-%s" % version
output_dir = os.path.join(args.outputdir_upload, release_name)
outlocal_dir = os.path.join(args.outputdir_local, release_name_local)
if not os.path.isdir(outlocal_dir):
sys.exit("ERROR: ouputdir-local does not exist")
if not os.path.isdir(output_dir):
sys.exit("ERROR: ouputdir-upload does not exist")
# Get md5sums.txt
md5sums_file = os.path.join(output_dir, machine, "md5sums.txt")
md5sums = {}
with open(md5sums_file) as f:
for line in f:
# Assuming line format: "<md5sum> <filename>\n"
name = line.split(" ")[1].rstrip()
sum = line.split(" ")[0]
md5sums[name] = sum
# Generate alphaplan FWR articles
generate_fwr_articles(
output_dir,
outlocal_dir,
machine,
release_name_local,
artifacts_all,
md5sums,
)
if __name__ == "__main__":
main()
......@@ -130,12 +130,6 @@ variables:
outdir="${OUTDIR_BASE}-fngsystem/CI_Builds"
fi
# Generate AlphaPlan FWR articles if release tag is set
if [ -n "$CI_COMMIT_TAG" ] && \
[[ "${CI_PARAM_PACKAGE_FTP}" == "false" ]];then
UPLOAD_PARAM="${UPLOAD_PARAM} --generate-fwr-articles"
fi
script=".gitlab-ci/package_release.py"
[ ! -x "$script" ] && script=".repo/manifests/$script"
[ ! -x "$script" ] && echo "Failed to find package_release script"
......@@ -156,6 +150,25 @@ variables:
--outputdir-local="${outdir}"
fi
# Generate AlphaPlan FWR articles if release tag is set
apscript=".gitlab-ci/alphaplan_fwr.py"
#if [ -n "$CI_COMMIT_TAG" ] && \
echo "CI AP debug mode"
if true && \
[ -d "${ARTIFACTS_IMAGE_PATH}" ] && \
[[ "${CI_PARAM_PACKAGE_FTP}" == "false" ]];then
# Check if alphaplan fwr script is available
[ ! -x "${apscript}" ] && \
echo "Failed to find alphaplan_fwr script" && \
exit 1
# Call script
${apscript} \
--images-dir="${ARTIFACTS_IMAGE_PATH}" \
--outputdir-local=${outdir} \
--outputdir-upload=release
fi
.prepare_test:
before_script:
- *setup_ssh
......
......@@ -7,7 +7,6 @@ import sys
import shutil
import hashlib
import tempfile
import alphaplan_fwr
from datetime import datetime
from convert_md2html import convertmd2html
......@@ -185,13 +184,6 @@ def main():
help="""Documentation directory""",
dest="doc_dir",
)
parser.add_argument(
"--generate-fwr-articles",
help="""Enable AlphaPlan FWR generation""",
dest="generate_fwr_articles",
action="store_true",
)
parser.set_defaults(generate_fwr_articles=False)
args, _ = parser.parse_known_args()
if args.outputdir_upload is None and args.outputdir_local is None:
......@@ -290,17 +282,6 @@ def main():
artifacts_all.append("license.manifest")
# Generate alphaplan FWR articles
if args.generate_fwr_articles:
alphaplan_fwr.generate_fwr_articles(
output_dir,
outlocal_dir,
machine,
release_name_local,
artifacts_all,
md5sums,
)
# Generate metadata
if args.sdk_dir is None:
generate_metadata(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment