diff --git a/.gitignore b/.gitignore index 1c57aac4..8bff77fa 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,13 @@ docs/html/ # files generated by tests tmp/ tests/repo/icons* + +# files used in manual testing +/config.py +/tmp/ +/logs/ +/metadata/ +makebuildserver.config.py +/tests/config.py +/tests/fdroid-icon.png +/unsigned/ diff --git a/.travis.yml b/.travis.yml index 7c2300dc..e7b004c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ matrix: # this doesn't actually work yet https://github.com/travis-ci/travis-ci/issues/5337 dist: trusty - os: osx + osx_image: xcode8 env: ANDROID_HOME=/usr/local/opt/android-sdk licenses: diff --git a/fdroidserver/build.py b/fdroidserver/build.py index bad025a6..818f6c1f 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -388,8 +388,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force): if options.verbose: cmdline += ' --verbose' cmdline += " %s:%s" % (app.id, build.vercode) - cmdline = '. /etc/profile && ' + cmdline - chan.exec_command('bash -c "' + cmdline + '"') + chan.exec_command('bash --login -c "' + cmdline + '"') output = bytes() while not chan.exit_status_ready(): while chan.recv_ready(): diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 732d18d2..2c2bb4e0 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1794,7 +1794,8 @@ def set_FDroidPopen_env(build=None): set up the environment variables for the build environment There is only a weak standard, the variables used by gradle, so also set - up the most commonly used environment variables for SDK and NDK + up the most commonly used environment variables for SDK and NDK. Also, if + there is no locale set, this will set the locale (e.g. LANG) to en_US.UTF-8. ''' global env, orig_path @@ -1806,6 +1807,15 @@ def set_FDroidPopen_env(build=None): for k, v in config['java_paths'].items(): env['JAVA%s_HOME' % k] = v + missinglocale = True + for k, v in env.items(): + if k == 'LANG' and v != 'C': + missinglocale = False + elif k == 'LC_ALL': + missinglocale = False + if missinglocale: + env['LANG'] = 'en_US.UTF-8' + if build is not None: path = build.ndk_path() paths = orig_path.split(os.pathsep) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index cb1cb10f..abff8b65 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -323,8 +323,10 @@ def resize_icon(iconpath, density): if not os.path.isfile(iconpath): return + fp = None try: - im = Image.open(iconpath) + fp = open(iconpath, 'rb') + im = Image.open(fp) size = dpi_to_px(density) if any(length > size for length in im.size): @@ -337,6 +339,10 @@ def resize_icon(iconpath, density): except Exception as e: logging.error("Failed resizing {0} - {1}".format(iconpath, e)) + finally: + if fp: + fp.close() + def resize_all_icons(repodirs): """Resize all icons that exceed the max size @@ -405,6 +411,14 @@ def getsig(apkpath): return hashlib.md5(hexlify(cert_encoded)).hexdigest() +def get_icon_bytes(apkzip, iconsrc): + '''ZIP has no official encoding, UTF-* and CP437 are defacto''' + try: + return apkzip.read(iconsrc) + except KeyError: + return apkzip.read(iconsrc.encode('utf-8').decode('cp437')) + + def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False): """Scan the apks in the given repo directory. @@ -563,7 +577,7 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False): # Check for debuggable apks... if common.isApkDebuggable(apkfile, config): - logging.warn('{0} is set to android:debuggable="true"'.format(apkfile)) + logging.warning('{0} is set to android:debuggable="true"'.format(apkfile)) # Get the signature (or md5 of, to be precise)... logging.debug('Getting signature of {0}'.format(apkfile)) @@ -607,7 +621,7 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False): try: with open(icondest, 'wb') as f: - f.write(apkzip.read(iconsrc)) + f.write(get_icon_bytes(apkzip, iconsrc)) apk['icons'][density] = iconfilename except: @@ -621,7 +635,7 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False): iconpath = os.path.join( get_icon_dir(repodir, '0'), iconfilename) with open(iconpath, 'wb') as f: - f.write(apkzip.read(iconsrc)) + f.write(get_icon_bytes(apkzip, iconsrc)) try: im = Image.open(iconpath) dpi = px_to_dpi(im.size[0]) @@ -657,17 +671,21 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False): get_icon_dir(repodir, last_density), iconfilename) iconpath = os.path.join( get_icon_dir(repodir, density), iconfilename) + fp = None try: - im = Image.open(last_iconpath) + fp = open(last_iconpath, 'rb') + im = Image.open(fp) + + size = dpi_to_px(density) + + im.thumbnail((size, size), Image.ANTIALIAS) + im.save(iconpath, "PNG") + empty_densities.remove(density) except: - logging.warn("Invalid image file at %s" % last_iconpath) - continue - - size = dpi_to_px(density) - - im.thumbnail((size, size), Image.ANTIALIAS) - im.save(iconpath, "PNG") - empty_densities.remove(density) + logging.warning("Invalid image file at %s" % last_iconpath) + finally: + if fp: + fp.close() # Then just copy from the highest resolution available last_density = None diff --git a/tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk b/tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk new file mode 100644 index 00000000..0851e066 Binary files /dev/null and b/tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk differ diff --git a/tests/repo/urzip.apk b/tests/repo/urzip.apk deleted file mode 100644 index ee5e5cba..00000000 Binary files a/tests/repo/urzip.apk and /dev/null differ diff --git a/tests/run-tests b/tests/run-tests index 62d27aa7..c55319da 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -138,6 +138,20 @@ $fdroid readmeta $fdroid update +#------------------------------------------------------------------------------# +echo_header "copy tests/repo, generate a keystore, and update" + +REPOROOT=`create_test_dir` +cd $REPOROOT +$fdroid init +cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $REPOROOT/ +echo "accepted_formats = ['json', 'txt', 'xml', 'yml']" >> config.py +$fdroid update --verbose +test -e repo/index.xml +test -e repo/index.jar +grep -F '