mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Be more consistent when running bash commands (fixes #365)
This commit is contained in:
parent
b184610913
commit
0949395771
2 changed files with 84 additions and 38 deletions
|
@ -375,11 +375,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
|
|
||||||
# Run a build command if one is required...
|
# Run a build command if one is required...
|
||||||
if 'build' in thisbuild:
|
if 'build' in thisbuild:
|
||||||
cmd = thisbuild['build']
|
output, error = ''
|
||||||
if options.verbose:
|
build = thisbuild['build']
|
||||||
print "Running custom build commands: " + cmd
|
|
||||||
else:
|
|
||||||
print "Running custom build commands..."
|
|
||||||
# Substitute source library paths into commands...
|
# Substitute source library paths into commands...
|
||||||
for name, libpath in srclibpaths:
|
for name, libpath in srclibpaths:
|
||||||
libpath = os.path.relpath(libpath, root_dir)
|
libpath = os.path.relpath(libpath, root_dir)
|
||||||
|
@ -387,15 +384,29 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||||
cmd = cmd.replace('$$SDK$$', sdk_path)
|
cmd = cmd.replace('$$SDK$$', sdk_path)
|
||||||
cmd = cmd.replace('$$NDK$$', ndk_path)
|
cmd = cmd.replace('$$NDK$$', ndk_path)
|
||||||
cmd = cmd.replace('$$MVN3$$', mvn3)
|
cmd = cmd.replace('$$MVN3$$', mvn3)
|
||||||
if options.verbose:
|
if verbose:
|
||||||
# Note: output goes to console, not log
|
print "Running 'build' commands in %s" % root_dir
|
||||||
p = subprocess.Popen(['bash', '-x', '-c', cmd], cwd=root_dir)
|
|
||||||
else:
|
p = subprocess.Popen(['bash', '-x', '-c', build], cwd=root_dir,
|
||||||
p = subprocess.Popen(['bash', '-c', cmd], cwd=root_dir,
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
for line in iter(p.stdout.readline, ''):
|
||||||
out, err = p.communicate()
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
output += line
|
||||||
|
for line in iter(p.stderr.readline, ''):
|
||||||
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
error += line
|
||||||
|
p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException("Error running build command", out, err)
|
raise BuildException("Error running build command for %s:%s" %
|
||||||
|
(app['id'], thisbuild['version']), output, error)
|
||||||
|
|
||||||
# Build native stuff if required...
|
# Build native stuff if required...
|
||||||
if thisbuild.get('buildjni') not in (None, 'no'):
|
if thisbuild.get('buildjni') not in (None, 'no'):
|
||||||
|
|
|
@ -305,8 +305,7 @@ class vcs_svn(vcs):
|
||||||
for svncommand in (
|
for svncommand in (
|
||||||
'svn revert -R .',
|
'svn revert -R .',
|
||||||
r"svn status | awk '/\?/ {print $2}' | xargs rm -rf"):
|
r"svn status | awk '/\?/ {print $2}' | xargs rm -rf"):
|
||||||
if subprocess.call(svncommand, cwd=self.local,
|
if subprocess.call(svncommand, cwd=self.local) != 0:
|
||||||
shell=True) != 0:
|
|
||||||
raise VCSException("Svn reset ({0}) failed in {1}".format(svncommand, self.local))
|
raise VCSException("Svn reset ({0}) failed in {1}".format(svncommand, self.local))
|
||||||
if not self.refreshed:
|
if not self.refreshed:
|
||||||
if subprocess.call(['svn', 'update'] +
|
if subprocess.call(['svn', 'update'] +
|
||||||
|
@ -330,8 +329,7 @@ class vcs_hg(vcs):
|
||||||
if subprocess.call(['hg', 'clone', self.remote, self.local]) !=0:
|
if subprocess.call(['hg', 'clone', self.remote, self.local]) !=0:
|
||||||
raise VCSException("Hg clone failed")
|
raise VCSException("Hg clone failed")
|
||||||
else:
|
else:
|
||||||
if subprocess.call('hg status -u | xargs rm -rf',
|
if subprocess.call('hg status -u | xargs rm -rf', cwd=self.local) != 0:
|
||||||
cwd=self.local, shell=True) != 0:
|
|
||||||
raise VCSException("Hg clean failed")
|
raise VCSException("Hg clean failed")
|
||||||
if not self.refreshed:
|
if not self.refreshed:
|
||||||
if subprocess.call(['hg', 'pull'],
|
if subprocess.call(['hg', 'pull'],
|
||||||
|
@ -1182,13 +1180,35 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
|
||||||
|
|
||||||
# Run an init command if one is required...
|
# Run an init command if one is required...
|
||||||
if 'init' in build:
|
if 'init' in build:
|
||||||
init = build['init']
|
output = ''
|
||||||
init = init.replace('$$SDK$$', sdk_path)
|
error = ''
|
||||||
init = init.replace('$$NDK$$', ndk_path)
|
cmd = build['init']
|
||||||
init = init.replace('$$MVN$$', mvn3)
|
cmd = cmd.replace('$$SDK$$', sdk_path)
|
||||||
if verbose: print "Doing init: exec '%s' in '%s'"%(init,root_dir)
|
cmd = cmd.replace('$$NDK$$', ndk_path)
|
||||||
if subprocess.call(['bash', '-c', init], cwd=root_dir) != 0:
|
cmd = cmd.replace('$$MVN$$', mvn3)
|
||||||
raise BuildException("Error running init command")
|
if verbose:
|
||||||
|
print "Running 'init' commands in %s" % root_dir
|
||||||
|
|
||||||
|
p = subprocess.Popen(['bash', '-x', '-c', cmd], cwd=root_dir,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
for line in iter(p.stdout.readline, ''):
|
||||||
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
output += line
|
||||||
|
for line in iter(p.stderr.readline, ''):
|
||||||
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
error += line
|
||||||
|
p.communicate()
|
||||||
|
if p.returncode != 0:
|
||||||
|
raise BuildException("Error running init command for %s:%s" %
|
||||||
|
(app['id'], thisbuild['version']), output, error)
|
||||||
|
|
||||||
# Generate (or update) the ant build file, build.xml...
|
# Generate (or update) the ant build file, build.xml...
|
||||||
updatemode = build.get('update', '.')
|
updatemode = build.get('update', '.')
|
||||||
|
@ -1372,25 +1392,40 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
|
||||||
|
|
||||||
# Run a pre-build command if one is required...
|
# Run a pre-build command if one is required...
|
||||||
if 'prebuild' in build:
|
if 'prebuild' in build:
|
||||||
prebuild = build['prebuild']
|
output = ''
|
||||||
if verbose:
|
error = ''
|
||||||
print "Running source init (prebuild) commands:" + prebuild
|
cmd = build['prebuild']
|
||||||
else:
|
|
||||||
print "Running source init (prebuild) commands..."
|
|
||||||
|
|
||||||
# Substitute source library paths into prebuild commands...
|
# Substitute source library paths into prebuild commands...
|
||||||
for name, libpath in srclibpaths:
|
for name, libpath in srclibpaths:
|
||||||
libpath = os.path.relpath(libpath, root_dir)
|
libpath = os.path.relpath(libpath, root_dir)
|
||||||
prebuild = prebuild.replace('$$' + name + '$$', libpath)
|
cmd = cmd.replace('$$' + name + '$$', libpath)
|
||||||
prebuild = prebuild.replace('$$SDK$$', sdk_path)
|
cmd = cmd.replace('$$SDK$$', sdk_path)
|
||||||
prebuild = prebuild.replace('$$NDK$$', ndk_path)
|
cmd = cmd.replace('$$NDK$$', ndk_path)
|
||||||
prebuild = prebuild.replace('$$MVN3$$', mvn3)
|
cmd = cmd.replace('$$MVN3$$', mvn3)
|
||||||
p = subprocess.Popen(['bash', '-c', prebuild], cwd=root_dir,
|
if verbose:
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
print "Running 'prebuild' commands in %s" % root_dir
|
||||||
out, err = p.communicate()
|
|
||||||
if p.returncode != 0:
|
|
||||||
raise BuildException("Error running pre-build command", out, err)
|
|
||||||
|
|
||||||
|
p = subprocess.Popen(['bash', '-x', '-c', cmd], cwd=root_dir,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
for line in iter(p.stdout.readline, ''):
|
||||||
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
output += line
|
||||||
|
for line in iter(p.stderr.readline, ''):
|
||||||
|
if verbose:
|
||||||
|
# Output directly to console
|
||||||
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
|
else:
|
||||||
|
error += line
|
||||||
|
p.communicate()
|
||||||
|
if p.returncode != 0:
|
||||||
|
raise BuildException("Error running prebuild command for %s:%s" %
|
||||||
|
(app['id'], thisbuild['version']), output, error)
|
||||||
print "Applying generic clean-ups..."
|
print "Applying generic clean-ups..."
|
||||||
|
|
||||||
if build.get('anal-tics', 'no') == 'yes':
|
if build.get('anal-tics', 'no') == 'yes':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue