Gary Wu | d04e440 | 2017-07-28 12:26:54 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import sys, csv, subprocess |
| 18 | |
| 19 | root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).rstrip() |
| 20 | url_template = "https://nexus.open-o.org/service/local/artifact/maven/redirect?r=releases&g={0}&a={1}&e={2}&c={3}&v=$VERSION" |
| 21 | |
| 22 | def parseRow(row): |
| 23 | service = row["service"] |
| 24 | filename = row["filename"] |
| 25 | groupId = row["groupId"] |
| 26 | artifactId = row["artifactId"] |
| 27 | extension = row["extension"] |
| 28 | classifier = row["classifier"] |
| 29 | url = url_template.format(groupId, artifactId, extension, classifier) |
| 30 | if classifier: |
| 31 | dest = "{}/{}-$VERSION.{}.{}".format(filename, filename, classifier, extension) |
| 32 | else: |
| 33 | dest = "{}/{}-$VERSION.{}".format(filename, filename, extension) |
| 34 | return {"url": url, "dest": dest} |
| 35 | |
| 36 | |
| 37 | with open( "{}/autorelease/binaries.csv".format(root), "r" ) as f: |
| 38 | reader = csv.DictReader(f) |
| 39 | errors = 0 |
| 40 | |
| 41 | print """ |
| 42 | #!/bin/bash |
| 43 | # |
| 44 | # Copyright 2016-2017 Huawei Technologies Co., Ltd. |
| 45 | # |
| 46 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 47 | # you may not use this file except in compliance with the License. |
| 48 | # You may obtain a copy of the License at |
| 49 | # |
| 50 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 51 | # |
| 52 | # Unless required by applicable law or agreed to in writing, software |
| 53 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 54 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 55 | # See the License for the specific language governing permissions and |
| 56 | # limitations under the License. |
| 57 | # |
| 58 | |
| 59 | VERSION=2.0.0 |
| 60 | |
| 61 | set +e |
| 62 | |
| 63 | """ |
| 64 | items = [] |
| 65 | for row in reader: |
| 66 | item = parseRow(row) |
| 67 | items.append(item) |
| 68 | |
| 69 | print "# {}".format(row["service"]) |
| 70 | print "mkdir -p {}".format(row["filename"]) |
| 71 | print "wget -O \"{}\" \"{}\"".format(item["dest"], item["url"]) |
| 72 | print "" |