]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
use PB_SUITE for persistence identifier
authorHolger Levsen <holger@layer-acht.org>
Wed, 2 Nov 2011 15:57:34 +0000 (16:57 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 2 Nov 2011 15:57:34 +0000 (16:57 +0100)
kernel_build.py
kernel_inpbuilder.py
kernel_persistence.py

index d0fecce231e6672c02c253c0960db8655fdf7a5a..f9b939a135772fecf6f630c92a7038f1d94a8ff3 100644 (file)
@@ -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(
index 170138d0b7e12764edd8b6dd9e7506ee3c38eb2f..dd1386f51465e3a9b034eb6d5758cc5c62f23ff9 100644 (file)
@@ -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:
index c2bb22aa7a67f0de7f90e9a03d64e61476ec8802..2cdb74355d3f553edde58a7f96cb129062a707af 100644 (file)
@@ -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 '<KernelVersion(identifier=\'%s\', last_version=\'%s\', branch_name=\'%s\', pb_modules=\'%s\')>' %(
-                self.identifier, self.last_version, self.branch_name, self.pb_modules
+        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(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: