Do not append studio version
[scm/meta/abs.git] / abs
diff --git a/abs b/abs
index 28363af..8076924 100755 (executable)
--- a/abs
+++ b/abs
@@ -108,7 +108,7 @@ class ErrorParser(object):
                                     '.*make.*: \*\*\* .*', \
                                     '.*make.*: Target (.*) not remade because of errors.', \
                                     '.*[Cc]ommand not found.*', \
-                                    'Error:\s*(.*)'], \
+                                    '^Error:\s*(.*)'], \
                        'TIZEN_NATIVE':['.*ninja: build stopped.*', \
                                        'edje_cc: Error..(.*):(\d).*', \
                                        'edje_cc: Error.*']}
@@ -158,12 +158,12 @@ class _Rootstrap(object):
         cmdline = self.tizen + ' list rootstrap'
         ret = Executor().run(cmdline, show=False)
         for x in ret.splitlines():
-            if re.search('(%s)-(2.4|3.0|4.0|5.0|5.5)-(device|emulator|device64|emulator64).core.*' % rs_prefix, x):
+            if re.search('(%s)-([0-9.]*)-(device.*|emulator.*).core.*' % rs_prefix, x):
                 if self.rootstrap_list == None:
                     self.rootstrap_list = []
                 self.rootstrap_list.append(x.split(' ')[0])
             else:
-                print 'No search result for %s' % '(%s)-(2.4|3.0|4.0|5.0|5.5)-(device|emulator|device64|emulator64).core.*' % rs_prefix
+                print 'No search result for %s' % '(%s)-([0-9.]*)-(device.*|emulator.*).core.*' % rs_prefix
         return self.rootstrap_list
 
     def check_rootstrap(self, rootstrap, show=True):
@@ -248,8 +248,11 @@ class Sdk(object):
         """Run a tizen command"""
 
         cmd = [self.tizen, command] + args
+        if command == 'package':
+            cmd = ['dbus-run-session -- bash; echo build | gnome-keyring-daemon --unlock; '] + cmd
         print '\nRunning command:\n    %s' % ' '.join(cmd)
-        return self.runtool.run(' '.join(cmd), show=show, checker=checker)
+        return self.runtool.run('{}'.format(' '.join(cmd)), \
+                show=show, checker=checker)
 
     def copytree2(self, src, dst, symlinks=False, ignore=None):
         """Copy with Ignore & Overwrite"""
@@ -394,6 +397,17 @@ class Sdk(object):
             if ret:
                 raise LocalError(ret)
 
+    def raise_package_exception(self, out, output_dir, i, bname, appname):
+        logpath = os.path.join(output_dir, \
+                              'package_%d_%s' % (i, bname))
+        if not os.path.isdir(output_dir):
+            os.makedirs(output_dir)
+        with open(logpath + '.log', 'w') as lf:
+            lf.write(out)
+        if 'keystore password was incorrect' in out:
+            raise LocalError('keystore password was incorrect for %s.' % appname)
+        raise LocalError('TPK/WGT file not generated for %s.' % appname)
+
     def package(self, source, cert=None, pkg_type=None, conf='Debug', manual_strip=False):
         """SDK CLI package command
             IF Debug + Manual Strip off then generate package-name-debug.tpk
@@ -422,6 +436,7 @@ class Sdk(object):
 
         # Manual strip
         if manual_strip == True :
+            main_args.extend(['--strip', 'on'])
             strip_cmd='';
             if self.arch == None:
                 raise LocalError('Architecture is None')
@@ -478,7 +493,7 @@ class Sdk(object):
                     try:
                         final_app = list_files(os.path.join(x['path'], conf), ext='tpk')[0]
                     except:
-                        raise LocalError('TPK file not generated for %s.' % x['APPNAME'])
+                        self.raise_package_exception(out, source.output_dir, i, os.path.basename(x['path']), x['APPNAME'])
                     x['out_package'] = final_app
                 elif x['type'] == 'sharedLib':
                     self._package_sharedlib(x['path'], conf, x['APPNAME'])
@@ -492,7 +507,7 @@ class Sdk(object):
                 try:
                     final_app = list_files(os.path.join(x['path'], '.buildResult'), ext='wgt')[0]
                 except:
-                    raise LocalError('WGT file not generated for %s.' % x['APPNAME'])
+                    self.raise_package_exception(out, source.output_dir, i, os.path.basename(x['path']), x['APPNAME'])
                 x['out_package'] = final_app
 
         if source.b_multi == True:
@@ -506,20 +521,20 @@ class Sdk(object):
 
             extra_args.extend(['--', '"%s"' % final_app])
             if final_app.endswith('.tpk'):
-                out = self._run('package', main_args + extra_args)
+                out = '%s\n\n%s' % (out, self._run('package', main_args + extra_args))
             elif final_app.endswith('.wgt'):
-                out = self._run('package', main_args_web + extra_args)
+                out = '%s\n\n%s' % (out, self._run('package', main_args_web + extra_args))
 
         #TODO: signature validation check failed : Invalid file reference. An unsigned file was found.
         if final_app.endswith('.tpk'):
             print 'Packaging final step again!'
-            out = self._run('package', main_args + ['--', '"%s"' % final_app])
+            out = '%s\n\n%s' % (out, self._run('package', main_args + ['--', '"%s"' % final_app]))
 
         #Append arch to web binary
-        if final_app.endswith('.wgt'):
-            final_app_with_arch = final_app.replace('.wgt', '-%s.wgt' % self.arch)
-            os.rename(final_app, final_app_with_arch)
-            final_app = final_app_with_arch
+        #if final_app.endswith('.wgt'):
+        #    final_app_with_arch = final_app.replace('.wgt', '-%s.wgt' % self.arch)
+        #    os.rename(final_app, final_app_with_arch)
+        #    final_app = final_app_with_arch
 
         #Copy tpk to output directory
         if conf == 'Debug' and manual_strip == False :
@@ -533,6 +548,7 @@ class Sdk(object):
         else :
             shutil.copy(final_app, source.output_dir)
 
+
     def clean(self, source):
         """SDK CLI clean command"""
 
@@ -703,4 +719,6 @@ if __name__ == '__main__':
             os.makedirs('_abs_out_')
         with open(os.path.join('_abs_out_', 'build_EXCEPTION.log'), 'w') as ef:
             ef.write('Exception %s' % repr(e))
-        sys.exit(1)
+        if 'keystore password was incorrect' in repr(e):
+            sys.exit(99)
+        sys.exit(77)