Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

halium: allow fallbacking to an eventual system image available inside the rootfs on "halium" file layouts #25

Open
wants to merge 1 commit into
base: halium
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions scripts/halium
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,31 @@ identify_android_image() {
# * "system" if the image should be mounted at '/android/system/'
# * "unknown" if neither is found

[ -f /tmpmnt/system.img ] && ANDROID_IMAGE_MODE="system"
[ -f /tmpmnt/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs"
[ -f /halium-system/var/lib/lxc/android/system.img ] && ANDROID_IMAGE_MODE="system"
[ -f /halium-system/var/lib/lxc/android/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs"
[ -z $ANDROID_IMAGE_MODE ] && ANDROID_IMAGE_MODE="unknown"
SYSTEM_SEARCH_PATHS="/halium-system/var/lib/lxc/android/system.img"
[ "${file_layout}" == "halium" ] && SYSTEM_SEARCH_PATHS="/tmpmnt/system.img ${SYSTEM_SEARCH_PATHS}"

ROOTFS_SEARCH_PATHS="/halium-system/var/lib/lxc/android/android-rootfs.img"
[ "${file_layout}" == "halium" ] && ROOTFS_SEARCH_PATHS="/tmpmnt/android-rootfs.img ${ROOTFS_SEARCH_PATHS}"

for image in ${SYSTEM_SEARCH_PATHS}; do
if [ -f "${image}" ]; then
ANDROID_IMAGE_MODE="system"
ANDROID_IMAGE="${image}"

return
fi
done

for image in ${ROOTFS_SEARCH_PATHS}; do
if [ -f "${image}" ]; then
ANDROID_IMAGE_MODE="rootfs"
ANDROID_IMAGE="${image}"

return
fi
done

ANDROID_IMAGE_MODE="unknown"
}

set_halium_version_properties() {
Expand Down Expand Up @@ -523,21 +543,15 @@ mountroot() {
# Mount the android system partition to a temporary location
MOUNT="ro"
MOUNT_LOCATION="/android-$ANDROID_IMAGE_MODE"
[ $ANDROID_IMAGE_MODE = "system" ] && ANDROID_IMAGE="system.img" || ANDROID_IMAGE="android-rootfs.img"
[ -e /tmpmnt/.writable_device_image -o -e /halium-system/.writable_device_image ] && MOUNT="rw"
tell_kmsg "mounting android system image (/tmpmnt/$ANDROID_IMAGE) $MOUNT, in $MOUNT_LOCATION ($ANDROID_IMAGE_MODE mode)"
if [ $file_layout = "halium" ]; then
# rootfs.img and Android system.img are separate
tell_kmsg "mounting android system image from userdata partition"
mount -o loop,$MOUNT "/tmpmnt/$ANDROID_IMAGE" $MOUNT_LOCATION
tell_kmsg "mounting android system image ($ANDROID_IMAGE) $MOUNT, in $MOUNT_LOCATION ($ANDROID_IMAGE_MODE mode)"
if [ -n "${ANDROID_IMAGE}" ]; then
mount -o loop,$MOUNT "$ANDROID_IMAGE" $MOUNT_LOCATION \
|| tell_kmsg "WARNING: Failed to mount Android system.img."
else
# Android system.img is inside rootfs
tell_kmsg "mounting android system image from system rootfs"
mount -o loop,$MOUNT "/halium-system/var/lib/lxc/android/$ANDROID_IMAGE" $MOUNT_LOCATION
tell_kmsg "WARNING: Unable to mount Android system image as it hasn't been found."
fi

[ $? -eq 0 ] || tell_kmsg "WARNING: Failed to mount Android system.img."

[ $ANDROID_IMAGE_MODE = "rootfs" ] && mount -o bind $MOUNT_LOCATION/system /android-system
[ $ANDROID_IMAGE_MODE = "system" ] && extract_android_ramdisk

Expand Down