chiark / gitweb /
Fix init with common, don't require cwd in FDroidPopen
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 5 Nov 2013 08:26:26 +0000 (09:26 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 5 Nov 2013 08:26:56 +0000 (09:26 +0100)
fdroidserver/common.py
fdroidserver/init.py

index fd84d7c532c6e8d805019e8225d92067f1a19b94..a92ef6b9d9befafa1bab8e55586f063d8f58ad95 100644 (file)
@@ -1910,7 +1910,7 @@ class PopenResult:
     stderr = ''
     stdout_apk = ''
 
-def FDroidPopen(commands, cwd):
+def FDroidPopen(commands, cwd=None):
     """
     Runs a command the FDroid way and returns return code and output
 
@@ -1918,7 +1918,8 @@ def FDroidPopen(commands, cwd):
     """
 
     if options.verbose:
-        print "Directory: %s" % cwd
+        if cwd is not None:
+            print "Directory: %s" % cwd
         print " > %s" % ' '.join(commands)
 
     result = PopenResult()
index 37ece55ca071865088558afdb38fea628248824d..82e533ed554ca32514af1fa6c37c6791ca59eaf2 100644 (file)
@@ -29,6 +29,7 @@ import sys
 from optparse import OptionParser
 
 import common
+from common import FDroidPopen, BuildException
 
 
 config = {}
@@ -56,24 +57,21 @@ def genpassword():
 def genkey(keystore, repo_keyalias, password, keydname):
     '''generate a new keystore with a new key in it for signing repos'''
     print('Generating a new key in "' + keystore + '"...')
-    p = subprocess.Popen(['keytool', '-genkey',
-                          '-keystore', keystore, '-alias', repo_keyalias,
-                          '-keyalg', 'RSA', '-keysize', '4096',
-                          '-sigalg', 'SHA256withRSA',
-                          '-validity', '10000',
-                          '-storepass', password, '-keypass', password,
-                          '-dname', keydname],
-                         stdout=subprocess.PIPE)
-    output = p.communicate()[0]
-    print(output)
+    p = FDroidPopen(['keytool', '-genkey',
+                '-keystore', keystore, '-alias', repo_keyalias,
+                '-keyalg', 'RSA', '-keysize', '4096',
+                '-sigalg', 'SHA256withRSA',
+                '-validity', '10000',
+                '-storepass', password, '-keypass', password,
+                '-dname', keydname])
     if p.returncode != 0:
-        raise BuildException("Failed to generate key")
+        raise BuildException("Failed to generate key", p.stdout, p.stderr)
     # now show the lovely key that was just generated
     p = subprocess.Popen(['keytool', '-list', '-v',
-                          '-keystore', keystore, '-alias', repo_keyalias],
-                         stdin=subprocess.PIPE,
-                         stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE)
+                '-keystore', keystore, '-alias', repo_keyalias],
+                stdin=subprocess.PIPE,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.PIPE)
     output = p.communicate(password)[0]
     print(output.lstrip().strip() + '\n\n')