chiark / gitweb /
FDroidPopen must have a locale to support UTF-8 filenames
authorHans-Christoph Steiner <hans@eds.org>
Thu, 23 Jun 2016 15:11:49 +0000 (17:11 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 27 Jun 2016 18:30:32 +0000 (20:30 +0200)
`fdroid update` should be able to handle any valid filename (hopefully
aapt doesn't barf on them).  To handle that, the environment where the
shell commands are run in needs to have a UTF-8 locale set. If LANG is
not set, things default to ASCII and UTF-8 filenames fail.

This also renames test APK with lots of Unicode chars as a test case.

closes #167

fdroidserver/common.py
tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk [new file with mode: 0644]
tests/repo/urzip.apk [deleted file]
tests/run-tests

index 732d18d2b6adc55222dc8ca2e67c57875abd89cb..2c2bb4e062b77472f7a2deb67d107897de7bc567 100644 (file)
@@ -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/tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk b/tests/repo/urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234.apk
new file mode 100644 (file)
index 0000000..0851e06
Binary files /dev/null and "b/tests/repo/urzip-\317\200\303\207\303\207\317\200\303\207\303\207\347\216\260\344\273\243\346\261\211\350\257\255\351\200\232\347\224\250\345\255\227-\320\261\321\212\320\273\320\263\320\260\321\200\321\201\320\272\320\270-\330\271\330\261\330\250\331\2121234.apk" differ
diff --git a/tests/repo/urzip.apk b/tests/repo/urzip.apk
deleted file mode 100644 (file)
index ee5e5cb..0000000
Binary files a/tests/repo/urzip.apk and /dev/null differ
index 62d27aa757aea20f1714803927c6c9dfaa28be1c..c55319da8ada9f97841b0735585b4561b58b17f9 100755 (executable)
@@ -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 '<application id=' repo/index.xml > /dev/null
+
+
 #------------------------------------------------------------------------------#
 echo_header "test metadata checks"