# else, find the latest sub-directory
sub_dir = ''
snapshot_dir = ''
- if build['version_minor']:
+ try:
sub_dir = '0.' + build['version_major'] + '.' + \
build['version_minor'] + '-SNAPSHOT/'
snapshot_dir = parent_dir + sub_dir
- else:
+ except KeyError:
subdir_url = urlopen(parent_dir)
content = subdir_url.read().decode('utf-8')
all_dirs = BeautifulSoup(content, 'html.parser')
# When run as a script, accept a set of builds and execute them
if __name__ == "__main__":
- # Load RPM build variables from a YAML config file
- build_vars_path = os.path.join(project_root, "build_vars.yaml")
- with open(build_vars_path) as rpm_var_file:
- build_vars = yaml.load(rpm_var_file)
-
# Accept the version(s) of the build(s) to perform as args
# TODO: More docs on ArgParser and argument
parser = argparse.ArgumentParser(conflict_handler='resolve')
- existing_build_group = parser.add_argument_group("Existing build")
- existing_build_group.add_argument(
- "-v", "--version", action="append", metavar="major minor patch rpm",
- nargs="*", help="RPM version(s) to build"
- )
new_build_group = parser.add_argument_group("New build")
new_build_group.add_argument(
# Parse the given args
args = parser.parse_args()
- # Build list of RPM builds to perform
- builds = []
-
+ # A dictionary containing essential build variables
+ build = {}
# Check if `changelog_date` has been passed as an arg
# The current datetime should be the default date for RPM changelog date
# but can still accept optional `changelog_date` param
if not args.sysd_commit:
args.sysd_commit = get_sysd_commit()
- if args.version:
- # Build a list of requested versions as dicts of version components
- versions = []
- version_keys = ["version_major", "version_minor", "version_patch",
- "rpm_release"]
- # For each version arg, match all version components to build_vars name
- for version in args.version:
- versions.append(dict(zip(version_keys, version)))
-
- # Find every RPM build that matches version arguments given to the
- # version information extracted from download_url. Any version
- # components that aren't passed are simply not checked, so they can't
- # fail the match, effectively wild-carding them.
- for build in build_vars["builds"]:
- for version in versions:
- # Extract version information from the download_url
- version_info = extract_version(build['download_url'])
- # Converts both dicts' key:value pairs to lists of tuples and
- # checks that each tuple in the version list is present in the
- # version_info list. If the extracted version_info matches the
- # passed version arguments, update build dict.
- if all(item in version_info.items()
- for item in version.items()):
- build.update(version_info)
- builds.append(build)
- else:
- build = {}
- # Common parameters for all new and snapshot builds
- build.update({"sysd_commit": args.sysd_commit,
- "changelog_name": args.changelog_name,
- "changelog_email": args.changelog_email,
- "changelog_date": args.changelog_date,
- "version_major": args.major,
- "version_minor": args.minor,
- "download_url": args.download_url
- })
-
- # If download_url is given, update version info
- if args.download_url:
- version = extract_version(args.download_url)
- build.update(version)
-
- builds.append(build)
+ # If download_url is given, update version info
+ if args.download_url:
+ build.update({"download_url": args.download_url})
+ version = extract_version(args.download_url)
+ build.update(version)
+
+ # Common parameters for all new and snapshot builds
+ build.update({"sysd_commit": args.sysd_commit,
+ "changelog_name": args.changelog_name,
+ "changelog_email": args.changelog_email,
+ "changelog_date": args.changelog_date,
+ })
# If the flag `--build-latest-snap` is true, extract information
- # from the snapshot URL, else directly build the RPM
- for build in builds:
- if args.build_latest_snap:
+ # from the snapshot URL using major version and minor version(optional)
+ # info, else proceed directly to build the RPM
+ if args.build_latest_snap:
+ if args.major:
+ build.update({'version_major': args.major})
+ if args.minor:
+ build.update({'version_minor': args.minor})
build_snapshot_rpm(build)
- else:
- build_rpm(build)
+ else:
+ build_rpm(build)
+++ /dev/null
-##############################################################################
-# Copyright (c) 2016 Daniel Farrell and Others. All rights reserved.
-#
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0 which accompanies this distribution,
-# and is available at http://www.eclipse.org/legal/epl-v10.html
-##############################################################################
-
-# Variables that define OpenDaylight's RPM builds
-# Consumed by Python logic to render Jinja2 templates into RPM .spec files
-# Each build should define:
-# download_url:
-# URL to ODL tarball artifact to repackage into RPM
-# sysd_commit:
-# Version of ODL systemd unitfile to download and package in ODL RPM
-# changelog_date:
-# Date this RPM was defined
-# changelog_name:
-# Name of person who defined RPM
-# changelog_email:
-# Email of person who defined RPM
-
----
-builds:
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.3.3-Lithium-SR3/distribution-karaf-0.3.3-Lithium-SR3.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Mon Jan 25 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.4.0-Beryllium/distribution-karaf-0.4.0-Beryllium.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Fri Feb 19 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.3.4-Lithium-SR4/distribution-karaf-0.3.4-Lithium-SR4.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Fri Mar 11 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.4.1-Beryllium-SR1/distribution-karaf-0.4.1-Beryllium-SR1.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Wed Mar 23 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distribution-karaf/0.4.2-Beryllium-SR2/distribution-karaf-0.4.2-Beryllium-SR2.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Wed May 11 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.4.3-Beryllium-SR3/distribution-karaf-0.4.3-Beryllium-SR3.tar.gz"
- sysd_commit: c6d7ee1f21d62ff8ffb741c7a12c3d8d3aa3d6ed
- changelog_date: "Tue Aug 09 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.0-Boron/distribution-karaf-0.5.0-Boron.tar.gz"
- sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
- changelog_date: "Fri Oct 07 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.4.4-Beryllium-SR4/distribution-karaf-0.4.4-Beryllium-SR4.tar.gz"
- sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
- changelog_date: "Thu Oct 27 2016"
- changelog_name: "Daniel Farrell"
- changelog_email: "dfarrell@redhat.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.1-Boron-SR1/distribution-karaf-0.5.1-Boron-SR1.tar.gz"
- sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
- changelog_date: "Wed Nov 16 2016"
- changelog_name: "Michal Skalski"
- changelog_email: "mskalski@mirantis.com"
- - download_url: "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.5.2-Boron-SR2/distribution-karaf-0.5.2-Boron-SR2.tar.gz"
- sysd_commit: 07f7c83b0ef46ad3809e5be03e09a77fe554eeae
- changelog_date: "Wed 23 Dec 2016"
- changelog_name: "Romanos Skiadas"
- changelog_email: "rski@intracom-telecom.com"