+++ /dev/null
-Source: =ST-source-=V
-Section: devel
-Priority: optional
-Maintainer: =M
-Build-Depends: po-debconf, gettext, file
-Standards-Version: 3.5.9.0
-
-Package: =ST-headers-=V
-Architecture: any
-Depends: ${shlibs:Depends}
-Section: devel
-Priority: optional
-Recommends: libc6-dev | libc-dev, gcc | c-compiler, make (>= 3.80-10), binutils (>= 2.12), util-linux (>= 2.10o)
-Suggests: module-init-tools (>= 0.9.10), e2fsprogs (>= 1.29)
-Provides: =ST-headers, =ST-headers-=CV, =ST-headers-PB_FLAVOUR
-Description: Header files related to Linux kernel, specifically,
- version =V
- .
- This package provides kernel header files for sites
- that want the latest kernel headers for version
- =V.
- Please read
- /usr/share/doc/=ST-headers-=V/debian.README.gz
- for details
-
-Package: =ST-source-=V
-Architecture: all
-Section: devel
-Priority: optional
-Provides: =ST-source, =ST-source-=CV, =ST-source-PB_FLAVOUR
-Depends: binutils, bzip2, file
-Recommends: libc6-dev | libc-dev, gcc | c-compiler, make (>= 3.80-10), po-debconf, gettext, binutils (>= 2.12), util-linux (>= 2.10o), module-init-tools (>= 0.9.10), debianutils (>= 2.30)
-Suggests: libncurses-dev | ncurses-dev, kernel-package, xmlto, libdb3-dev, libncurses-dev, docbook-utils, e2fsprogs (>= 1.29), linux-initramfs-tool, ksymoops
-Description: Linux kernel source for version =V
- This package provides the source code for the Linux kernel, specifically,
- version =V.
- .
- You may configure the kernel to your setup by typing "make config"
- and following instructions, but you could get ncursesX.X-dev and try
- "make menuconfig" for a jazzier, and easier to use interface. There
- are options to use QT or GNOME based configuration interfaces, but they
- need additional packages to be installed. Also, please read the detailed
- documentation in the file README.headers.gz in the documentation directory
- /usr/share/doc/=ST-source-=V/.
- .
- If you wish to use this package to create a custom Linux kernel, then
- it is suggested that you investigate the package kernel-package,
- which has been designed to ease the task of creating kernel image
- packages.
-
-Package: =ST-image-=V=SA
-Architecture: =A
-Section: kernel
-Priority: optional
-Provides: =ST-image, =ST-image-=CV, =ST-image-PB_FLAVOUR
-Pre-Depends: debconf (>= 0.2.17) | debconf-2.0
-Depends: =I coreutils (>= 5.96)
-Suggests: fdutils, =ST-doc-=V=SA | =ST-source-=V, ksymoops, =ST-image-=V=SA-dbg
-Description: Linux kernel binary image for version =V=SA
- This package contains the Linux kernel image for version
- =V=SA.
- .
- It also contains the corresponding System.map file, and the modules
- built by the packager. It also contains scripts that try to ensure
- that the system is not left in a unbootable state after an update.
- .
- Kernel image packages are generally produced using kernel-package,
- and it is suggested that you install that package if you wish to
- create a custom kernel from the sources. Please look at kernel-img.conf(5),
- and /usr/share/doc/kernel-package/README.gz from the package kernel-package
- for details on how to tailor the installation of this or any other kernel
- image package
-
-Package: =ST-image-=V=SA-dbg
-Architecture: =A
-Section: debug
-Priority: optional
-Depends: =ST-image-=V=SA
-Provides: =ST-debug, =ST-debug-=CV, =ST-debug-=V=SA, =ST-image-PB_FLAVOUR-debug
-Suggests: systemtap
-Description: Linux kernel debug image for version =V=SA
- This package contains the Linux kernel debug image for version
- =V=SA.
- This means the debugging information for the modules in the kernel
- image package, and the uncompressed vmlinux image; it is not intended
- to be bootable. This is useful for debugging the Linux kernel.
-
-
-Package: =ST-doc-=V
-Architecture: all
-Section: doc
-Priority: optional
-Provides: =ST-doc-=CV
-Suggests: =ST-image-=V=SA
-Description: Linux kernel specific documentation for version =V
- This package provides various Readme's in the =V
- kernel Documentation/ subdirectory: these typically contain
- kernel-specific installation notes for some drivers. for
- example. Please see
- /usr/share/doc/=ST-doc-X.X.XX/Documentation/00-INDEX
- for a list of contents. Please also read the Changes file, as it
- contains information about the problems which may result by upgrading
- your kernel.
-
-Package: =ST-manual-=V
-Architecture: all
-Section: doc
-Priority: optional
-Provides: =ST-manual-=CV
-Conflicts: =ST-manual-=CV
-Suggests: =ST-image-=V=SA
-Description: Linux kernel section 9 manual pages for version =V
- This package provides various Section 9 manual pages included with the kernel.
-
-Package: =ST-uml-=V=SA
-Architecture: =A
-Section: utils
-Priority: optional
-Provides: =ST-uml, =ST-uml-=CV, user-mode-linux
-Depends: =I coreutils (>= 5.96) | fileutils (>= 4.0)
-Suggests: fdutils, kernel-doc-=V=SA | kernel-source-=V, uml-utilities
-Conflicts: user-mode-linux (<= 2.6)
-Replaces: user-mode-linux (<= 2.6)
-Description: Linux uml kernel binary image for version =V=SA
- This package contains the Linux uml kernel image for version =V=SA
- and the modules built by the packager.
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import os
-import re
-import sys
-import atexit
-import shutil
-import subprocess
-import logging
-from glob import glob
-from logging import Formatter
-import kernel_persistence
-import urllib
-
-CWD = os.environ.get('WORKSPACE')
-BUILD_NUMBER = os.environ.get('BUILD_NUMBER')
-BUILD_ID = os.environ.get('BUILD_ID')
-BUILD_URL = os.environ.get('BUILD_URL')
-
-GIT_REPO_PATH = os.environ.get('GIT_REPO_PATH')
-GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH)
-GIT_BRANCH_NAME = os.environ.get('GIT_BRANCH_NAME')
-
-GIT_COMMITTER_EMAIL = os.environ.get('GIT_COMMITTER_EMAIL')
-
-PBUILDER = '/usr/sbin/pbuilder'
-SUDO = '/usr/bin/sudo'
-
-env = os.environ
-PB_SUITE = os.environ.get('DISTRIBUTION')
-if PB_SUITE == 'production':
- PB_SUITE = 'production-proposed-updates'
-env['PB_SUITE'] = PB_SUITE
-
-# FIXME: move this into own logger Class
-logger = logging.getLogger(sys.argv[0])
-logger.setLevel(logging.DEBUG)
-stream_handler = logging.StreamHandler()
-stream_handler.setLevel(logging.DEBUG)
-formatter = Formatter('%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s')
-stream_handler.setFormatter(formatter)
-logger.addHandler(stream_handler)
-
-
-def build_kernel_with_pbuilder(revision, pbuilder_script, dist='stable'):
- pbuilder_script = os.path.join(sys.path[0],pbuilder_script)
-
- cmd = [
- SUDO,
- PBUILDER,
- '--execute',
- '--hookdir', '""',
- '--bindmounts', '"/srv/git %s /var/lib/jenkins/jenkins_build_script/"' % (os.path.join(CWD,'..')),
- '--',
- pbuilder_script,
- '--cwd', '%s' %('/tmp'),
- '--build-number', '%s' %(BUILD_NUMBER),
- '--build-id', '%s' %(BUILD_ID),
- '--build-url', '%s' %(BUILD_URL),
- '--git-repo-path', '%s' %(GIT_REPO_PATH),
- '--git-repo-name', '%s' %(GIT_REPO_NAME),
- '--git-branch-name', '%s' %(GIT_BRANCH_NAME),
- '--revision', '%s' %(revision),
- '--dist', '%s' %(dist),
- '--overlay-dir', '/var/lib/jenkins/jenkins_build_script/develop/kernel-package-overlay',
- ]
-
- os.environ.update({'DIST': '%s' %(dist)})
-
- cmdobj = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- env=os.environ
- )
-
- logger.info('calling "%s" ...', ' '.join(cmd))
- ret = os.system('%s' %(' '.join(cmd)))
- if ret:
- logger.error(
- '"%s" returned non-zero (exitcode was: %s).',
- ' '.join(cmd),
- ret,
- )
- return False
-
- logger.info(
- '"%s" returned zero.', ' '.join(cmd))
- return True
-
-def remove_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():
- sys.exit(0)
-
-def exit_error():
- sys.exit(1)
-
-if __name__ == '__main__':
- logger.debug('running with this enviroment: %s', os.environ)
- atexit.register(remove_git_target_workspace)
-
- kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE)
- new_version = kernel_revision_obj.last_version + 1
- if not kernel_persistence.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()
-
- if not build_kernel_with_pbuilder(
- new_version, 'kernel_inpbuilder.py',
- dist='stable'):
- exit_error()
-
- exit_ok()
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import os
-import re
-import sys
-import git
-import shutil
-import subprocess
-import logging
-import platform
-import optparse
-from glob import glob
-from logging import Formatter
-from ftplib import FTP
-from multiprocessing import cpu_count
-
-__version__ = '0.0.2'
-
-GIT = '/usr/bin/git'
-MAKE_KPKG = '/usr/bin/make-kpkg'
-APT_GET = '/usr/bin/apt-get'
-
-DEFAULT_PARALLEL_JOBS = cpu_count() + 1
-
-BUILD_ARCH_MAP = {
- 'x86_64': 'amd64',
- 'i386': '686'
-}
-
-BUILD_ARCH = BUILD_ARCH_MAP.get(platform.machine(), '686')
-CREG_KERNEL_CONFIG_DELIM = re.compile(ur'\s*=\s*')
-ERROR = 1
-OK = 0
-
-def getopts():
- usage = '%prog [options]'
- parser = optparse.OptionParser(
- usage=usage,
- version='%prog ' + __version__
- )
-
- parser.add_option(
- '--cwd',
- dest='cwd',
- default='/tmp',
- metavar='CWD',
- help='Set the current working dir. Default: %default'
- )
-
- parser.add_option(
- '--build-number',
- dest='build_number',
- default=None,
- metavar='BUILD_NUMBER',
- help='Set the Build number. Default: %default'
- )
-
- parser.add_option(
- '--build-id',
- dest='build_id',
- default=None,
- metavar='BUILD_ID',
- help='Set the Build Id. Default: %default'
- )
-
- parser.add_option(
- '--build-url',
- dest='build_url',
- default=None,
- metavar='BUILD_URL',
- help='Set the Build Url. Default: %default'
- )
-
- parser.add_option(
- '--git-repo-path',
- dest='git_repo_path',
- default=None,
- metavar='GIT_REPO_PATH',
- help='Set the Git Repo Path. Default: %default'
- )
-
- parser.add_option(
- '--git-repo-name',
- dest='git_repo_name',
- default=None,
- metavar='GIT_REPO_NAME',
- help='Set the Git Repo Name. Default: %default'
- )
-
- parser.add_option(
- '--git-branch-name',
- dest='git_branch_name',
- default=None,
- metavar='GIT_BRANCH_NAME',
- help='Set the Name of the branch. Default: %default'
- )
-
- parser.add_option(
- '--revision',
- dest='revision',
- default=None,
- metavar='REVISION',
- help='Set the Revision. Default: %default'
- )
-
- parser.add_option(
- '--dist',
- dest='dist',
- default='stable',
- metavar='DIST',
- help='Set the distribution. Default: %default'
- )
-
- parser.add_option(
- '--overlay-dir',
- dest='overlay_dir',
- default=None,
- metavar='OVERLAY_DIR',
- help='Set the overlay-dir for make-kpkg Default: %default'
- )
-
- return parser.parse_args()
-
-def git_clone_remote_repository(url, destination):
- if os.path.exists(destination):
- logger.debug('%s allready exists' %(destination))
- if os.path.isdir(destination):
- shutil.rmtree(destination)
- else:
- os.unlink(destination)
- logger.debug('%s deleted' %(destination))
-
- cmd = [GIT, 'clone', '%s' %(url), '%s' %(destination)]
- cmdobj = subprocess.Popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=False,
- env={'':''},
- cwd=CWD,
- close_fds=True
- )
-
- logger.info('begin to clone git repo from %s' %(url))
- logger.debug(
- 'calling »%s« for cloning git repo' %(' '.join(cmd))
- )
- ret = cmdobj.wait()
-
- if ret:
- logger.error('%s returned with %s' %(' '.join(cmd), ret))
- logger.error('Error was: %s' %(cmdobj.stderr.readlines()))
- return False
- logger.debug('repository %s checked out into %s' %(url, destination))
- return True
-
-def git_checkout_branch():
- if GIT_BRANCH_NAME == "master":
- cmd = [GIT, 'checkout', GIT_REMOTE_BRANCH_NAME]
- else:
- cmd = [GIT, 'checkout', '-b', GIT_BRANCH_NAME, GIT_REMOTE_BRANCH_NAME]
-
- cmdobj = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stderr=subprocess.PIPE,
- stdout=subprocess.PIPE,
- env={'':''},
- cwd=GIT_TARGET_DIR
- )
-
- logger.info(
- 'checking out local branch %s from remote branch %s'
- %(GIT_BRANCH_NAME, GIT_REMOTE_BRANCH_NAME)
- )
-
- logger.debug(
- 'calling »%s« for checkout' %(' '.join(cmd))
- )
-
- ret = cmdobj.wait()
- if ret:
- logger.error('%s returned with %s' %(' '.join(cmd), ret))
- logger.error('Error was: %s' %(cmdobj.stderr.readlines()))
- return False
- logger.info(
- 'local branch %s successfully checked out.' %(GIT_BRANCH_NAME)
- )
- return True
-
-def build_kernel(flavour, revision, overlay_dir, targets, parallel_jobs='auto', distcc=False):
- if parallel_jobs == 'auto':
- parallel_jobs = DEFAULT_PARALLEL_JOBS
- else:
- parallel_jobs = int(parallel_jobs)
-
- # modify overlay-dir/Control on the fly
- os.system("sed -i -s 's#PB_FLAVOUR#%s#' %s/Control" % (flavour, overlay_dir))
-
- cmd = [MAKE_KPKG, '-j', '%s' %(parallel_jobs), '--arch',
- '%s' %(BUILD_ARCH), '--rootcmd', 'fakeroot',
- '--append-to-version', '-%s' %(flavour),
- '--initrd', '--arch_in_name',
- '--overlay-dir', '%s' %(overlay_dir),
- ]
- # add targets
- cmd += targets
-
- logger.info('start compile process for flavour %s revision %s' % (flavour, revision))
-
- logger.debug(
- 'calling "%s" for compiling the kernel' %(' '.join(cmd))
- )
-
- os.putenv('LOCALVERSION', '')
- os.environ['LOCALVERSION'] = ''
- if distcc:
- os.environ['MAKEFLAGS'] = 'CC=distcc'
- os.putenv('MAKEFLAGS', 'CC=distcc')
-
- ret = os.system('%s' %(' '.join(cmd)))
-
- if ret:
- logger.error('%s returned with %s' %(' '.join(cmd), ret))
- return False
- logger.info(
- 'kernel successfully compiled.'
- )
- return True
-
-def read_file(path):
- try:
- fh = open(path, 'r', 1)
- except:
- raise
- else:
- result = dict(enumerate(fh))
- fh.close()
- return result
-
-def create_file(path,data):
- try:
- fh = open(path, 'w', 1)
- fh.write(data)
- fh.close()
- return True
- except:
- raise
-
-def determine_kernel_flavour():
- pb_version_path = os.path.join(GIT_TARGET_DIR, 'pb_version')
- if not os.path.exists(pb_version_path):
- pb_version = '0'
- else:
- fh = open(pb_version_path)
- pb_version = fh.readline().rstrip()
- fh.close()
-
- # strip the first 6 characters ("linux-") and the last 4 (".git")
- flavour = GIT_REPO_NAME[6:-4]
-
- # slightly different version numbers per branch
- if GIT_BRANCH_NAME == 'master':
- debian_version = '$(version)-%s+%s' % (pb_version, REVISION)
- elif GIT_BRANCH_NAME.startswith('release/') or GIT_BRANCH_NAME.startswith('hotfix'):
- debian_version = '$(version)-%s~rc%s' % (pb_version, REVISION)
- elif GIT_BRANCH_NAME == 'experimental':
- debian_version = '$(version)-%s~experimental%s' % (pb_version, REVISION)
- else:
- debian_version = '$(version)-%s~develop%s' % (pb_version, REVISION)
-
- # create appropriate /etc/kernel-pkg.conf
- content = 'maintainer := Profitbricks GmbH\nemail := support@profitbricks.com\npriority := Low\ndebian = %s\n' % (debian_version)
- create_file('/etc/kernel-pkg.conf', content)
- logger.info('/etc/kernel-pkg.conf created with this content: \n%s' % content)
-
- # return safely
- kernel_flavour = 'profitbricks-%s' % flavour
- return kernel_flavour
-
-def exit(retcode):
- logger.info('Exit with %s', retcode)
- sys.exit(retcode)
-
-def has_extra_modules():
- return os.path.exists(EXTRA_MODULES_PATH)
-
-def install_extra_modules():
- cmd = [APT_GET, 'update']
- subprocess.check_call(cmd)
-
- fh = open(EXTRA_MODULES_PATH, 'r', 1)
- extra_modules = map(lambda x: x.rstrip(), fh)
- fh.close()
-
- os.system('apt-get update')
- if extra_modules:
- cmd = [APT_GET, '-y', 'install']
- cmd += extra_modules
- subprocess.check_call(cmd)
-
- cmd = ['m-a', 'unpack']
- cmd += extra_modules
- ret = os.system('%s' %(' '.join(cmd)))
- if ret:
- logger.error('%s returned with %s' %(' '.join(cmd), ret))
- return False
- logger.info(
- 'module-assistant unpacked successfully.'
- )
- # FIXME: should also do:
- # sed -i -s "s#^Provides: $OOT_MODULE-modules#Provides: $OOT_MODULE-modules, $OOT_MODULE-modules-profitbrick-$PB_FLAVOUR#g" modules/$OOT_MODULE/debian/control.modules.in
- # use os.system("sed -i -s ...")
-
- return True
-
-
-if __name__ == '__main__':
- logger = logging.getLogger(sys.argv[0])
- logger.setLevel(logging.DEBUG)
- stream_handler = logging.StreamHandler(sys.stdout)
- stream_handler.setLevel(logging.DEBUG)
- formatter = Formatter('%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s')
- stream_handler.setFormatter(formatter)
- logger.addHandler(stream_handler)
-
- options, args = getopts()
- logger.debug('running with this enviroment: %s', os.environ)
-
- CWD = os.environ.get('WORKSPACE') or options.cwd
- if not CWD:
- logger.info('No CWD given - using "/tmp" as CWD')
- CWD = '/tmp'
-
- BUILD_NUMBER = os.environ.get('BUILD_NUMBER') or options.build_number
- if not BUILD_NUMBER:
- logger.error('No build number given')
- exit(ERROR)
-
- BUILD_ID = os.environ.get('BUILD_ID') or options.build_id
- if not BUILD_ID:
- logger.error('No build id given')
- exit(ERROR)
-
- # FIXME: Do we realy need BUILD_URL here?
- BUILD_URL = os.environ.get('BUILD_URL') or options.build_url
-
- GIT_REPO_PATH = os.environ.get('GIT_REPO_PATH') or options.git_repo_path
- if not GIT_REPO_PATH:
- logger.error('No git repo path given')
- exit(ERROR)
-
- OVERLAY_DIR = options.overlay_dir or '/usr/share/kernel-package'
-
- # add directory where current script is in to python search path
- cmd_folder = os.path.join(OVERLAY_DIR,'..')
- sys.path.insert(0, cmd_folder)
- logger.info('cmd_folder = %s' % cmd_folder)
- os.environ['WORKSPACE']=cmd_folder # needed by kernel_persistence
- import kernel_persistence
- from lib import git_helper
-
- PB_SUITE = os.environ.get('PB_SUITE')
-
- update_kernel_branch = False
- GIT_BRANCH_NAME = (
- os.environ.get('GIT_BRANCH_NAME') or options.git_branch_name
- )
- if not GIT_BRANCH_NAME:
- # try to get it from persistence
- try:
- kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE)
- GIT_BRANCH_NAME=kernel_revision_obj.branch_name
- except:
- logger.error('No git branch name given and no persistence for %s neither' % PB_SUITE)
- exit(ERROR)
- else:
- update_kernel_branch = True
-
- REVISION = os.environ.get('REVISION') or options.revision
- if not REVISION:
- logger.error('No revision given')
- exit(ERROR)
-
- GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH)
- 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')
-
- EXTRA_MODULES_PATH = os.path.join(GIT_TARGET_DIR, 'pb_modules')
-
- if git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
- logger.info('git clone was successful')
- else:
- logger.info('git clone was not successful')
- exit(ERROR)
-
- if not git_checkout_branch():
- exit(ERROR)
-
- kernel_flavour = determine_kernel_flavour()
- logger.info('REVISION = %s, kernel_flavour = %s' %(REVISION,kernel_flavour))
-
- logger.debug('changing dir to %s' %(GIT_TARGET_DIR))
- os.chdir(GIT_TARGET_DIR)
-
- if update_kernel_branch:
- # save commit id in persistence so we can get it from there if triggered without a branch name
- kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE)
- kernel_persistence.update_kernel_branch_obj(kernel_revision_obj, git_helper.git_get_commit_id())
-
- # update changelog
- cmd = 'sed -i -e \'s#DUMMY_ENTRY#%s#\' -e \'s#DUMMY_DATE#%s#\' %s' % (git_helper.git_get_commit_id(),git_helper.git_get_commit_date(),os.path.join(OVERLAY_DIR,'changelog'))
- logger.info('Running %s' % cmd)
- os.system(cmd)
-
- if not build_kernel(kernel_flavour, REVISION, OVERLAY_DIR, [ 'kernel_image', 'kernel_source', 'kernel_debug' ]):
- exit(ERROR)
- if has_extra_modules():
- if not install_extra_modules():
- logger.error('Error during installation of extra kernel modules')
- exit(ERROR)
- if not build_kernel(kernel_flavour, REVISION, OVERLAY_DIR, [ 'modules' ]):
- exit(ERROR)
-
- try:
- ftp = FTP(
- 'alexandria.profitbricks.localdomain',
- 'debian-uploader',
- 'vae6tooZe1ec'
- )
- except:
- logger.error('Cannot login via ftp...')
- exit(ERROR)
-
- ftp.cwd('/srv/profitbricks-repository/incoming')
-
- logger.info('FTP Login on %s successful' %(ftp.host))
-
- if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/'):
- ftp.cwd('production-proposed-updates')
- elif GIT_BRANCH_NAME == 'experimental':
- ftp.cwd('experimental');
- else:
- ftp.cwd('pre-staging');
- logger.info('FTP working directory: %s' %(ftp.pwd()))
-
- 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 successful')
- logger.info('dirlist: %s' %(os.listdir(GIT_TARGET_WORKSPACE)))
-
- exit(OK)
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import os
-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
-import logging
-from logging import Formatter
-import sys
-
-CWD = os.environ.get('WORKSPACE')
-PERSISTENCE_FILE = os.path.join(CWD, '..', '.persistence')
-
-Base = declarative_base()
-engine = create_engine('sqlite:///%s' %(PERSISTENCE_FILE))
-Session = sessionmaker(bind=engine)
-
-# FIXME: move this into own logger Class
-logger = logging.getLogger(sys.argv[0])
-logger.setLevel(logging.DEBUG)
-stream_handler = logging.StreamHandler()
-stream_handler.setLevel(logging.DEBUG)
-formatter = Formatter('%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s')
-stream_handler.setFormatter(formatter)
-logger.addHandler(stream_handler)
-
-class KernelVersion(Base):
- __tablename__ = 'branch_kernel_version'
- id = Column(Integer, Sequence('identifier_id'), primary_key=True)
- identifier = Column(String(255), unique=True, nullable=False)
- last_version = Column(Integer, nullable=False)
- branch_name = Column(String(255), nullable=False)
-
- def __init__(self, identifier, last_version, branch_name):
- self.identifier = identifier
- self.last_version = last_version
- self.branch_name = branch_name
-
- def __repr__(self):
- return '<KernelVersion(identifier=\'%s\', last_version=\'%s\', branch_name=\'%s\')>' %(
- self.identifier, self.last_version, self.branch_name
- )
-
-Base.metadata.create_all(engine)
-
-def get_last_kernel_revision_obj(persistence_identifier):
- session = Session()
- logger.debug('Getting kernel revision from persistence')
-
- try:
- answ = session.query(KernelVersion).filter(
- KernelVersion.identifier == persistence_identifier).one()
- except NoResultFound:
- session.add(KernelVersion(persistence_identifier, 0, ''))
- session.commit()
- answ = session.query(KernelVersion).filter(
- KernelVersion.identifier == persistence_identifier).one()
- finally:
- session.close()
-
- logger.info(
- 'Got this Kernel revision for persistence_identifier %s for file %s: %s'
- %(persistence_identifier, PERSISTENCE_FILE, answ)
- )
- return answ
-
-def update_kernel_revision_obj(kernel_version_obj, new_revision):
- session = Session()
- kernel_version_obj.last_version = new_revision
- session.add(kernel_version_obj)
- try:
- session.commit()
- except Exception, error:
- logger.error('Some error happend while commiting new revision')
- logger.exception(error)
- return False
- else:
- return True
- finally:
- session.close()
-
-def update_kernel_branch_obj(kernel_version_obj, branch):
- session = Session()
- kernel_version_obj.branch_name = branch
- session.add(kernel_version_obj)
- try:
- session.commit()
- except Exception, error:
- logger.error('Some error happend while commiting branch')
- logger.exception(error)
- return False
- else:
- return True
- finally:
- session.close()