replace $$srclib$$ with an absolute path

closes #725
This commit is contained in:
Hans-Christoph Steiner 2020-06-24 20:50:21 +02:00
parent b3f5176654
commit d0f426e076
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
3 changed files with 55 additions and 5 deletions

View File

@ -541,8 +541,7 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
# Substitute source library paths into commands...
for name, number, libpath in srclibpaths:
libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath)
cmd = cmd.replace('$$' + name + '$$', os.path.join(os.getcwd(), libpath))
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)

View File

@ -2116,8 +2116,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Substitute source library paths into prebuild commands
for name, number, libpath in srclibpaths:
libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath)
cmd = cmd.replace('$$' + name + '$$', os.path.join(os.getcwd(), libpath))
p = FDroidPopen(['bash', '-x', '-c', '--', cmd], cwd=root_dir)
if p.returncode != 0:
@ -2744,7 +2743,7 @@ def set_FDroidPopen_env(build=None):
def replace_build_vars(cmd, build):
cmd = cmd.replace('$$COMMIT$$', build.commit)
cmd = cmd.replace('$$VERSION$$', build.versionName)
cmd = cmd.replace('$$VERCODE$$', build.versionCode)
cmd = cmd.replace('$$VERCODE$$', str(build.versionCode))
return cmd

View File

@ -288,6 +288,58 @@ class CommonTest(unittest.TestCase):
self.assertIsNotNone(re.search('android:versionName="%s"' % build.versionName, filedata))
self.assertIsNotNone(re.search('android:versionCode="%s"' % build.versionCode, filedata))
def test_prepare_sources_with_prebuild_subdir(self):
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
app_build_dir = os.path.join(testdir, 'build', 'com.example')
shutil.copytree(os.path.join(self.basedir, 'source-files', 'fdroid', 'fdroidclient'),
app_build_dir)
subdir = 'baz/bar'
subdir_path = os.path.join(app_build_dir, subdir)
os.makedirs(subdir_path)
with open(os.path.join(subdir_path, 'build.gradle'), 'w') as fp:
fp.write('// just a test placeholder')
config = dict()
fdroidserver.common.fill_config_defaults(config)
fdroidserver.common.config = config
srclibname = 'FakeSrcLib'
srclib_testdir = os.path.join(testdir, 'build', 'srclib')
os.makedirs(os.path.join(srclib_testdir, srclibname, 'testdirshouldexist'))
fdroidserver.metadata.srclibs = {
srclibname: {
'RepoType': 'git',
'Repo': 'https://example.com/foo/fakesrclib',
'Subdir': None,
'Prepare': None,
}
}
app = fdroidserver.metadata.App()
app.id = 'app.has.srclibs'
build = fdroidserver.metadata.Build()
build.commit = 'master'
build.gradle = ['yes']
build.prebuild = 'test -d $$FakeSrcLib$$/testdirshouldexist' # actual test condition
build.srclibs = [srclibname + '@1.2.3']
build.subdir = subdir
build.versionCode = 0xcafe
build.versionName = 'vCAFE'
class FakeVcs():
# no need to change to the correct commit here
def gotorevision(self, rev, refresh=True):
pass
# no srclib info needed, but it could be added...
def getsrclib(self):
return None
fdroidserver.common.prepare_source(FakeVcs(), app, build,
app_build_dir, srclib_testdir, app_build_dir,
onserver=True, refresh=False) # do not clone in this test
def test_prepare_sources_refresh(self):
packageName = 'org.fdroid.ci.test.app'
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)