1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 02:50:12 +01:00

import: ignore results if build/appid dir already exists

This commit is contained in:
Hans-Christoph Steiner 2020-02-17 17:09:42 +01:00
parent 32a29b3304
commit 202602937d
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA

View File

@ -24,6 +24,7 @@ import json
import os
import re
import shutil
import sys
import urllib.parse
import urllib.request
import yaml
@ -231,7 +232,7 @@ def main():
apps = metadata.read_metadata()
app = None
build_dir = None
tmp_importer_dir = None
local_metadata_files = common.get_local_metadata_files()
if local_metadata_files != []:
@ -257,7 +258,7 @@ def main():
write_local_file = True
elif options.url:
app = get_app_from_url(options.url)
build_dir = clone_to_tmp_dir(app)
tmp_importer_dir = clone_to_tmp_dir(app)
git_repo = git.repo.Repo(tmp_importer_dir)
build.disable = 'Generated by import.py - check/set version fields and commit id'
write_local_file = False
@ -270,8 +271,8 @@ def main():
build.commit = binascii.hexlify(bytearray(git_repo.head.commit.binsha)).decode()
# Extract some information...
paths = get_all_gradle_and_manifests(build_dir)
subdir = get_gradle_subdir(build_dir, paths)
paths = get_all_gradle_and_manifests(tmp_importer_dir)
subdir = get_gradle_subdir(tmp_importer_dir, paths)
if paths:
versionName, versionCode, package = common.parse_androidmanifests(paths, app)
if not package:
@ -305,8 +306,8 @@ def main():
or os.path.exists(os.path.join(subdir, 'build.gradle')):
build.gradle = ['yes']
package_json = os.path.join(build_dir, 'package.json') # react-native
pubspec_yaml = os.path.join(build_dir, 'pubspec.yaml') # flutter
package_json = os.path.join(tmp_importer_dir, 'package.json') # react-native
pubspec_yaml = os.path.join(tmp_importer_dir, 'pubspec.yaml') # flutter
if os.path.exists(package_json):
build.sudo = ['apt-get install npm', 'npm install -g react-native-cli']
build.init = ['npm install']
@ -316,7 +317,7 @@ def main():
app.License = data.get('license', app.License)
app.Description = data.get('description', app.Description)
app.WebSite = data.get('homepage', app.WebSite)
app_json = os.path.join(build_dir, 'app.json')
app_json = os.path.join(tmp_importer_dir, 'app.json')
if os.path.exists(app_json):
with open(app_json) as fp:
data = json.load(fp)
@ -345,8 +346,13 @@ def main():
# Keep the repo directory to save bandwidth...
if not os.path.exists('build'):
os.mkdir('build')
if build_dir is not None:
shutil.move(build_dir, os.path.join('build', package))
build_dir = os.path.join('build', package)
if os.path.exists(build_dir):
logging.warning(_('{path} already exists, ignoring import results!')
.format(path=build_dir))
sys.exit(1)
elif tmp_importer_dir is not None:
shutil.move(tmp_importer_dir, build_dir)
with open('build/.fdroidvcs-' + package, 'w') as f:
f.write(app.RepoType + ' ' + app.Repo)