From 8a7bc2b69a586c8a15803520b05749f2c81a4e74 Mon Sep 17 00:00:00 2001 From: Jamie Alexandre Date: Mon, 12 Jun 2017 13:21:35 -0700 Subject: [PATCH 1/2] Add buildkite instructions for building APK --- .buildkite/build_apk.sh | 18 ++++++++++++++++++ .buildkite/pipeline.yml | 5 +++++ 2 files changed, 23 insertions(+) create mode 100755 .buildkite/build_apk.sh diff --git a/.buildkite/build_apk.sh b/.buildkite/build_apk.sh new file mode 100755 index 00000000000..5dce9ea3b71 --- /dev/null +++ b/.buildkite/build_apk.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail + + +yes y | rm -r kolibri-android-wrapper/ || true 2> /dev/null +git clone https://github.com/learningequality/kolibri-android-wrapper.git + +buildkite-agent artifact download 'dist/*.pex' dist/ +cp dist/*.pex kolibri-android-wrapper/kolibri.pex + +cd kolibri-android-wrapper +docker build -t kolibriandroid . +APK_FILENAME=$(basename `docker run -it kolibriandroid /bin/sh -c "ls /*.apk | tr -d '\n'"`) +(docker run -it kolibriandroid /bin/sh -c "cat /*.apk") > ../dist/$APK_FILENAME +cd .. + +buildkite-agent artifact upload 'dist/*.apk' diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0f0c9b4f6aa..f88b2deef55 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -14,3 +14,8 @@ steps: - label: Build kolibri windows installer command: .buildkite/build_windows_installer.sh + + - wait + + - label: Build the Android APK file + command: mkdir -p dist && .buildkite/build_apk.sh From 78177ae43f7b4d2c25139d19e1e9834458002819 Mon Sep 17 00:00:00 2001 From: Jamie Alexandre Date: Mon, 12 Jun 2017 13:23:30 -0700 Subject: [PATCH 2/2] Fallback to reading from /proc/mounts when "mount" command not available --- .../core/discovery/utils/filesystem/posix.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/kolibri/core/discovery/utils/filesystem/posix.py b/kolibri/core/discovery/utils/filesystem/posix.py index ff40bd78007..d57bb4be7c7 100644 --- a/kolibri/core/discovery/utils/filesystem/posix.py +++ b/kolibri/core/discovery/utils/filesystem/posix.py @@ -17,6 +17,11 @@ # /dev/sdb2 on /media/user/KEEPOD type ext4 (rw,nosuid,nodev,uhelper=udisks2) LINUX_MOUNT_PARSER = re.compile("^(?P\S+) on (?P.+) type (?P\S+)", flags=re.MULTILINE) +# Regex parser for the contents of `/proc/mounts` (mostly needed for Android), which contains rows that looks like: +# /dev/block/bootdevice/by-name/userdata /data ext4 rw,seclabel,nosuid,nodev,noatime,noauto_da_alloc,data=ordered 0 0 +RAW_MOUNT_PARSER = re.compile("^(?P\S+) (?P.+) (?P\S+)", flags=re.MULTILINE) + + FILESYSTEM_BLACKLIST = set(["anon_inodefs", "bdev", "binfmt_misc", "cgroup", "cpuset", "debugfs", "devpts", "devtmpfs", "ecryptfs", "fuse", "fuse.gvfsd-fuse", "fusectl", "hugetlbfs", "mqueue", "nfs", "nfs4", "nfsd", "pipefs", "proc", "pstore", "ramfs", "rootfs", "rpc_pipefs", "securityfs", "sockfs", "sysfs", @@ -30,20 +35,25 @@ def get_drive_list(): Disk size/usage comes from shutil.disk_usage or os.statvfs, and name/type info from dbus (Linux) or diskutil (OSX). """ - drivelist = subprocess.Popen('mount', shell=True, stdout=subprocess.PIPE) - drivelisto, err = drivelist.communicate() - - drives = [] - if sys.platform == "darwin": MOUNT_PARSER = OSX_MOUNT_PARSER else: MOUNT_PARSER = LINUX_MOUNT_PARSER + try: + drivelist = subprocess.Popen('mount', shell=True, stdout=subprocess.PIPE) + drivelisto, err = drivelist.communicate() + except OSError: # couldn't run `mount`, let's try reading the /etc/mounts listing directly + with open("/proc/mounts") as f: + drivelisto = f.read() + MOUNT_PARSER = RAW_MOUNT_PARSER + + drives = [] + for drivematch in MOUNT_PARSER.finditer(drivelisto.decode()): drive = drivematch.groupdict() - path = drive["path"] + path = drive["path"].replace("\\040", " ").replace("\\011", "\t").replace("\\012", "\n").replace("\\134", "\\") # skip the drive if the filesystem or path is in a blacklist if drive["filesystem"] in FILESYSTEM_BLACKLIST or any(path.startswith(p) for p in PATH_PREFIX_BLACKLIST):