if not os.path.exists(src):
raise BuildException("Unsigned apk is not at expected location of " + src)
- p = subprocess.Popen([os.path.join(config['sdk_path'],
+ p = FDroidPopen([os.path.join(config['sdk_path'],
'build-tools', config['build_tools'], 'aapt'),
- 'dump', 'badging', src],
- stdout=subprocess.PIPE)
- output = p.communicate()[0]
+ 'dump', 'badging', src])
vercode = None
version = None
foundid = None
- for line in output.splitlines():
+ for line in p.stdout.splitlines():
if line.startswith("package:"):
pat = re.compile(".*name='([a-zA-Z0-9._]*)'.*")
m = pat.match(line)
if p.returncode != 0 or not git_rev:
# Try a plain git checkout as a last resort
- p = subprocess.Popen(['git', 'checkout', rev], cwd=self.local)
+ p = FDroidPopen(['git', 'checkout', rev], cwd=self.local)
if p.returncode != 0:
raise VCSException("No git treeish found and direct git checkout failed")
else:
if subprocess.call(['hg', 'update', '-C', rev],
cwd=self.local) != 0:
raise VCSException("Hg checkout failed")
- p = subprocess.Popen(['hg', 'purge', '--all'], stdout=subprocess.PIPE,
- cwd=self.local)
- result = p.communicate()[0]
+ p = FDroidPopen(['hg', 'purge', '--all'], cwd=self.local)
# Also delete untracked files, we have to enable purge extension for that:
- if "'purge' is provided by the following extension" in result:
+ if "'purge' is provided by the following extension" in p.stdout:
with open(self.local+"/.hg/hgrc", "a") as myfile:
myfile.write("\n[extensions]\nhgext.purge=\n")
if subprocess.call(['hg', 'purge', '--all'], cwd=self.local) != 0:
raise VCSException("HG purge failed")
def gettags(self):
- p = subprocess.Popen(['hg', 'tags', '-q'],
- stdout=subprocess.PIPE, cwd=self.local)
- return p.communicate()[0].splitlines()[1:]
+ p = FDroidPopen(['hg', 'tags', '-q'], cwd=self.local)
+ return p.stdout.splitlines()[1:]
class vcs_bzr(vcs):
raise VCSException("Bzr revert failed")
def gettags(self):
- p = subprocess.Popen(['bzr', 'tags'],
- stdout=subprocess.PIPE, cwd=self.local)
+ p = FDroidPopen(['bzr', 'tags'], cwd=self.local)
return [tag.split(' ')[0].strip() for tag in
- p.communicate()[0].splitlines()]
+ p.stdout.splitlines()]
def retrieve_string(xml_dir, string):
if string.startswith('@string/'):
:param apkfile: full path to the apk to check"""
- p = subprocess.Popen([os.path.join(config['sdk_path'],
+ p = FDroidPopen([os.path.join(config['sdk_path'],
'build-tools', config['build_tools'], 'aapt'),
- 'dump', 'xmltree', apkfile, 'AndroidManifest.xml'],
- stdout=subprocess.PIPE)
- output = p.communicate()[0]
+ 'dump', 'xmltree', apkfile, 'AndroidManifest.xml'])
if p.returncode != 0:
logging.critical("Failed to get apk manifest information")
sys.exit(1)
- for line in output.splitlines():
+ for line in p.stdout.splitlines():
if 'android:debuggable' in line and not line.endswith('0x0'):
return True
return False
if cwd:
logging.info("Directory: %s" % cwd)
- logging.info(" > %s" % ' '.join(commands))
+ logging.info("> %s" % ' '.join(commands))
result = PopenResult()
p = subprocess.Popen(commands, cwd=cwd,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ stdin=subprocess.PIPE)
stdout_queue = Queue.Queue()
stdout_reader = AsynchronousFileReader(p.stdout, stdout_queue)
import re
import shutil
import socket
-import subprocess
import sys
from optparse import OptionParser
if p.returncode != 0:
raise BuildException("Failed to generate key", p.stdout)
# 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)
+ p = FDroidPopen(['keytool', '-list', '-v',
+ '-keystore', keystore, '-alias', repo_keyalias])
output = p.communicate(password)[0]
print(output.lstrip().strip() + '\n\n')
import sys
import os
import shutil
-import subprocess
import md5
import glob
from optparse import OptionParser
import common, metadata
-from common import BuildException
+from common import FDroidPopen, BuildException
config = None
options = None
# See if we already have a key for this application, and
# if not generate one...
- p = subprocess.Popen(['keytool', '-list',
+ p = FDroidPopen(['keytool', '-list',
'-alias', keyalias, '-keystore', config['keystore'],
- '-storepass', config['keystorepass']], stdout=subprocess.PIPE)
- output = p.communicate()[0]
+ '-storepass', config['keystorepass']])
if p.returncode !=0:
print "Key does not exist - generating..."
- p = subprocess.Popen(['keytool', '-genkey',
+ p = FDroidPopen(['keytool', '-genkey',
'-keystore', config['keystore'], '-alias', keyalias,
'-keyalg', 'RSA', '-keysize', '2048',
'-validity', '10000',
'-storepass', config['keystorepass'],
'-keypass', config['keypass'],
- '-dname', config['keydname']], stdout=subprocess.PIPE)
- output = p.communicate()[0]
- print output
+ '-dname', config['keydname']])
if p.returncode != 0:
raise BuildException("Failed to generate key")
# Sign the application...
- p = subprocess.Popen(['jarsigner', '-keystore', config['keystore'],
+ p = FDroidPopen(['jarsigner', '-keystore', config['keystore'],
'-storepass', config['keystorepass'],
'-keypass', config['keypass'], '-sigalg',
'MD5withRSA', '-digestalg', 'SHA1',
- apkfile, keyalias], stdout=subprocess.PIPE)
- output = p.communicate()[0]
- print output
+ apkfile, keyalias])
if p.returncode != 0:
raise BuildException("Failed to sign application")
# Zipalign it...
- p = subprocess.Popen([os.path.join(config['sdk_path'],'tools','zipalign'),
+ p = FDroidPopen([os.path.join(config['sdk_path'],'tools','zipalign'),
'-v', '4', apkfile,
- os.path.join(output_dir, apkfilename)],
- stdout=subprocess.PIPE)
- output = p.communicate()[0]
- print output
+ os.path.join(output_dir, apkfilename)])
if p.returncode != 0:
raise BuildException("Failed to align application")
os.remove(apkfile)
import os
import shutil
import glob
-import subprocess
import re
import zipfile
import hashlib
from metadata import MetaDataException
from PIL import Image
+from common import FDroidPopen
def get_densities():
return ['640', '480', '320', '240', '160', '120']
thisinfo['features'] = []
thisinfo['icons_src'] = {}
thisinfo['icons'] = {}
- p = subprocess.Popen([os.path.join(config['sdk_path'], 'build-tools', config['build_tools'], 'aapt'),
- 'dump', 'badging', apkfile],
- stdout=subprocess.PIPE)
- output = p.communicate()[0]
+ p = FDroidPopen([os.path.join(config['sdk_path'],
+ 'build-tools', config['build_tools'], 'aapt'),
+ 'dump', 'badging', apkfile])
if p.returncode != 0:
print "ERROR: Failed to get apk information"
sys.exit(1)
- for line in output.splitlines():
+ for line in p.stdout.splitlines():
if line.startswith("package:"):
try:
thisinfo['id'] = re.match(name_pat, line).group(1)
print "\tcd " + getsig_dir
print "\t./make.sh"
sys.exit(1)
- p = subprocess.Popen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
- 'getsig', os.path.join(os.getcwd(), apkfile)], stdout=subprocess.PIPE)
- output = p.communicate()[0]
- if options.verbose:
- print output
- if p.returncode != 0 or not output.startswith('Result:'):
+ p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
+ 'getsig', os.path.join(os.getcwd(), apkfile)])
+ if p.returncode != 0 or not p.stdout.startswith('Result:'):
print "ERROR: Failed to get apk signature"
sys.exit(1)
- thisinfo['sig'] = output[7:].strip()
+ thisinfo['sig'] = p.stdout[7:].strip()
apk = zipfile.ZipFile(apkfile, 'r')
return " ".join(ret)
def extract_pubkey():
- p = subprocess.Popen(['keytool', '-exportcert',
+ p = FDroidPopen(['keytool', '-exportcert',
'-alias', config['repo_keyalias'],
'-keystore', config['keystore'],
- '-storepass', config['keystorepass']],
- stdout=subprocess.PIPE)
- cert = p.communicate()[0]
+ '-storepass', config['keystorepass']])
if p.returncode != 0:
print "ERROR: Failed to get repo pubkey"
sys.exit(1)
global repo_pubkey_fingerprint
- repo_pubkey_fingerprint = cert_fingerprint(cert)
- return "".join("%02x" % ord(b) for b in cert)
+ repo_pubkey_fingerprint = cert_fingerprint(p.stdout)
+ return "".join("%02x" % ord(b) for b in p.stdout)
repoel.setAttribute("pubkey", extract_pubkey())
print "Key fingerprint:", repo_pubkey_fingerprint
#Create a jar of the index...
- p = subprocess.Popen(['jar', 'cf', 'index.jar', 'index.xml'],
- cwd=repodir, stdout=subprocess.PIPE)
- output = p.communicate()[0]
- if options.verbose:
- print output
+ p = FDroidPopen(['jar', 'cf', 'index.jar', 'index.xml'], cwd=repodir)
if p.returncode != 0:
print "ERROR: Failed to create jar file"
sys.exit(1)
# Sign the index...
- p = subprocess.Popen(['jarsigner', '-keystore', config['keystore'],
+ p = FDroidPopen(['jarsigner', '-keystore', config['keystore'],
'-storepass', config['keystorepass'], '-keypass', config['keypass'],
'-digestalg', 'SHA1', '-sigalg', 'MD5withRSA',
- os.path.join(repodir, 'index.jar') , config['repo_keyalias']], stdout=subprocess.PIPE)
- output = p.communicate()[0]
+ os.path.join(repodir, 'index.jar') , config['repo_keyalias']])
if p.returncode != 0:
print "Failed to sign index"
- print output
sys.exit(1)
- if options.verbose:
- print output
# Copy the repo icon into the repo directory...
icon_dir = os.path.join(repodir ,'icons')
import glob
from optparse import OptionParser
+from common import FDroidPopen
+
import common
options = None
os.remove(remoteapk)
url = 'https://f-droid.org/repo/' + apkfilename
print "...retrieving " + url
- p = subprocess.Popen(['wget', url],
- cwd=tmp_dir,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- out = p.communicate()[0]
+ p = FDroidPopen(['wget', url], cwd=tmp_dir)
if p.returncode != 0:
raise Exception("Failed to get " + apkfilename)
cwd=thatdir) != 0:
raise Exception("Failed to unpack remote build of " + apkfilename)
- p = subprocess.Popen(['diff', '-r', 'this_apk', 'that_apk'],
- cwd=tmp_dir, stdout=subprocess.PIPE)
- out = p.communicate()[0]
- lines = out.splitlines()
+ p = FDroidPopen(['diff', '-r', 'this_apk', 'that_apk'], cwd=tmp_dir)
+ lines = p.stdout.splitlines()
if len(lines) != 1 or 'META-INF' not in lines[0]:
- raise Exception("Unexpected diff output - " + out)
+ raise Exception("Unexpected diff output - " + p.stdout)
print "...successfully verified"
verified += 1