Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/icecold' into icecold
Browse files Browse the repository at this point in the history
  • Loading branch information
aronasorman committed Jun 13, 2017
2 parents 0cf0c5b + beed1d1 commit 2cd7647
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .buildkite/build_apk.sh
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 5 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 16 additions & 6 deletions kolibri/core/discovery/utils/filesystem/posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
# /dev/sdb2 on /media/user/KEEPOD type ext4 (rw,nosuid,nodev,uhelper=udisks2)
LINUX_MOUNT_PARSER = re.compile("^(?P<device>\S+) on (?P<path>.+) type (?P<filesystem>\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<device>\S+) (?P<path>.+) (?P<filesystem>\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",
Expand All @@ -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):
Expand Down

0 comments on commit 2cd7647

Please sign in to comment.