DPUT_CF = os.path.join(CWD, '..', 'dput.cf')
-class HudsonUrl(urllib.FancyURLopener):
- pass
-
-def read_file(path):
- try:
- fh = open(path, 'r', 1)
- except:
- raise
- else:
- result = dict(enumerate(fh))
- fh.close()
- return result
-
def dput_package_upload(changes_path):
try:
cmd = [BIN_DPUT,
return True
-def remove_git_target_workspace():
- if not os.path.exists(GIT_TARGET_WORKSPACE):
- return True
-
- try:
- cmd = [BIN_SUDO, BIN_RM, '-rf', GIT_TARGET_WORKSPACE]
- cmdobj = subprocess.Popen(
- cmd,
- shell=False,
- cwd='/',
- close_fds=True,
- stdout=sys.stdout,
- stderr=sys.stderr,
- env={'':''}
- )
-
- logger.debug(
- 'Trying to call "%s" to delete "%s"'
- %(' '.join(cmd), GIT_TARGET_WORKSPACE)
- )
- ret = cmdobj.wait()
-
- if not ret:
- message = (
- 'Cmd "%s" returned non-zero (exitcode: %s).'
- %(' '.join(cmd), ret)
- )
- logger.debug(message)
- raise Exception(message)
- except Exception, error:
- logger.exception(error)
- raise
- else:
- logger.info('deleted %s' %(GIT_TARGET_WORKSPACE))
- return True
-
-
def getopts():
usage = '%prog [options]'
parser = optparse.OptionParser(usage=usage, version='%prog 0.1')
)
)
)
- #logging.getLogger('lib.git_helper').setLevel(logging.DEBUG)
+ # FIXME: not used right now, shall it be used?
options, args = getopts()
- #if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
- # logger.info('git clone was successfull')
- #else:
- # logger.error('git clone was not successfull')
- # exit_error()
-
- #atexit.register(remove_git_target_workspace)
- #os.chdir(GIT_TARGET_DIR)
# FIXME: this is just needed for gbp and can go away eventually
if GIT_BRANCH_NAME:
logger.error('Could not determine GIT_UPSTREAM_BRANCH')
exit_error()
- repo = git.repo.Repo()
+ repo = git.Repo()
# reset local repository first
localname = GIT_BRANCH_NAME
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env={'':''}
- )
+ )
logger.debug('Calling "%s":' %(' '.join(cmd)))
ret = cmdobj.wait()
logger.debug('%s' %(line.strip()))
logger.debug('Cmd returned with status %d' %(cmdobj.returncode))
- ## #if GIT_BRANCH_NAME != 'master':
- ## if not git_helper.git_new_branch_from(localname,remotename):
- ## raise Exception('Checkout of %s was not successfull.' %( remotename ))
-
- # we need to make sure our jenkins config is used, so let's delete any
- # other config available in repository that might be prefered
- #cleanup_files = ('.gbp.conf', 'debian/gbp.conf', '.git/gbp.conf')
- #result = git_helper.git_cleanup_branch(cleanup_files)
- #commit_files = result["goods"].keys()
- #if len(commit_files) > 0:
- # git_helper.git_commit(
- # "Cleanup branch for correct builds.",
- # commit_files
- # )
-
+ # gather details from changelog
cmd = ['dpkg-parsechangelog']
parse_changelog = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=sys.stderr,
cwd='./'
- )
+ )
ret = parse_changelog.wait()
if ret:
- logger.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)
- )
+ message = '{cmd} failed with return code {code}'.format(
+ cmd = ' '.join(cmd),
+ code = ret,
+ )
+ logger.error(message)
+ raise Exception(message)
exit_error()
-
- changelog = parse_changelog.stdout
+ else:
+ changelog = parse_changelog.stdout
cmd = ['grep-dctrl', '-n', '-s', 'Source,Version,Distribution', '']
grep_dctrl = subprocess.Popen(
stdout=subprocess.PIPE,
stderr=sys.stderr,
cwd=os.getcwd()
- )
+ )
ret = grep_dctrl.wait()
if ret:
- logger.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)
- )
+ message = '{cmd} failed with return code {code}'.format(
+ cmd = ' '.join(cmd),
+ code = ret,
+ )
+ logger.error(message)
+ raise Exception(message)
exit_error()
-
- pkg_name = grep_dctrl.stdout.readline()
- pkg_name = pkg_name.strip()
- logger.info('Source package name is %s' % (pkg_name))
-
- 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))
+ else:
+ pkg_name = grep_dctrl.stdout.readline().strip()
+ version = grep_dctrl.stdout.readline().strip()
+ distribution = grep_dctrl.stdout.readline().strip()
+ logger.info(
+ 'Changelog: Package {name} with version {version} in distribution {dist}'.format(
+ name = pkg_name,
+ version = version,
+ dist = distribution,
+ ))
section_error=False
for line in fileinput.input('debian/control'):