| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | # This script is used to bump version of bjam. It takes a single argument, e.g |
|---|
| 4 | # |
|---|
| 5 | # ./bump_version.py 3.1.9 |
|---|
| 6 | # |
|---|
| 7 | # and updates all necessary files. For the time being, it's assumes presense |
|---|
| 8 | # of 'perl' executable and Debian-specific 'dch' executable. |
|---|
| 9 | # |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | import sys |
|---|
| 13 | import string |
|---|
| 14 | import os |
|---|
| 15 | |
|---|
| 16 | def spec(version): |
|---|
| 17 | os.system("perl -pi -e 's|^Version:.*|Version: %s|' boost-jam.spec" % |
|---|
| 18 | string.join(version, ".")) |
|---|
| 19 | |
|---|
| 20 | def build_jam(version): |
|---|
| 21 | os.system("perl -pi -e 's|^VERSION = .* ;|VERSION = %s\$(.)%s\$(.)%s ;|' build.jam" |
|---|
| 22 | % (version[0], version[1], version[2])) |
|---|
| 23 | |
|---|
| 24 | def index_html(version): |
|---|
| 25 | os.system("perl -pi -e 's|This is version .* of BJam|This is version %s of BJam|' index.html" |
|---|
| 26 | % string.join(version, ".")) |
|---|
| 27 | |
|---|
| 28 | def jam_c(version): |
|---|
| 29 | re = "\\*major_version = .*, \\*minor_version = .*, \\*changenum = .*"; |
|---|
| 30 | new = ('*major_version = "%02d", *minor_version = "%02d", *changenum = "%02d";' % |
|---|
| 31 | (int(version[0]), int(version[1]), int(version[2]))) |
|---|
| 32 | os.system("perl -pi -e 's|%s|%s|' jam.c" % (re, new)) |
|---|
| 33 | |
|---|
| 34 | def patchlevel(version): |
|---|
| 35 | os.system("perl -pi -e 's|VERSION .*|VERSION \"%s\"|' patchlevel.h" % |
|---|
| 36 | string.join(version, ".")) |
|---|
| 37 | |
|---|
| 38 | def dch(version): |
|---|
| 39 | os.system("dch --ignore-dirname -v " + string.join(version, ".") + "-1") |
|---|
| 40 | |
|---|
| 41 | bumpers = [spec, build_jam, index_html, jam_c, patchlevel, dch] |
|---|
| 42 | |
|---|
| 43 | def main(): |
|---|
| 44 | |
|---|
| 45 | if len(sys.argv) < 2: |
|---|
| 46 | print "Expect new version as argument" |
|---|
| 47 | sys.exit(1) |
|---|
| 48 | |
|---|
| 49 | new_version = string.split(sys.argv[1], ".") |
|---|
| 50 | print "Setting version to", new_version |
|---|
| 51 | for b in bumpers: |
|---|
| 52 | b(new_version) |
|---|
| 53 | |
|---|
| 54 | if __name__ == '__main__': |
|---|
| 55 | main() |
|---|