[RBS] Support multiple shell commands for the same project
authorhyokeun <hyokeun.jeon@samsung.com>
Mon, 13 Aug 2018 07:38:55 +0000 (16:38 +0900)
committerYonghee Han <onstudy@samsung.com>
Thu, 31 Jan 2019 01:21:23 +0000 (10:21 +0900)
Change-Id: Iaad2d83bce3d35fbebc28a3a66d900d0c197cff5

job_create_sdkrootstrap.py

index dfbc6ee..5ade3ec 100755 (executable)
@@ -180,11 +180,20 @@ def make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_imag
     """
     Make Rootstrap snapshot(private api)
     """
+
     # checkout branch
     git_branch = profile['git_branch']
+
+    print '\n\n==========='
+    print 'CREATING ROOTSTRAP FOR'
+    print '  [%s] [%s] [%s] [%s] [%s]' \
+            % (profile.get('project'), 'PRIVATE', \
+               profile.get('git_branch'), profile.get('private_cmd'), git_branch)
+    print '===========\n'
+
     mygit.checkout(git_branch)
 
-    rs = os.path.join(git_cache, git_prj, 'make_'+profile['private_cmd']+'.sh')
+    rs = os.path.join(git_cache, git_prj, profile['private_cmd'])
     if not os.path.isfile(rs):
         print '%s is not found' % rs
         return 'failed'
@@ -216,8 +225,8 @@ def make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_imag
     # 64 bit support
     str_64_cmd = ''
     if profile.get('support_64') != 'False':
-        str_64_cmd = '$WORKDIR/$SDKIMAGE/make_%s_64.sh -u %s -b %s\n' % \
-            (profile["private_cmd"],
+        str_64_cmd = '$WORKDIR/$SDKIMAGE/%s -u %s -b %s\n' % \
+            (profile["private_cmd"].replace('.sh', '_64.sh'),
              os.path.join(profile["base_url"],profile["repo_path"],build_id),
              os.path.join(profile["base_url"],profile["base_repo_path"],'latest'))
 
@@ -226,7 +235,7 @@ def make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_imag
                'chown -R build:build $BUILDDIR\nchmod 600 $BUILDDIR/.ssh/id_rsa \n' \
                'cp -r "$BUILDDIR/.ssh/" /root/\nchmod 600 /root/.ssh/id_rsa\n' \
                'mkdir -p "$WORKDIR"\ncd "$WORKDIR"\n%s\n' \
-               '$WORKDIR/$SDKIMAGE/make_%s.sh -u %s -b %s\n' \
+               '$WORKDIR/$SDKIMAGE/%s -u %s -b %s\n' \
                '%s\n' \
                'cp -r $WORKDIR/$RS/ $BUILDDIR\n' % \
                (git_cmd,
@@ -327,9 +336,17 @@ def make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image
         git_branch = specific_branch
     else:
         git_branch = profile['git_branch']
+
+    print '\n\n==========='
+    print 'CREATING ROOTSTRAP FOR'
+    print '  [%s] [%s] [%s] [%s] [%s]' \
+            % (profile.get('project'), 'PUBLIC', \
+               profile.get('git_branch'), profile.get('public_cmd'), git_branch)
+    print '===========\n'
+
     mygit.checkout(git_branch)
 
-    rs = os.path.join(git_cache, git_prj, 'make_'+profile['public_cmd']+'.sh')
+    rs = os.path.join(git_cache, git_prj, profile['public_cmd'])
     if not os.path.isfile(rs):
         print '%s is not found' % rs
         return 'failed'
@@ -362,8 +379,8 @@ def make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image
     # 64 bit support
     str_64_cmd = ''
     if profile.get('support_64') != 'False':
-        str_64_cmd = '$WORKDIR/$SDKIMAGE/make_%s_64.sh -u %s -b %s\n' % \
-            (profile["public_cmd"],
+        str_64_cmd = '$WORKDIR/$SDKIMAGE/%s -u %s -b %s\n' % \
+            (profile["public_cmd"].replace('.sh', '_64.sh'),
              os.path.join(profile["base_url"],profile["repo_path"],build_id),
              os.path.join(profile["base_url"],profile["base_repo_path"],'latest'))
 
@@ -372,7 +389,7 @@ def make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image
                'chown -R build:build $BUILDDIR\nchmod 600 $BUILDDIR/.ssh/id_rsa \n' \
                'cp -r "$BUILDDIR/.ssh/" /root/\nchmod 600 /root/.ssh/id_rsa\n' \
                'mkdir -p "$WORKDIR"\ncd "$WORKDIR"\n%s\n' \
-               '$WORKDIR/$SDKIMAGE/make_%s.sh -u %s -b %s\n' \
+               '$WORKDIR/$SDKIMAGE/%s -u %s -b %s\n' \
                '%s\n' \
                'cp -r $WORKDIR/$RS/ $BUILDDIR\n' % \
                (git_cmd,
@@ -517,23 +534,24 @@ def main():
 
         status = 'succeeded'
         reason = 'ok'
-        #### Make Rootstrap Snapshot (PRIVATE)####
-        status = make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_image)
-
-        if status == 'succeeded':
-            print "The RBS(Internal) build was successful."
-        else:
-            print "The RBS(Internal) build was failed."
-            reason = 'RBS build fail'
-
-        try:
-            update_dashboard(fields['project'], \
-                             fields['build_id'].split('_')[-1], 
-                             status, reason,
-                             fields.get('infra', 'LOCAL')
-                             )
-        except Exception as err:
-            print repr(err)
+        if profile.get('private_cmd', 'False') != 'False':
+            #### Make Rootstrap Snapshot (PRIVATE)####
+            status = make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_image)
+
+            if status == 'succeeded':
+                print "The RBS(Internal) build was successful."
+            else:
+                print "The RBS(Internal) build was failed."
+                reason = 'RBS build fail'
+
+            try:
+                update_dashboard(fields['project'], \
+                                 fields['build_id'].split('_')[-1], 
+                                 status, reason,
+                                 fields.get('infra', 'LOCAL')
+                                 )
+            except Exception as err:
+                print repr(err)
 
         status = 'succeeded'
         #### Make Rootstrap Snapshot (PUBLIC)####