#
# 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']
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(
'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]'
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']