From: Mathias Klette Date: Thu, 2 May 2013 10:34:32 +0000 (+0200) Subject: Merge branch 'develop' into feature/DEVINF-28 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=bbc59d68d60663c0ef4dfd4d40d07e4f57d73383;p=profitbricks%2Fjenkins-build-scripts.git Merge branch 'develop' into feature/DEVINF-28 Conflicts: debian_build.py --- bbc59d68d60663c0ef4dfd4d40d07e4f57d73383 diff --cc debian_build.py index 2ddfd00,0daa6c9..677a1dd --- a/debian_build.py +++ b/debian_build.py @@@ -6,39 -6,46 +6,39 @@@ # # wirklich. wirklich. wirklich. # -# -# mehr kommentare wären auch gut. wirklich gut. +# mehr kommentare waeren auch gut. wirklich gut. -import os -import re -import pwd -import sys -import git -import errno -import atexit -import shutil +# import standards +import datetime +import fileinput import fnmatch +import git import optparse -import datetime +import os import platform +import pwd +import re +import shutil import subprocess +import sys import time -import urllib -import fileinput -import psycopg2 -from common_code import * +from ConfigParser import SafeConfigParser +from multiprocessing import cpu_count + +# import local modules from add_liveboot_request import add_liveboot_request -from db_add import * from cidb import * -from glob import glob -from ftplib import FTP -from lib import git_helper -from logging import Formatter +from common_code import * +from db_add import * +from lib import dput from lib import git_buildpackage -from multiprocessing import cpu_count -from ConfigParser import SafeConfigParser +from lib import git_helper + # from common_code - logger = logger_init() + logger = logger_init(__file__) -# local constants -DEFAULT_PARALLEL_JOBS = cpu_count() + 1 -JOB_URL = 'http://jenkins:80/job/%(flavour)s/buildWithParameters?token=BuildIt&' -JOB_DELAY = '0sec' - +# jenkins parameters GIT_REPO_PATH = ENV['GIT_REPO_PATH'] GIT_REPO_NAME = os.path.basename(ENV['GIT_REPO_PATH']) GIT_BRANCH_NAME = ENV['GIT_BRANCH_NAME'] @@@ -46,22 -53,8 +46,23 @@@ GIT_COMMITTER_EMAIL = ENV['GIT_COMMITTE ENV.setdefault('NO_UPLOAD','') NO_UPLOAD = ENV['NO_UPLOAD'] +# local constants + BUILD_START = datetime.datetime.now() +DEFAULT_PARALLEL_JOBS = cpu_count() + 1 +JOB_URL = 'http://jenkins:80/job/%(flavour)s/buildWithParameters?token=BuildIt&' +JOB_DELAY = '0sec' + +AUTO_CHANGELOG_REPONAMES = ( + 'ri-docs', + 'so-docs', + 'infrastructure-docs', + 'storage-docs', + ) +STABLE_DISTRIBUTIONS = ( + 'stable', + 'production', + 'production-proposed-updates' + ) #unused: (except in in-active code) GIT_TARGET_WORKSPACE = os.path.join( @@@ -84,14 -83,105 +85,14 @@@ DPUT_OPTIONS_DEV = 'allow_unsigned_uploads': 1, 'post_upload_command': 'ssh reprepro@alexandria.pb.local /srv/dev-repository/bin/pb_processincoming', } - DPUT_CF = os.path.join(CWD, '..', 'dput.cf') + DPUT_CF = os.path.join(ENV['WORKSPACE'], '..', 'dput.cf') -AUTO_CHANGELOG_JOBS = ( - 'ri-docs', - 'so-docs', - 'infrastructure-docs', - 'storage-docs', - ) - -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, - '-c', - '%s' %(DPUT_CF), - '--no-upload-log', - 'profitbricks', - '%s' %(changes_path), - ] - - logger.debug( 'Trying to execute: "%s"' %(cmd)) - cmd_obj = subprocess.Popen( - cmd, - shell=False, - stdout=sys.stdout, - stderr=subprocess.STDOUT, - close_fds=True, - cwd=os.path.dirname(DPUT_CF) - ) - result = cmd_obj.wait() - logger.debug('Exit status: %d' %( result )) - - if result != 0: - raise Exception('FIXME: explain the error') - - except Exception, error: - logger.exception('%s' %(error)) - - return True + # FIXME: i went to lib/dput.py def create_dput_cfg(): - fh = open(DPUT_CF, 'w') - config = SafeConfigParser() - config.add_section('profitbricks') - for option, value in DPUT_OPTIONS.iteritems(): - config.set('profitbricks', '%s' %(option), '%s' %(value)) - config.write(fh) - fh.close() - 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 - + # FIXME: i went to lib/dput.py def getopts(): usage = '%prog [options]' @@@ -197,7 -295,7 +198,7 @@@ if __name__ == '__main__' else: logger.debug('Status is now:\n%s' %( gitcmd.status().strip() )) - if GIT_BRANCH_NAME == 'master' and BUILD_JOBNAME in AUTO_CHANGELOG_REPONAMES: - if GIT_BRANCH_NAME == 'master' and ENV['JOB_NAME'] in AUTO_CHANGELOG_JOBS: ++ if GIT_BRANCH_NAME == 'master' and ENV['JOB_NAME'] in AUTO_CHANGELOG_REPONAMES: cmd = ['/usr/bin/dch', '-i', 'Released by jenkins.'] subprocess.check_call(cmd) cmd = ['/usr/bin/git-dch', '-R', '-a', '--spawn-editor=none']