commit_files
)
- pb_version_path = os.path.join('debian', 'pb_version')
- if not os.path.exists(pb_version_path):
- pb_version = '0.0'
+ if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
+ logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
else:
- fh = open(pb_version_path)
- pb_version = fh.readline().rstrip()
- fh.close()
+ logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
+ exit_error()
- fh = open('debian/control')
- for line in fh:
- if line.startswith('Source:'):
- pkg_name = line.split(':')[-1].lstrip().rstrip()
- break
- fh.close()
+ cmd = ['dpkg-parsechangelog']
+ parse_changelog = subprocess.Popen(
+ cmd,
+ shell=False,
+ close_fds=True,
+ stdout=subprocess.PIPE,
+ stderr=sys.stderr,
+ cwd='./'
+ )
+ ret = parse_changelog.wait()
+ if ret:
+ logger_loud_error('%s was not successfull, return code was %s ' % (' '.join(cmd), ret))
+ raise Exception(
+ '%s was not successfull, return code was %s ' % (' '.join(cmd), ret)
+ )
+ exit_error()
- if options.distribution in ('pre-staging', 'unstable', 'experimental'):
+ changelog = parse_changelog.stdout
- daily_date = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
- version = '%s~%s-1' %(pb_version, daily_date)
- os.unlink('debian/changelog')
- cmd = ['/usr/bin/git', 'log', '--since=yesterday', '--abbrev-commit', '--format=format:"%cD -- %aN%n[%h] %s%n"']
- git_log = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- cwd='./',
- universal_newlines=True
+ cmd = ['grep-dctrl', '-n', '-s', 'Source,Version,Distribution', '']
+ grep_dctrl = subprocess.Popen(
+ cmd,
+ shell=False,
+ close_fds=True,
+ stdin=changelog,
+ stdout=subprocess.PIPE,
+ stderr=sys.stderr,
+ cwd=os.getcwd()
+ )
+ ret = grep_dctrl.wait()
+ if ret:
+ logger_loud_error('%s was not successfull, return code was %s ' % (' '.join(cmd), ret))
+ raise Exception(
+ '%s was not successfull, return code was %s ' % (' '.join(cmd), ret)
)
+ exit_error()
- ret = git_log.wait()
+ pkg_name = grep_dctrl.stdout.readline()
+ pkg_name = version.strip()
+ logger.info('Source package name is %s' % (version))
- if ret:
- raise Exception('git log was not successfull')
+ version = grep_dctrl.stdout.readline()
+ version = version.strip()
+ logger.info('Package version is %s' % (version))
+
+ distribution = grep_dctrl.stdout.readline()
+ distribution = distribution.strip()
+ logger.info('Package distribution is %s' % (distribution))
+
+ if (options.distribution in ('testing', 'staging') and not distribution in ('testing', 'staging')) \
+ or (options.distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates') and not distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates')) \
+ or (options.distribution in ('unstable', 'pre-staging') and not distribution in ('unstable', 'pre-staging', 'UNRELEASED')):
+ logger_loud_error('Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution))
+ raise Exception(
+ 'Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution)
+ )
+ exit_error()
+
+ if (options.distribution in ('testing', 'staging') or (options.distribution in ('unstable', 'pre-staging'):
+ daily_date = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
+ if (options.distribution in ('testing', 'staging'):
+ version = '%s~rc%s-1' %(version, daily_date)
else:
- logger.info('git log was successfull')
+ version = '%s~develop%s-1' %(version, daily_date)
- new_log = git_log.stdout.read()
- if new_log == '':
- logger.info('git log since yesterday is empty, aborting build.')
- sys.exit(0)
+ new_log = 'Generated by jenkins build.'
cmd = [
'/usr/bin/dch',
- '--create',
- '--package',
- pkg_name,
'--newversion',
'%s' %(version),
'--distribution',
raise Exception(
'"%s" returned with exitcode: %s' %(' '.join(cmd), ret)
)
- logger.info('debian/changelog written')
# we need to commit here else git-buildpackage will use the existing debian/changelog...
# TODO: Later we should investigate why the "--ignore-new" trick
# did not work!
cmd = ['/usr/bin/git', 'add', '-A']
subprocess.check_call(cmd)
- cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add changelog']
+ cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add new changelog entry']
subprocess.check_call(cmd)
- else:
- # so we're in the master or release branches
- # let's check it out :-D
- if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
- logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
- else:
- logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
- exit_error()
-
- cmd = ['dpkg-parsechangelog']
- parse_changelog = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdout=subprocess.PIPE,
- stderr=sys.stderr,
- cwd='./'
- )
- ret = parse_changelog.wait()
- if ret:
- logger_loud_error('%s was not successfull, return code was %s ' % (' '.join(cmd), ret))
- raise Exception(
- '%s was not successfull, return code was %s ' % (' '.join(cmd), ret)
- )
- exit_error()
-
- changelog = parse_changelog.stdout
-
- cmd = ['grep-dctrl', '-n', '-s', 'Version,Distribution', '']
- grep_dctrl = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdin=changelog,
- stdout=subprocess.PIPE,
- stderr=sys.stderr,
- cwd=os.getcwd()
- )
- ret = grep_dctrl.wait()
- if ret:
- logger_loud_error('%s was not successfull, return code was %s ' % (' '.join(cmd), ret))
- raise Exception(
- '%s was not successfull, return code was %s ' % (' '.join(cmd), ret)
- )
- exit_error()
-
- version = grep_dctrl.stdout.readline()
- version = version.strip()
- logger.info('Packet version is %s' % (version))
-
- distribution = grep_dctrl.stdout.readline()
- distribution = distribution.strip()
- logger.info('Packet distribution is %s' % (distribution))
- if (options.distribution in ('testing', 'staging') and not distribution in ('testing', 'staging')) or (options.distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates') and not distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates')):
- logger_loud_error('Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution))
- raise Exception(
- 'Distribution %s in debian/changelog did not match branch %s' % (distribution, options.distribution)
- )
- exit_error()
if not GIT_COMMITTER_EMAIL:
for commit in repo.commits():