mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 07:20:29 +03:00
Merge branch 'import-kivy' into 'master'
import kivy and two fixes See merge request fdroid/fdroidserver!778
This commit is contained in:
commit
838eee355f
4 changed files with 75 additions and 16 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import git
|
import git
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
@ -58,6 +59,44 @@ def clone_to_tmp_dir(app):
|
||||||
return tmp_dir
|
return tmp_dir
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_kivy_buildozer(tmp_importer_dir, app, build):
|
||||||
|
versionCode = None
|
||||||
|
buildozer_spec = os.path.join(tmp_importer_dir, 'buildozer.spec')
|
||||||
|
if os.path.exists(buildozer_spec):
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(buildozer_spec)
|
||||||
|
import pprint
|
||||||
|
pprint.pprint(sorted(config['app'].keys()))
|
||||||
|
app.id = config['app'].get('package.domain')
|
||||||
|
print(app.id)
|
||||||
|
app.AutoName = config['app'].get('package.name', app.AutoName)
|
||||||
|
app.License = config['app'].get('license', app.License)
|
||||||
|
app.Description = config['app'].get('description', app.Description)
|
||||||
|
build.versionName = config['app'].get('version')
|
||||||
|
build.output = 'bin/%s-$$VERSION$$-release-unsigned.apk' % app.AutoName
|
||||||
|
build.ndk = 'r17c'
|
||||||
|
build.srclibs = [
|
||||||
|
'buildozer@586152c',
|
||||||
|
'python-for-android@ccb0f8e1',
|
||||||
|
]
|
||||||
|
build.sudo = [
|
||||||
|
'apt-get update',
|
||||||
|
'apt-get install -y build-essential libffi-dev libltdl-dev',
|
||||||
|
]
|
||||||
|
build.prebuild = [
|
||||||
|
'sed -iE "/^[# ]*android\\.(ant|ndk|sdk)_path[ =]/d" buildozer.spec',
|
||||||
|
'sed -iE "/^[# ]*android.accept_sdk_license[ =]+.*/d" buildozer.spec',
|
||||||
|
'sed -iE "/^[# ]*android.skip_update[ =]+.*/d" buildozer.spec',
|
||||||
|
'sed -iE "/^[# ]*p4a.source_dir[ =]+.*/d" buildozer.spec',
|
||||||
|
'sed -i "s,\\[app\\],[app]\\n\\nandroid.sdk_path = $$SDK$$\\nandroid.ndk_path = $$NDK$$\\np4a.source_dir = $$python-for-android$$\\nandroid.accept_sdk_license = False\\nandroid.skip_update = True\\nandroid.ant_path = /usr/bin/ant\\n," buildozer.spec',
|
||||||
|
'pip3 install --user --upgrade $$buildozer$$ Cython==0.28.6',
|
||||||
|
]
|
||||||
|
build.build = [
|
||||||
|
'PATH="$HOME/.local/bin:$PATH" buildozer android release',
|
||||||
|
]
|
||||||
|
return build.get('versionName'), versionCode, app.get('id')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
global config, options
|
global config, options
|
||||||
|
|
@ -123,23 +162,25 @@ def main():
|
||||||
app.UpdateCheckMode = 'Tags'
|
app.UpdateCheckMode = 'Tags'
|
||||||
build.commit = common.get_head_commit_id(git_repo)
|
build.commit = common.get_head_commit_id(git_repo)
|
||||||
|
|
||||||
|
versionName, versionCode, appid = check_for_kivy_buildozer(tmp_importer_dir, app, build)
|
||||||
|
|
||||||
# Extract some information...
|
# Extract some information...
|
||||||
paths = common.get_all_gradle_and_manifests(tmp_importer_dir)
|
paths = common.get_all_gradle_and_manifests(tmp_importer_dir)
|
||||||
subdir = common.get_gradle_subdir(tmp_importer_dir, paths)
|
subdir = common.get_gradle_subdir(tmp_importer_dir, paths)
|
||||||
if paths:
|
if paths:
|
||||||
versionName, versionCode, package = common.parse_androidmanifests(paths, app)
|
versionName, versionCode, appid = common.parse_androidmanifests(paths, app)
|
||||||
if not package:
|
if not appid:
|
||||||
raise FDroidException(_("Couldn't find package ID"))
|
raise FDroidException(_("Couldn't find Application ID"))
|
||||||
if not versionName:
|
if not versionName:
|
||||||
logging.warning(_('Could not find latest version name'))
|
logging.warning(_('Could not find latest version name'))
|
||||||
if not versionCode:
|
if not versionCode:
|
||||||
logging.warning(_('Could not find latest version code'))
|
logging.warning(_('Could not find latest version code'))
|
||||||
else:
|
elif not appid:
|
||||||
raise FDroidException(_("No gradle project could be found. Specify --subdir?"))
|
raise FDroidException(_("No gradle project could be found. Specify --subdir?"))
|
||||||
|
|
||||||
# Make sure it's actually new...
|
# Make sure it's actually new...
|
||||||
if package in apps:
|
if appid in apps:
|
||||||
raise FDroidException("Package " + package + " already exists")
|
raise FDroidException(_('Package "{appid}" already exists').format(appid=appid))
|
||||||
|
|
||||||
# Create a build line...
|
# Create a build line...
|
||||||
build.versionName = versionName or 'Unknown'
|
build.versionName = versionName or 'Unknown'
|
||||||
|
|
@ -205,17 +246,17 @@ def main():
|
||||||
# Keep the repo directory to save bandwidth...
|
# Keep the repo directory to save bandwidth...
|
||||||
if not os.path.exists('build'):
|
if not os.path.exists('build'):
|
||||||
os.mkdir('build')
|
os.mkdir('build')
|
||||||
build_dir = os.path.join('build', package)
|
build_dir = os.path.join('build', appid)
|
||||||
if os.path.exists(build_dir):
|
if os.path.exists(build_dir):
|
||||||
logging.warning(_('{path} already exists, ignoring import results!')
|
logging.warning(_('{path} already exists, ignoring import results!')
|
||||||
.format(path=build_dir))
|
.format(path=build_dir))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif tmp_importer_dir is not None:
|
elif tmp_importer_dir is not None:
|
||||||
shutil.move(tmp_importer_dir, build_dir)
|
shutil.move(tmp_importer_dir, build_dir)
|
||||||
with open('build/.fdroidvcs-' + package, 'w') as f:
|
with open('build/.fdroidvcs-' + appid, 'w') as f:
|
||||||
f.write(app.RepoType + ' ' + app.Repo)
|
f.write(app.RepoType + ' ' + app.Repo)
|
||||||
|
|
||||||
metadatapath = os.path.join('metadata', package + '.yml')
|
metadatapath = os.path.join('metadata', appid + '.yml')
|
||||||
metadata.write_metadata(metadatapath, app)
|
metadata.write_metadata(metadatapath, app)
|
||||||
logging.info("Wrote " + metadatapath)
|
logging.info("Wrote " + metadatapath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ BINARY_TRANSPARENCY_DIR = 'binary_transparency'
|
||||||
|
|
||||||
AUTO_S3CFG = '.fdroid-server-update-s3cfg'
|
AUTO_S3CFG = '.fdroid-server-update-s3cfg'
|
||||||
USER_S3CFG = 's3cfg'
|
USER_S3CFG = 's3cfg'
|
||||||
|
REMOTE_HOSTNAME_REGEX = re.compile(r'\W*\w+\W+(\w+).*')
|
||||||
|
|
||||||
|
|
||||||
def update_awsbucket(repo_section):
|
def update_awsbucket(repo_section):
|
||||||
|
|
@ -384,15 +385,17 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
||||||
|
|
||||||
repo = git.Repo.init(git_mirror_path)
|
repo = git.Repo.init(git_mirror_path)
|
||||||
|
|
||||||
|
enabled_remotes = []
|
||||||
for remote_url in servergitmirrors:
|
for remote_url in servergitmirrors:
|
||||||
hostname = re.sub(r'\W*\w+\W+(\w+).*', r'\1', remote_url)
|
name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||||
r = git.remote.Remote(repo, hostname)
|
enabled_remotes.append(name)
|
||||||
|
r = git.remote.Remote(repo, name)
|
||||||
if r in repo.remotes:
|
if r in repo.remotes:
|
||||||
r = repo.remote(hostname)
|
r = repo.remote(name)
|
||||||
if 'set_url' in dir(r): # force remote URL if using GitPython 2.x
|
if 'set_url' in dir(r): # force remote URL if using GitPython 2.x
|
||||||
r.set_url(remote_url)
|
r.set_url(remote_url)
|
||||||
else:
|
else:
|
||||||
repo.create_remote(hostname, remote_url)
|
repo.create_remote(name, remote_url)
|
||||||
logging.info('Mirroring to: ' + remote_url)
|
logging.info('Mirroring to: ' + remote_url)
|
||||||
|
|
||||||
# sadly index.add don't allow the --all parameter
|
# sadly index.add don't allow the --all parameter
|
||||||
|
|
@ -414,6 +417,9 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
||||||
|
|
||||||
# push for every remote. This will overwrite the git history
|
# push for every remote. This will overwrite the git history
|
||||||
for remote in repo.remotes:
|
for remote in repo.remotes:
|
||||||
|
if remote.name not in enabled_remotes:
|
||||||
|
repo.delete_remote(remote)
|
||||||
|
continue
|
||||||
if remote.name == 'gitlab':
|
if remote.name == 'gitlab':
|
||||||
logging.debug('Writing .gitlab-ci.yml to deploy to GitLab Pages')
|
logging.debug('Writing .gitlab-ci.yml to deploy to GitLab Pages')
|
||||||
with open(os.path.join(git_mirror_path, ".gitlab-ci.yml"), "wt") as out_file:
|
with open(os.path.join(git_mirror_path, ".gitlab-ci.yml"), "wt") as out_file:
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,10 @@ v_all=${plugin_v[@]}
|
||||||
for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
|
for f in {.,..}/gradle/wrapper/gradle-wrapper.properties; do
|
||||||
[[ -f $f ]] || continue
|
[[ -f $f ]] || continue
|
||||||
while IFS='' read -r line || [ -n "$line" ]; do
|
while IFS='' read -r line || [ -n "$line" ]; do
|
||||||
|
line=$(printf $line | tr -d '\r') # strip Windows linefeeds
|
||||||
if [[ $line == 'distributionUrl='* ]]; then
|
if [[ $line == 'distributionUrl='* ]]; then
|
||||||
wrapper_ver=${line#*/gradle-}
|
wrapper_ver=${line#*/gradle-}
|
||||||
wrapper_ver=${wrapper_ver%-*.zip}
|
wrapper_ver=${wrapper_ver%-*.zip}
|
||||||
wrapper_ver=$(printf $wrapper_ver | tr -d '\r') # strip Windows linefeeds
|
|
||||||
break 2
|
break 2
|
||||||
fi
|
fi
|
||||||
done < $f
|
done < $f
|
||||||
|
|
@ -186,14 +186,13 @@ fi
|
||||||
for f in {.,..}/build.gradle{,.kts}; do
|
for f in {.,..}/build.gradle{,.kts}; do
|
||||||
[[ -f $f ]] || continue
|
[[ -f $f ]] || continue
|
||||||
while IFS='' read -r line || [ -n "$line" ]; do
|
while IFS='' read -r line || [ -n "$line" ]; do
|
||||||
|
line=$(printf $line | tr -d '\r') # strip Windows linefeeds
|
||||||
if [[ -z "$plugin_pver" && $line == *'com.android.tools.build:gradle:'* ]]; then
|
if [[ -z "$plugin_pver" && $line == *'com.android.tools.build:gradle:'* ]]; then
|
||||||
plugin_pver=${line#*[\'\"]com.android.tools.build:gradle:}
|
plugin_pver=${line#*[\'\"]com.android.tools.build:gradle:}
|
||||||
plugin_pver=${plugin_pver%[\'\"]*}
|
plugin_pver=${plugin_pver%[\'\"]*}
|
||||||
plugin_pver=$(printf $plugin_pver | tr -d '\r') # strip Windows linefeeds
|
|
||||||
elif [[ -z "$wrapper_ver" && $line == *'gradleVersion = '* ]]; then
|
elif [[ -z "$wrapper_ver" && $line == *'gradleVersion = '* ]]; then
|
||||||
wrapper_ver=${line#*gradleVersion*=*[\'\"]}
|
wrapper_ver=${line#*gradleVersion*=*[\'\"]}
|
||||||
wrapper_ver=${wrapper_ver%[\'\"]*}
|
wrapper_ver=${wrapper_ver%[\'\"]*}
|
||||||
wrapper_ver=$(printf $wrapper_ver | tr -d '\r') # strip Windows linefeeds
|
|
||||||
fi
|
fi
|
||||||
done < $f
|
done < $f
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,19 @@ class ServerTest(unittest.TestCase):
|
||||||
virustotal_apikey = os.getenv('VIRUSTOTAL_API_KEY')
|
virustotal_apikey = os.getenv('VIRUSTOTAL_API_KEY')
|
||||||
fdroidserver.server.upload_to_virustotal('repo', virustotal_apikey)
|
fdroidserver.server.upload_to_virustotal('repo', virustotal_apikey)
|
||||||
|
|
||||||
|
def test_remote_hostname_regex(self):
|
||||||
|
for remote_url, name in (
|
||||||
|
('git@github.com:guardianproject/fdroid-repo', 'github'),
|
||||||
|
('git@gitlab.com:guardianproject/fdroid-repo', 'gitlab'),
|
||||||
|
('https://github.com:guardianproject/fdroid-repo', 'github'),
|
||||||
|
('https://gitlab.com/guardianproject/fdroid-repo', 'gitlab'),
|
||||||
|
('https://salsa.debian.org/foo/repo', 'salsa'),
|
||||||
|
):
|
||||||
|
self.assertEqual(
|
||||||
|
name,
|
||||||
|
fdroidserver.server.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
os.chdir(os.path.dirname(__file__))
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue