From 12565976f52c04446002e46b389d2ab52610bf3a Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 2 Nov 2011 16:57:34 +0100 Subject: [PATCH] use PB_SUITE for persistence identifier --- kernel_build.py | 2 +- kernel_inpbuilder.py | 42 ++++++++++++++++++++++++------------------ kernel_persistence.py | 23 ++++++----------------- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/kernel_build.py b/kernel_build.py index d0fecce..f9b939a 100644 --- a/kernel_build.py +++ b/kernel_build.py @@ -138,7 +138,7 @@ def exit_error(): 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(GIT_BRANCH_NAME) + 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( diff --git a/kernel_inpbuilder.py b/kernel_inpbuilder.py index 170138d..dd1386f 100644 --- a/kernel_inpbuilder.py +++ b/kernel_inpbuilder.py @@ -207,7 +207,7 @@ def git_checkout_branch(): ) return True -def build_kernel(flavour, revision, overlay_dir, parallel_jobs='auto', distcc=False): +def build_kernel(flavour, revision, overlay_dir, targets, parallel_jobs='auto', distcc=False): if parallel_jobs == 'auto': parallel_jobs = DEFAULT_PARALLEL_JOBS else: @@ -223,10 +223,7 @@ def build_kernel(flavour, revision, overlay_dir, parallel_jobs='auto', distcc=Fa '--overlay-dir', '%s' %(overlay_dir), ] # add targets - cmd += [ 'kernel_debug', 'kernel_image', 'kernel_source', 'modules' ] - - if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix'): - cmd += [ 'kernel_doc' ] + cmd += targets logger.info('start compile process for flavour %s revision %s' % (flavour, revision)) @@ -327,8 +324,6 @@ def install_extra_modules(): logger.info( 'module-assistant unpacked successfully.' ) - kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(GIT_BRANCH_NAME) - kernel_persistence.update_kernel_modules_obj(kernel_revision_obj, ' '.join(extra_modules)) return True @@ -378,19 +373,35 @@ if __name__ == '__main__': logger.error('No git new id given') exit(ERROR) + OVERLAY_DIR = options.overlay_dir or '/usr/share/kernel-package' + + # add current dir to python search path + cmd_folder = os.path.join(os.path.abspath(OVERLAY_DIR), '..') + sys.path.insert(0, cmd_folder) + os.environ['WORKSPACE']=cmd_folder # needed by kernel_persistence + import kernel_persistence + GIT_BRANCH_NAME = ( os.environ.get('GIT_BRANCH_NAME') or options.git_branch_name ) if not GIT_BRANCH_NAME: - logger.error('No git branch name given') - exit(ERROR) + # 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 + except: + logger.error('No git branch name given and no persistence for %s neither' % PB_SUITE) + exit(ERROR) + else: + kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE) + kernel_persistence.update_kernel_branch_obj(kernel_revision_obj, GIT_BRANCH_NAME)) + REVISION = os.environ.get('REVISION') or options.revision if not REVISION: logger.error('No revision given') exit(ERROR) - OVERLAY_DIR = options.overlay_dir or '/usr/share/kernel-package' GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH) GIT_REMOTE_BRANCH_NAME = os.path.join('origin', '%s' %(GIT_BRANCH_NAME)) @@ -425,19 +436,14 @@ if __name__ == '__main__': logger.debug('changing dir to %s' %(GIT_TARGET_DIR)) os.chdir(GIT_TARGET_DIR) - # add current dir to python search path - cmd_folder = os.path.join(os.path.abspath(OVERLAY_DIR), '..') - sys.path.insert(0, cmd_folder) - os.environ['WORKSPACE']=cmd_folder # needed by kernel_persistence - import kernel_persistence - + if not build_kernel(kernel_flavour, REVISION, OVERLAY_DIR, [ 'kernel_debug', 'kernel_image' ]): + 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): + if not build_kernel(kernel_flavour, REVISION, OVERLAY_DIR, [ 'modules' ]): exit(ERROR) else: try: diff --git a/kernel_persistence.py b/kernel_persistence.py index c2bb22a..2cdb743 100644 --- a/kernel_persistence.py +++ b/kernel_persistence.py @@ -33,34 +33,23 @@ class KernelVersion(Base): identifier = Column(String(255), unique=True, nullable=False) last_version = Column(Integer, nullable=False) branch_name = Column(String(255), nullable=False) - pb_modules = Column(String(255), nullable=True) def __init__(self, identifier, last_version, branch_name, pb_modules): self.identifier = identifier self.last_version = last_version self.branch_name = branch_name - self.pb_modules = pb_modules def __repr__(self): - return '' %( - self.identifier, self.last_version, self.branch_name, self.pb_modules + return '' %( + self.identifier, self.last_version, self.branch_name ) Base.metadata.create_all(engine) -def get_last_kernel_revision_obj(branch): +def get_last_kernel_revision_obj(persistence_identifier): session = Session() logger.debug('Getting kernel revision from persistence') - if branch == 'master' or branch.startswith('hotfix'): - persistence_identifier = 'master' - elif branch.startswith('release'): - persistence_identifier = 'release' - else: - # FIXME: feature branch handling - persistence_identifier = 'develop' - logger.debug('branch = %s, persistence_identifier = %s' % (branch, persistence_identifier)) - try: answ = session.query(KernelVersion).filter( KernelVersion.identifier == persistence_identifier).one() @@ -93,14 +82,14 @@ def update_kernel_revision_obj(kernel_version_obj, new_revision): finally: session.close() -def update_kernel_modules_obj(kernel_version_obj, pb_modules): +def update_kernel_branch_obj(kernel_version_obj, branch): session = Session() - kernel_version_obj.pb_modules = pb_modules + kernel_version_obj.branch_name = branch session.add(kernel_version_obj) try: session.commit() except Exception, error: - logger.error('Some error happend while commiting pb_modules') + logger.error('Some error happend while commiting branch') logger.exception(error) return False else: -- 2.39.5