Skip to content
Snippets Groups Projects
Unverified Commit 12974582 authored by Nico's avatar Nico
Browse files

add support for experimental builds

parent afe1dbf9
No related branches found
No related tags found
No related merge requests found
...@@ -8,4 +8,4 @@ PIPELINE_ID_FILE="/home/www/html/firmware/gluon/.last-downloaded-pipeline-id" ...@@ -8,4 +8,4 @@ PIPELINE_ID_FILE="/home/www/html/firmware/gluon/.last-downloaded-pipeline-id"
MYDIR=$(readlink -f $(dirname "$0")) MYDIR=$(readlink -f $(dirname "$0"))
cd "$ARCHIVE_DIR" cd "$ARCHIVE_DIR"
"$MYDIR/download-latest-firmware-build.py" --pipeline-id-file "$PIPELINE_ID_FILE" --create-symlink "$EXPERIMENTAL_LINK" "$MYDIR/download-latest-firmware-build.py" --pipeline-id-file "$PIPELINE_ID_FILE" --create-symlink "$EXPERIMENTAL_LINK" --branch experimental
...@@ -21,18 +21,19 @@ ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, down ...@@ -21,18 +21,19 @@ ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, down
ap.add_argument("--pipeline-id-file", help="Store downloaded Pipeline ID in this file and only download if latest pipeline ID doesn't match file contents") ap.add_argument("--pipeline-id-file", help="Store downloaded Pipeline ID in this file and only download if latest pipeline ID doesn't match file contents")
ap.add_argument("--create-symlink", help="Create symlink to downloaded firmware at the specified path") ap.add_argument("--create-symlink", help="Create symlink to downloaded firmware at the specified path")
ap.add_argument("--debug", action="store_true", help="Produce lots of debug output") ap.add_argument("--debug", action="store_true", help="Produce lots of debug output")
ap.add_argument("--branch", help="Download only builds of this branch")
args = ap.parse_args() args = ap.parse_args()
def find_version_from_archive(archive_file_list): def find_version_from_archive(archive_file_list):
for file in archive_file_list: for file in archive_file_list:
if file.filename.startswith("gluon/output/images"): if file.filename.startswith("gluon/output/images"):
filename = os.path.basename(file.filename) filename = os.path.basename(file.filename)
version_regex = re.compile(r'gluon-ffs-(([0-9]+\.[0-9]+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+-)') version_regex = re.compile(r'gluon-ffs-(((experimental|[0-9]+\.[0-9])+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+-)')
version_matches = version_regex.match(filename) version_matches = version_regex.match(filename)
if version_matches: if version_matches:
logging.debug("Found version number {}".format(version_matches.group(2))) logging.debug("Found version number {}".format(version_matches.group(2)))
return version_matches.group(2) return version_matches.group(2)
return None raise ValueError("Could not determine version from ZIP file")
def extract_zip(artifact_zipfile): def extract_zip(artifact_zipfile):
logging.debug("Extracting ZIP from FD {}".format(artifact_zipfile)) logging.debug("Extracting ZIP from FD {}".format(artifact_zipfile))
...@@ -47,14 +48,14 @@ def extract_zip(artifact_zipfile): ...@@ -47,14 +48,14 @@ def extract_zip(artifact_zipfile):
os.rename(outputdir, version) os.rename(outputdir, version)
return version return version
def find_latest_pipeline_id(): def find_latest_pipeline_id(branch):
logging.debug("Finding pipeline ID") logging.debug("Finding pipeline ID")
pipelines_request = requests.get("{}/projects/{}/pipelines".format(GITLAB_API_BASE, PROJECT_ID)) pipelines_request = requests.get("{}/projects/{}/pipelines".format(GITLAB_API_BASE, PROJECT_ID))
pipelines_request.raise_for_status() pipelines_request.raise_for_status()
pipelines = pipelines_request.json() pipelines = pipelines_request.json()
for pipeline in pipelines: for pipeline in pipelines:
if pipeline["status"] == "success" and pipeline["ref"].startswith("v"): if pipeline["status"] == "success" and pipeline["ref"].startswith(branch):
logging.debug("Found Pipeline ID: {}".format(pipeline["id"])) logging.debug("Found Pipeline ID: {}".format(pipeline["id"]))
return pipeline["id"] return pipeline["id"]
return None return None
...@@ -63,7 +64,7 @@ if args.debug: ...@@ -63,7 +64,7 @@ if args.debug:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
if args.pipeline_id is None: if args.pipeline_id is None:
pipeline_id = int(find_latest_pipeline_id()) pipeline_id = int(find_latest_pipeline_id(args.branch))
if args.pipeline_id_file: if args.pipeline_id_file:
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment