1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-19 21:30:10 +01:00

Merge branch 'replacement-var-abs-path' into 'master'

Replacement var abs path

Closes #725

See merge request fdroid/fdroidserver!770
This commit is contained in:
Marcus 2020-06-24 21:01:35 +00:00
commit ed8c87950d
3 changed files with 57 additions and 7 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

@ -1841,7 +1841,7 @@ def parse_srclib_spec(spec):
return (name, ref, number, subdir)
def getsrclib(spec, srclib_dir, subdir=None, basepath=False,
def getsrclib(spec, srclib_dir, basepath=False,
raw=False, prepare=True, preponly=False, refresh=True,
build=None):
"""Get the specified source library.
@ -1976,7 +1976,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
if build.srclibs:
logging.info("Collecting source libraries")
for lib in build.srclibs:
srclibpaths.append(getsrclib(lib, srclib_dir, build, preponly=onserver,
srclibpaths.append(getsrclib(lib, srclib_dir, preponly=onserver,
refresh=refresh, build=build))
for name, number, libpath in srclibpaths:
@ -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)