diff options
author | 2016-07-26 13:29:03 +0000 | |
---|---|---|
committer | 2016-07-27 11:13:06 +0000 | |
commit | a50635dbb821aa981fc5245e80a906ce9fd80448 (patch) | |
tree | 0059bddc5e0632436e9d775f299de622bb656fea /scripts/packages/convert_changelog.py | |
parent | ad81cffc9d9c6234fe22c19bd26523313a82d554 (diff) |
Build Bazel debian source package using Bazel
--
Change-Id: I8c0b6adf08a4ca64ad41e0454cb30842c133fa22
Reviewed-on: https://bazel-review.googlesource.com/#/c/4161
MOS_MIGRATED_REVID=128465441
Diffstat (limited to 'scripts/packages/convert_changelog.py')
-rw-r--r-- | scripts/packages/convert_changelog.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/packages/convert_changelog.py b/scripts/packages/convert_changelog.py new file mode 100644 index 0000000000..78edbda914 --- /dev/null +++ b/scripts/packages/convert_changelog.py @@ -0,0 +1,60 @@ +# pylint: disable=g-bad-file-header +# Copyright 2015 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""This tool convert Bazel's changelog file to debian changelog format.""" + +from datetime import datetime +import sys + + +def main(input_file, output_file): + changelog_out = open(output_file, "w") + time_stamp = None + with open(input_file, "r") as changelog_in: + for line in changelog_in: + line = line.strip() + + if line.startswith("```") or line.startswith("Baseline"): + continue + + if line.startswith("## Release"): + if time_stamp: + changelog_out.write( + "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" % + time_stamp) + parts = line.split(" ") + version = parts[2] + time_stamp = datetime.strptime( + parts[3], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100") + changelog_out.write("bazel (%s) unstable; urgency=low\n" % version) + + elif line.startswith("+") or line.startswith("-"): + parts = line.split(" ") + line = "*" + line[1:] + changelog_out.write(" %s\n" % line) + + elif line.endswith(":"): + changelog_out.write("\n %s\n" % line) + + elif line: + changelog_out.write(" %s\n" % line) + + if time_stamp: + changelog_out.write( + "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" % + time_stamp) + + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) |