diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d18a81469..f0cda57aa 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -38,6 +38,11 @@ jobs: run: | brew install automake sudo ln -sfn /usr/local/opt/openssl /usr/local/ssl + - name: Unzip Test + run: | + ls -la + python3 scripts/unziptest.py + ls -la - name: buildozer android debug run: | touch main.py diff --git a/buildozer/scripts/unziptest.py b/buildozer/scripts/unziptest.py new file mode 100644 index 000000000..fdfaec6a5 --- /dev/null +++ b/buildozer/scripts/unziptest.py @@ -0,0 +1,64 @@ +import os +from os.path import join + +from zipfile import ZipFile + +from buildozer.buildops import download, cmd + + +def bash_cmd_case(): + os.mkdir("test_bash_cmd") + os.chdir("test_bash_cmd") + download( + "https://dl.google.com/android/repository/android-ndk-r25b-linux.zip", + "test.zip", + ) + cmd("unzip test.zip", show_output=True, env=os.environ) + os.chdir("..") + + +def python_library_case(): + os.mkdir("test_pylib") + os.chdir("test_pylib") + download( + "https://dl.google.com/android/repository/android-ndk-r25b-linux.zip", + "test.zip", + ) + with ZipFile("test.zip", "r") as compressed_file: + for file_info in compressed_file.infolist(): + _extract_one_file_from_zip( + compressed_file, + file_info.filename, + file_info.external_attr, + os.getcwd(), + ) + os.chdir("..") + + +def _extract_one_file_from_zip( + compressed_file, filename, external_attr, destination_dir +): + """ + Python's zipfile library does not preserve Unix file permissions + on extraction, so this function extracts one file and chmods it + appropriately. + + On Windows platforms, the extra work has no effect. + """ + compressed_file.extract(filename, path=destination_dir) + + # First 2 bytes of 4-byte value represent Unix permissions + permission = external_attr >> 16 + os.chmod(join(destination_dir, filename), permission) + + +def compare(): + bash_cmd_case() + python_library_case() + cmd( + ["diff", "-r", "test_bash_cmd/", "test_pylib/"], + show_output=True, + env=os.environ, + ) + +compare() \ No newline at end of file