Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/build.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-16 16:53:36 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-16 16:53:36 (GMT)
commit39f3d8a9428e031c4bdb0cc9a26f2fb1df9a7520 (patch)
tree7947f1413318b4379bae8e6c28fc92e61d38d3ee /devbot/build.py
parentc6206d0f80d5961b5d52a5b03765acdad2c22f7e (diff)
Add a distribute command
It builds and uploads releases.
Diffstat (limited to 'devbot/build.py')
-rw-r--r--devbot/build.py93
1 files changed, 86 insertions, 7 deletions
diff --git a/devbot/build.py b/devbot/build.py
index ee15192..9823310 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -1,14 +1,20 @@
import fnmatch
+import re
import os
import multiprocessing
import shutil
import subprocess
+from distutils.sysconfig import parse_makefile
from devbot import command
from devbot import config
from devbot import environ
from devbot import state
from devbot import utils
+from devbot import release
+
+_builders = {}
+_distributors = {}
def build_one(module_name):
environ.setup()
@@ -72,6 +78,16 @@ def build():
return True
+def distribute():
+ environ.setup()
+
+ for module in config.load_modules():
+ if module.distribute:
+ if not _distribute_module(module):
+ break
+
+ return True
+
def clean():
_rmtree(config.install_dir)
_rmtree(config.prefix_dir)
@@ -134,10 +150,53 @@ def _build_autotools(module, log):
_unlink_libtool_files()
+_builders["autotools"] = _build_autotools
+
def _build_activity(module, log):
setup = os.path.join(module.get_source_dir(), "setup.py")
command.run([setup, "install", "--prefix", config.prefix_dir], log)
+_builders["activity"] = _build_activity
+
+def _distribute_autotools(module):
+ makefile = parse_makefile("Makefile")
+ filename = makefile["DIST_ARCHIVES"]
+ version = makefile["VERSION"]
+
+ git_module = module.get_git_module()
+
+ version_revision = None
+ description = git_module.describe()
+ if description != "v%s" % version:
+ match = re.match(r"(v[\d\.]+)", description)
+ if match is None:
+ print "No version tag was found"
+ return False
+ else:
+ version_revision = match.groups()[0]
+
+ if version_revision is not None:
+ git_module.checkout(version_revision)
+
+ command.run(["make", "distcheck"])
+
+ result = False
+
+ if not release.exists(module, filename):
+ path = os.path.join(os.getcwd(), filename)
+ if release.upload(module, path):
+ annotation = git_module.get_annotation("v%s" % version)
+ result = release.announce(module, filename, version, annotation)
+ else:
+ print "Release already uploaded"
+
+ if version_revision is not None:
+ git_module.checkout()
+
+ return result
+
+_distributors["autotools"] = _distribute_autotools
+
def _build_module(module, log=None):
print "\n=== Building %s ===\n" % module.name
@@ -159,14 +218,11 @@ def _build_module(module, log=None):
os.chdir(source_dir)
try:
- if os.path.exists(os.path.join(source_dir, "setup.py")):
- _build_activity(module, log)
- elif os.path.exists(os.path.join(source_dir, "autogen.sh")):
- _build_autotools(module, log)
- else:
- print "The source directory has unexpected content, please " \
- "delete it and pull\nthe source again."
+ build_system = module.get_build_system()
+ if build_system is None:
return False
+
+ _builders[build_system](module, log)
except subprocess.CalledProcessError:
return False
@@ -174,6 +230,29 @@ def _build_module(module, log=None):
return True
+def _distribute_module(module, log=None):
+ print "\n=== Distribute %s ===\n" % module.name
+
+ build_dir = module.get_build_dir()
+
+ if not os.path.exists(build_dir):
+ print "Build directory does not exist. Please build before " \
+ "distributing."
+ return False
+
+ os.chdir(build_dir)
+
+ try:
+ build_system = module.get_build_system()
+ if build_system is None:
+ return False
+
+ _distributors[build_system](module)
+ except subprocess.CalledProcessError:
+ return False
+
+ return True
+
def _rmtree(dir):
print "Deleting %s" % dir
shutil.rmtree(dir, ignore_errors=True)