-
Jonas Höppner authored
Don't rename the release artifacts, just copy to a versioned folder. The list of files to copy is taken from variables set in yocto DISTRO_ARTIFACTS and DISTRO_IMAGES. Images are linked, all other files are copied. BCS 746-000273
c18d32a5
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
package_release.py 2.00 KiB
#!/usr/bin/env python3
import argparse
import glob
import json
import os
import sys
import shutil
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--images-dir",
help="""Yocto images directory""",
dest="images_dir",
required=True,
)
parser.add_argument(
"--release-dir",
help="""release directory""",
dest="release_dir",
required=True,
)
args, _ = parser.parse_known_args()
# Get bitbake variables from testdata.json file
testdata_files = glob.glob(args.images_dir + "/*.testdata.json")
if not testdata_files:
sys.exit("ERROR: no *.testdata.json file found in images directory")
with open(testdata_files[0], "r") as f:
buildvars = json.load(f)
machine = buildvars["MACHINE"]
version = buildvars["DISTRO_VERSION"]
artifacts_image = buildvars["DISTRO_IMAGES"].split()
artifacts_all = buildvars["DISTRO_RELEASE_ARTEFACTS"].split()
# Set directories (use relative path)
release_name = "GUF-Yocto-%s" % version
output_dir = "%s/%s/%s" % (args.release_dir, release_name, machine)
images_dir_relative = os.path.relpath(args.images_dir, output_dir)
# Create output directory
os.makedirs(output_dir, exist_ok=True)
# Create symlinks for all images (to reduce size and network load)
for artifact in artifacts_image:
source_file = "%s/%s" % (images_dir_relative, artifact)
target_file = "%s/%s" % (output_dir, artifact)
print("Create link: %s -> %s" % (target_file, source_file))
os.symlink(source_file, target_file)
# Copy all other artifacts
for artifact in artifacts_all:
if artifact in artifacts_image:
continue
source_file = "%s/%s" % (args.images_dir, artifact)
target_file = "%s/%s" % (output_dir, artifact)
print("Copy: %s -> %s" % (target_file, source_file))
shutil.copyfile(source_file, target_file, follow_symlinks=True)
if __name__ == "__main__":
main()