import os
import re
import sys
-import git
import atexit
import shutil
import subprocess
import logging
-import platform
import smtplib
from glob import glob
from logging import Formatter
-from ftplib import FTP
-from multiprocessing import cpu_count
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Table, Column, Integer, String, MetaData, Sequence
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.exc import NoResultFound
-GIT = '/usr/bin/git'
-MAKE_KPKG = '/usr/bin/make-kpkg'
-DEFAULT_PARALLEL_JOBS = cpu_count() + 1
-
-BUILD_ARCH_MAP = {
- 'x86_64': 'amd64',
- 'i386': '686'
-}
-
-BUILD_ARCH = BUILD_ARCH_MAP.get(platform.machine(), '686')
-
CWD = os.environ.get('WORKSPACE')
BUILD_NUMBER = os.environ.get('BUILD_NUMBER')
BUILD_ID = os.environ.get('BUILD_ID')
GIT_OLD_ID = os.environ.get('GIT_OLD_ID')
GIT_NEW_ID = os.environ.get('GIT_NEW_ID')
GIT_BRANCH_NAME = os.environ.get('GIT_BRANCH_NAME')
-GIT_REMOTE_BRANCH_NAME = os.path.join('origin', '%s' %(GIT_BRANCH_NAME))
-GIT_TARGET_WORKSPACE = os.path.join(
- CWD,
- '%s-build%s' %(BUILD_ID, BUILD_NUMBER)
-)
-
-GIT_TARGET_DIR = os.path.join(
- GIT_TARGET_WORKSPACE,
- os.path.basename(GIT_REPO_PATH)
-)
GIT_COMMITTER_EMAIL = os.environ.get('GIT_COMMITTER_EMAIL')
-KERNEL_CONFIG_PATH = os.path.join(GIT_TARGET_DIR, '.config')
-CREG_KERNEL_CONFIG_DELIM = re.compile(ur'\s*=\s*')
PERSISTENCE_FILE = os.path.join(CWD, '..', '.persistence')
SMTP_SERVER = 'roma.profitbricks.localdomain'
SMTP_SUBJECT = 'Kernel build for branch %s, buildnumber %s was %s'
)
logger.info('calling "%s" ...', ' '.join(cmd))
-# ret = cmdobj.wait()
ret = os.system('%s' %(' '.join(cmd)))
if ret:
-# errormsg = 'stdout: %s\n\n\nstderr: %s' %(cmdobj.stdout.read(),
-# cmdobj.stderr.read())
-# if not errormsg:
-# errormsg = None
logger.error(
'"%s" returned non-zero (exitcode was: %s).',
' '.join(cmd),
)
return False
-# message = cmdobj.stdout.read()
-# if not message:
-# message = None
logger.info(
'"%s" returned zero.', ' '.join(cmd))
return True
-def read_file(path):
- try:
- fh = open(path, 'r', 1)
- except:
- raise
- else:
- result = dict(enumerate(fh))
- fh.close()
- return result
-
def remove_git_target_workspace():
- try:
- shutil.rmtree(GIT_TARGET_WORKSPACE)
- except IOError, error:
- logger.debug('Got exception with error code: %s', error.errno)
- if error.errno == 2:
- pass
- else:
- raise
- logger.info('deleted %s' %(GIT_TARGET_WORKSPACE))
+ rmpath = '/tmp/%s-build%s' %(BUILD_ID, BUILD_NUMBER)
+ if os.path.isdir(rmpath):
+ try:
+ shutil.rmtree(rmpath)
+ except IOError, error:
+ logger.debug('Got exception with error code: %s', error.errno)
+ if error.errno == 2:
+ pass
+ else:
+ raise
+ logger.info('deleted %s' %(rmpath))
def exit_ok():
send_email(SMTP_BUILD_SUCCESS)
exit_error()
if not build_kernel_with_pbuilder(
- new_version, 'kernel_inpbuilder.py',
+ new_version, 'kernel_inpbuilder.py',
dist='stable'):
exit_error()
exit_ok()
import re
import sys
import git
-import atexit
import shutil
import subprocess
import logging
import optparse
from glob import glob
from logging import Formatter
-#from ftplib import FTP
+from ftplib import FTP
from multiprocessing import cpu_count
-__version__ = '0.0.1'
+__version__ = '0.0.2'
GIT = '/usr/bin/git'
MAKE_KPKG = '/usr/bin/make-kpkg'
cmd = [MAKE_KPKG, '-j', '%s' %(parallel_jobs), '--arch',
'%s' %(BUILD_ARCH), '--rootcmd', 'fakeroot', '--revision',
- '%s' %(revision), '--initrd', '--arch-in-name', 'kernel_debug',
+ '%s' %(revision), '--initrd', '--arch_in_name', 'kernel_debug',
'kernel_image', 'kernel_source', 'kernel_headers', 'modules']
logger.info('start compile process')
return localversion
return False
-def remove_git_target_workspace():
- try:
- shutil.rmtree(GIT_TARGET_WORKSPACE)
- except IOError, error:
- if error.errno == 2:
- pass
- else:
- raise
- logger.info('deleted %s' %(GIT_TARGET_WORKSPACE))
-
def exit(retcode):
logger.info('Exit with %s', retcode)
sys.exit(retcode)
-
def has_extra_modules():
return os.path.exists(EXTRA_MODULES_PATH)
# FIXME: Do we realy need BUILD_URL here?
BUILD_URL = os.environ.get('BUILD_URL') or options.build_url
- if not BUILD_URL:
- logger.error('No build url given')
- exit(ERROR)
GIT_REPO_PATH = os.environ.get('GIT_REPO_PATH') or options.git_repo_path
if not GIT_REPO_PATH:
else:
logger.info('git clone was not successfull')
exit(ERROR)
- #atexit.register(remove_git_target_workspace)
+
if not git_checkout_branch():
exit(ERROR)
- #kernel_revision_obj = get_last_kernel_revision_obj()
- #new_version = kernel_revision_obj.last_version + 1
+
new_version = REVISION
try:
add_local_version_to_config(new_version)
'updated CONFIG_LOCALVERSION in %s to %s'
%(KERNEL_CONFIG_PATH, new_version)
)
-# if not update_kernel_revision_obj(kernel_revision_obj, new_version):
-# logger.info(
-# 'Could not update persistence version to %s for %s'
-# %(new_version, GIT_BRANCH_NAME)
-# )
-# exit(ERROR)
logger.debug('changing dir to %s' %(GIT_TARGET_DIR))
os.chdir(GIT_TARGET_DIR)
if not build_kernel(new_version):
exit(ERROR)
else:
- #ftp = FTP(
- # 'alexandria.profitbricks.localdomain',
- # 'debian-uploader',
- # 'vae6tooZe1ec'
- #)
-
- #logger.info('FTP Login on %s successfull' %(ftp.host))
-
- #ftp.cwd('squeeze')
- #for package in glob(
- # os.path.join(GIT_TARGET_WORKSPACE, '*.deb')
- #):
- # fh = open(package, 'rb', 1)
- # ftp.storbinary(
- # 'STOR %s' %(os.path.basename(package)),
- # fh
- # )
- # fh.close()
- # logger.info('Successfully uploaded %s' %(package))
- #ftp.quit()
+ ftp = FTP(
+ 'alexandria.profitbricks.localdomain',
+ 'debian-uploader',
+ 'vae6tooZe1ec'
+ )
+
+ logger.info('FTP Login on %s successfull' %(ftp.host))
+
+ if GIT_BRANCH_NAME.startswith('master-'):
+ ftp.cwd('stable-proposed-updates')
+ else:
+ ftp.cwd('unstable-proposed-updates');
+
+ for package in glob(
+ os.path.join(GIT_TARGET_WORKSPACE, '*.deb')
+ ):
+ fh = open(package, 'rb', 1)
+ ftp.storbinary(
+ 'STOR %s' %(os.path.basename(package)),
+ fh
+ )
+ fh.close()
+ logger.info('Successfully uploaded %s' %(package))
+ ftp.quit()
logger.info('Build successfull')
logger.info('dirlist: %s' %(os.listdir(GIT_TARGET_WORKSPACE)))
exit(OK)