| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | import glob |
|---|
| 4 | import logging |
|---|
| 5 | import os |
|---|
| 6 | import re |
|---|
| 7 | import shutil |
|---|
| 8 | try: |
|---|
| 9 | import subprocess |
|---|
| 10 | except ImportError: |
|---|
| 11 | from fake_subprocess import subprocess |
|---|
| 12 | import sys |
|---|
| 13 | import ConfigParser |
|---|
| 14 | |
|---|
| 15 | script = sys.argv[0] |
|---|
| 16 | script = os.path.abspath(script) |
|---|
| 17 | src_dir = os.path.dirname(script) |
|---|
| 18 | os.chdir(src_dir) |
|---|
| 19 | |
|---|
| 20 | logging.getLogger().setLevel(logging.INFO) |
|---|
| 21 | log_dir = os.path.join(src_dir, "logs") |
|---|
| 22 | package_dir = os.path.join(src_dir, "packages") |
|---|
| 23 | rpm_dir = os.path.join(src_dir, "rpms") |
|---|
| 24 | tmp_dir = os.path.join(src_dir, "tmp") |
|---|
| 25 | |
|---|
| 26 | os.chdir(package_dir) |
|---|
| 27 | |
|---|
| 28 | building_new_python = sys.version_info[0] == 2 and sys.version_info[1] < 5 |
|---|
| 29 | python_suffix = os.environ.get("PYTHON_SUFFIX","") |
|---|
| 30 | python_suffix2 = os.environ.get("PYTHON_SUFFIX2","") |
|---|
| 31 | |
|---|
| 32 | SJSOFT_URL="svn+ssh://svn.sjsoft.com/home/closedsvn/svn" |
|---|
| 33 | #BRANCH_PATHS={"1.8":"releases/1.8.x","1.10": "releases/1.10.x"} |
|---|
| 34 | BRANCH_PATHS={"1.12.1.x": "releases/1.12.1.x"} |
|---|
| 35 | #BRANCH_PATHS={"1.11.x": "releases/1.11.x"} |
|---|
| 36 | SOURCE_PATH="j5/src/" |
|---|
| 37 | for BRANCH_PATH in BRANCH_PATHS: |
|---|
| 38 | print "Creating sjsoft-j5 version %s" % BRANCH_PATH |
|---|
| 39 | SVN_URL = "%s/%s/%s" % (SJSOFT_URL, BRANCH_PATHS[BRANCH_PATH], SOURCE_PATH) |
|---|
| 40 | |
|---|
| 41 | log_filename = os.path.join(log_dir, "sjsoft-svn-%s.log" % BRANCH_PATH) |
|---|
| 42 | log_file = open(log_filename, "wb") |
|---|
| 43 | subprocess.call(["svn", "co", SVN_URL, "sjsoft-src-%s" % BRANCH_PATH], stdout=log_file) |
|---|
| 44 | os.chdir("sjsoft-src-%s" % BRANCH_PATH) |
|---|
| 45 | subprocess.call(["svn", "up"], stdout=log_file) |
|---|
| 46 | subprocess.call(["svn", "switch", SVN_URL], stdout=log_file) |
|---|
| 47 | if os.path.exists(os.path.join("sjsoft", "Library", "FunctionalTests")): |
|---|
| 48 | shutil.rmtree(os.path.join("sjsoft", "Library", "FunctionalTests")) |
|---|
| 49 | if not os.path.exists("yahp.jar"): |
|---|
| 50 | subprocess.call(["wget","-c","http://download.sjsoft.com/yahpconverter/yahp1.2.19c.jar","-O","yahp.jar"], stdout=log_file) |
|---|
| 51 | open("yahp-version.txt","w").write("1.2.19c") |
|---|
| 52 | # Clean this out as the specfiles don't seem to do this - will nuke concurrent builds |
|---|
| 53 | for build_dir in glob.glob("/var/tmp/sjsoft-j5-*-buildroot/"): |
|---|
| 54 | shutil.rmtree(build_dir) |
|---|
| 55 | |
|---|
| 56 | if os.path.exists("setup.cfg"): |
|---|
| 57 | os.remove("setup.cfg") |
|---|
| 58 | build_config = ConfigParser.ConfigParser() |
|---|
| 59 | build_config.read('setup-bdist_rpm.cfg') |
|---|
| 60 | build_config.set('install', 'remove_source', '1') |
|---|
| 61 | # TODO: generate this dependencies list from the requirements specs |
|---|
| 62 | requirements = [("CherryPy", "3.1.1"), |
|---|
| 63 | ("decorator", "3.2.0"), |
|---|
| 64 | ("Creoleparser", "0.6"), |
|---|
| 65 | ("Genshi", "0.5.1"), |
|---|
| 66 | ("Routes", "1.11"), |
|---|
| 67 | ("ZSI", "2.0_rc3"), |
|---|
| 68 | ("html5lib", "0.11.1"), |
|---|
| 69 | ("lxml", "2.2"), |
|---|
| 70 | ("multiprocessing", "1.6.1.1"), |
|---|
| 71 | ("pyparsing"+python_suffix2, "1.5.1"), |
|---|
| 72 | ("xlwt", "0.7.1"), |
|---|
| 73 | ("pytz"+python_suffix2,"2006a"), |
|---|
| 74 | ("PyXML"+python_suffix2,"0.8.4"), |
|---|
| 75 | ("soaplib", "0.9"), |
|---|
| 76 | ("MySQL-python"+python_suffix, "1.2.1"), |
|---|
| 77 | ("numpy"+python_suffix, "1.0.3"), |
|---|
| 78 | ("protobuf-python"+python_suffix, "2.0.2"), |
|---|
| 79 | ("python%s-imaging" % python_suffix, "1.1.5"), |
|---|
| 80 | ("python%s-ldap" % python_suffix, "2.3"), |
|---|
| 81 | ("python%s-nose" % python_suffix, "0.9.2"), |
|---|
| 82 | ("python%s-pgsql" % python_suffix, "0.9.6"), |
|---|
| 83 | ("python%s-simplejson" % python_suffix, "1.7.3"), |
|---|
| 84 | ("python%s-xlrd" % python_suffix, "0.6.1"), |
|---|
| 85 | ("python%s-crypto" % python_suffix, "2.0.1"), |
|---|
| 86 | ("python%s-lxml" % python_suffix,"1.3.6"), |
|---|
| 87 | ("python%s-dateutil" % python_suffix,"1.1"), |
|---|
| 88 | ("python%s-suds" % python_suffix,"0.3.3"), |
|---|
| 89 | ("python%s-sqlalchemy" % python_suffix,"0.6.0") |
|---|
| 90 | ] |
|---|
| 91 | if int(BRANCH_PATH.split('.')[0]) > 1 or int(BRANCH_PATH.split('.')[1]) >= 10: |
|---|
| 92 | requirements.append(("Babel", "0.9.1")) |
|---|
| 93 | requires = ", ".join(["%s >= %s" % (name, version) for (name, version) in requirements]) |
|---|
| 94 | build_config.set('bdist_rpm', 'requires', requires) |
|---|
| 95 | build_config.write(open('setup.cfg', 'w')) |
|---|
| 96 | log_filename = os.path.join(log_dir, "build-sjsoft-rpms.log") |
|---|
| 97 | log_file = open(log_filename, "wb") |
|---|
| 98 | if building_new_python: |
|---|
| 99 | ret_code = subprocess.call(["python"+os.environ["PYTHON_VERSION"], "setup_standalone.py", "bdist_rpm", "--fix-python"], stdout=log_file, stderr=log_file) |
|---|
| 100 | else: |
|---|
| 101 | ret_code = subprocess.call(["python", "setup_standalone.py", "bdist_rpm", "--fix-python"], stdout=log_file, stderr=log_file) |
|---|
| 102 | os.remove("setup.cfg") |
|---|
| 103 | if ret_code: |
|---|
| 104 | logging.warning("build unsuccessful; tailing log file") |
|---|
| 105 | print "".join(open(log_filename, "rb").readlines()[-10:]) |
|---|
| 106 | sys.exit(1) |
|---|
| 107 | for rpm_filename in [filename for filename in os.listdir("dist") if filename.endswith(".rpm")]: |
|---|
| 108 | shutil.copyfile(os.path.join("dist", rpm_filename), os.path.join(rpm_dir, rpm_filename)) |
|---|
| 109 | os.chdir(os.path.dirname(os.path.abspath(os.curdir))) |
|---|
| 110 | |
|---|