import shutil
import logging
import smtplib
+import optparse
+import datetime
import platform
import subprocess
from glob import glob
send_email(SMTP_BUILD_ERROR)
sys.exit(1)
+def getopts():
+ usage = '%prog [options]'
+ parser = optparse.OptionParser(usage=usage, version='%prog 0.1')
+ parser.add_option(
+ '--distribution',
+ dest='distribution',
+ choices = ['stable', 'testing', 'unstable', 'experimental'],
+ default='unstable',
+ help='The pkg distribution. Default: %default'
+ )
+
+ return parser.parse_args()
+
if __name__ == '__main__':
logger.debug(
'Initialised with Enviroment: %s'
)
)
logging.getLogger('lib.git_helper').setLevel(logging.DEBUG)
+ options, args = getopts()
if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
logger.info('git clone was successfull')
else:
if repo.active_branch != 'master' and GIT_DEBIAN_BRANCH != 'master':
git_helper.git_checkout_branch(GIT_DEBIAN_BRANCH)
+ pb_version_path = os.path.join('debian', 'pb_version')
+
+ if not os.path.exists(pb_version_path):
+ pb_version = '0.0'
+ else:
+ fh = open(pb_version_path)
+ pb_version = fh.read().rstrip()
+ fh.close()
+
+ if options.distribution in ('unstable', 'experimental'):
+ daily_date = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
+ version = '%s-%s' %(pb_version, daily_date)
+ os.unlink('debian/changelog')
+ fh = open('debian/control')
+ for line in fh:
+ if line.startswith('Source:'):
+ pkg_name = line.split(':')[-1].lstrip().rstrip()
+ fh.close()
+
+ cmd = ['/usr/bin/git', 'log']
+ git_log = subprocess.Popen(
+ cmd,
+ shell=False,
+ close_fds=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd='./'
+ )
+
+ ret = git_log.wait()
+
+ if ret:
+ raise Exception('git log was not successfull')
+# git_log_output = map(
+# lambda x: x.rstrip(),
+# cmd_obj.stdout.readlines()
+# )
+
+
+ cmd = [
+ '/usr/bin/dch',
+ '--create',
+ '--package',
+ pkg_name,
+ '--newversion',
+ '%s' %(version),
+ '--distribution',
+ '%s' %(options.distribution),
+ '--',
+ '%s' %(git_log.stdout.read())
+ ]
+
+ dch = subprocess.Popen(
+ cmd,
+ shell=True,
+ close_fds=True,
+ stdin=git_log.stdout,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd='./'
+ )
+ ret = dch.wait()
+
+ if ret:
+ raise Exception('git dch was not successfull')
+ logger.info('debian/changelog written')
+
if not GIT_COMMITTER_EMAIL:
for commit in repo.commits():
if commit.id == GIT_NEW_ID: