d3b6b90d45
* upstream/dev: (52 commits) Fix udevil regression. Fix game migration to new path during post-update. Bump AMD64 kernel to 6.6.4. Bump Kernel to 6.1.65 on supported devices Fix merged storage to switch on and off correctly. Hide internal/external switch, but make it available as system.merged.device (1/0). Yuzu-sa - Add cpu accuracy ES feature Additional merged storage optimizations, add a script to remove empty directories that may cause overlay issues. Disable merged storage by default, fix bind mount to use correct (updated) path. * Add support for changing the merged storage target between the internal and external card. * Since JELOS creates the games directory structure it is possible that the overlay will hide games if you switch targets as it will consider them removed. Delete the empty directories and reboot to resolve. * Ex: find /storage/games-internal -type d -empty -delete && find /storage/games-external -type d -empty -delete && reboot * Merged storage can now be disabled persistently. * A new directory structure is required to enable switching: * /storage/games-internal/roms * /storage/games-external/roms * The target /storage/roms has not changed. * Lowers clocks to powersave for RK3566 devices. Remove stale profile bits that still seem to exist on some devices and break audio. Remove stale xorg bits from package. Bump Citra-SA and Yuzu-SA Switch the xorg-server package to xwayland. Tested the emulators that appeared to depend on it, they seemed to start up ok. Yuzu-SA: never ask to confirm close Add Yuzu Rumble Strength Feature Amlogic/linux: remove unneeded drm panel orientation quirk Amlogic/linux: silence dmesg spam Amlogic/linux: remove 1908 opp as this is not present in the bsp Amlogic/linux: simplify rgb10-max3-pro device tree Fix mesa oops ...
244 lines
6.3 KiB
Bash
Executable file
244 lines
6.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
|
|
|
. /etc/profile
|
|
. /etc/os-release
|
|
|
|
### Vars
|
|
UPDATE_ROOT="/storage/.update"
|
|
MOUNT_GAMES=$(get_setting system.automount)
|
|
GAMES_DEVICE=$(get_setting system.gamesdevice)
|
|
MS_ENABLED=$(get_setting system.merged.storage)
|
|
MS_DEVICE=$(get_setting system.merged.device)
|
|
|
|
### Default to the external storage device.
|
|
MOUNT_PATH="/storage/games-external"
|
|
|
|
MS_PATH="/storage/roms"
|
|
|
|
function unmount() {
|
|
log $0 "Unmount ${1}."
|
|
umount -f "${1}" 2>/dev/null ||:
|
|
}
|
|
|
|
function start_ms() {
|
|
### Entrypoint will be either games card found (external), or not found (internal).
|
|
MOUNT_PATH="/storage/games-${1}"
|
|
|
|
### Determine if internal or external is the primary target by configuration.
|
|
case ${MS_DEVICE} in
|
|
internal)
|
|
LOWER="internal"
|
|
UPPER="external"
|
|
;;
|
|
*)
|
|
LOWER="external"
|
|
UPPER="internal"
|
|
;;
|
|
esac
|
|
|
|
if [ -e "/storage/.ms_unsupported" ] || \
|
|
[ "${MS_ENABLED}" = 0 ]
|
|
then
|
|
log $0 "Executing bind mount of ${MOUNT_PATH} to ${MS_PATH}"
|
|
mount --bind ${MOUNT_PATH}/roms ${MS_PATH}
|
|
exit 0
|
|
else
|
|
log $0 "Enabling merged storage of /storage/games-${LOWER} and /storage/games-${UPPER} to ${MS_PATH}."
|
|
|
|
for DIR in /storage/games-${UPPER}/.tmp/games-workdir /storage/games-${LOWER}/roms /storage/games-${UPPER}/roms
|
|
do
|
|
if [ ! -d "${DIR}" ]
|
|
then
|
|
mkdir -p "${DIR}"
|
|
fi
|
|
done
|
|
mount overlay -t overlay -o lowerdir=/storage/games-${LOWER}/roms,upperdir=/storage/games-${UPPER}/roms,workdir=/storage/games-${UPPER}/.tmp/games-workdir ${MS_PATH}
|
|
fi
|
|
}
|
|
|
|
start_overlay() {
|
|
if [ -e "/storage/.overlay_unsupported" ]
|
|
then
|
|
# If we're not using the overlay, bind mount the external storage path
|
|
# so we don't need to change any configs.
|
|
grep ${MOUNT_PATH} /proc/mounts >/dev/null 2>&1
|
|
if [ ! $? = 0 ]
|
|
then
|
|
MOUNT_PATH="/storage/games-internal"
|
|
fi
|
|
log $0 "Executing bind mount of ${MOUNT_PATH} to ${OVERLAY_PATH}"
|
|
mount --bind ${MOUNT_PATH} ${OVERLAY_PATH}
|
|
exit 0
|
|
else
|
|
log $0 "Enabling overlay."
|
|
systemctl enable storage-roms.mount >/dev/null 2>&1
|
|
systemctl start storage-roms.mount >/dev/null 2>&1
|
|
fi
|
|
}
|
|
|
|
if [[ ! "${MOUNT_GAMES}" =~ [0-9] ]]
|
|
then
|
|
set_setting system.automount 1
|
|
elif [[ "${MOUNT_GAMES}" == "0" ]]
|
|
then
|
|
<<<<<<< HEAD
|
|
start_overlay
|
|
exit 0
|
|
fi
|
|
|
|
=======
|
|
start_ms internal
|
|
exit 0
|
|
fi
|
|
|
|
function create_game_dirs() {
|
|
systemd-tmpfiles --create /usr/lib/tmpfiles.d/JELOS-system-dirs.conf >/dev/null 2>&1 ||:
|
|
}
|
|
|
|
>>>>>>> upstream/dev
|
|
function load_modules() {
|
|
for MODULE in exfat vfat
|
|
do
|
|
lsmod | grep ${MODULE} >/dev/null 2>&1
|
|
if [ ! $? = 0 ]
|
|
then
|
|
log $0 "Loading ${MODULE}."
|
|
<<<<<<< HEAD
|
|
modprobe ${MODULE} 2>/dev/null
|
|
=======
|
|
modprobe ${MODULE} >/dev/null 2>&1
|
|
>>>>>>> upstream/dev
|
|
fi
|
|
done
|
|
}
|
|
|
|
function mount_games() {
|
|
<<<<<<< HEAD
|
|
=======
|
|
local MOUNT_PATH="/storage/games-external"
|
|
>>>>>>> upstream/dev
|
|
FSTYPE=$(blkid -o export ${1} | awk 'BEGIN {FS="="} /TYPE/ {print $2}')
|
|
case ${FSTYPE} in
|
|
ext4)
|
|
log $0 "Found supported partition for overlayfs."
|
|
<<<<<<< HEAD
|
|
if [ -e "/storage/.overlay_unsupported" ]
|
|
=======
|
|
if [ -e "/storage/.ms_unsupported" ]
|
|
>>>>>>> upstream/dev
|
|
then
|
|
rm -f /storage/.ms_unsupported
|
|
fi
|
|
touch /storage/.ms_supported
|
|
;;
|
|
*)
|
|
log $0 "Partition does not support overlayfs, disabling."
|
|
<<<<<<< HEAD
|
|
if [ -e "/storage/.overlay_supported" ]
|
|
=======
|
|
if [ -e "/storage/.ms_supported" ]
|
|
>>>>>>> upstream/dev
|
|
then
|
|
rm -f /storage/.ms_supported
|
|
fi
|
|
touch /storage/.ms_unsupported
|
|
;;
|
|
esac
|
|
|
|
if [ ! -d "${MOUNT_PATH}" ]
|
|
then
|
|
log $0 "Create directory ${MOUNT_PATH}"
|
|
/usr/bin/busybox mkdir -p ${MOUNT_PATH} >/dev/null 2>&1
|
|
fi
|
|
|
|
NULL=$(cat /proc/mounts | grep -v -e "/var/media" 2>/dev/null | grep ${1})
|
|
if [ ! "$?" = "0" ] && \
|
|
[ -e "${1}" ] && \
|
|
[ ! -e "/storage/.please_resize_me" ]
|
|
then
|
|
|
|
### Udevil shouldn't mount it this early, but just in-case.
|
|
umount /var/media/* 2>/dev/null
|
|
<<<<<<< HEAD
|
|
log $0 "Checking filesystem ${1}."
|
|
fsck -Mly ${1} >/dev/null 2>&1
|
|
log $0 "Mounting ${1} on ${MOUNT_PATH}"
|
|
/usr/bin/busybox mount ${1} ${MOUNT_PATH} >/dev/null 2>&1
|
|
fi
|
|
start_overlay
|
|
}
|
|
|
|
find_games() {
|
|
if /usr/bin/busybox mountpoint -q /storage ; then
|
|
=======
|
|
|
|
log $0 "Checking filesystem ${1}."
|
|
fsck -Mly ${1} >/dev/null 2>&1
|
|
|
|
log $0 "Mounting ${1} on ${MOUNT_PATH}"
|
|
/usr/bin/busybox mount ${1} ${MOUNT_PATH} >/dev/null 2>&1
|
|
fi
|
|
start_ms external
|
|
create_game_dirs
|
|
exit 0
|
|
}
|
|
|
|
function find_games() {
|
|
if /usr/bin/busybox mountpoint -q /storage
|
|
then
|
|
>>>>>>> upstream/dev
|
|
for DEV in $(for dev in mmcblk[0-9] sd[a-z] nvme[0-9]; do blkid | grep ${dev} | awk 'BEGIN {FS=":"}; /ext4/ || /fat/ {print $1}' | sort -r; done)
|
|
do
|
|
ROOTDEV=$(echo ${DEV} | sed -e "s#^/.*/##g" -e "s#p[0-9].*\$##g")
|
|
log $0 "Inspecting ${DEV}."
|
|
SIZE=$(awk '/'${ROOTDEV}'$/ {print $3}' /proc/partitions)
|
|
if (( ${SIZE} <= 8388608 ))
|
|
then
|
|
log $0 "Device ${ROOTDEV} is too small, ignoring."
|
|
# We don't want to mount partitions smaller than ~8GB.
|
|
continue
|
|
fi
|
|
if [ -L "/sys/class/block/${ROOTDEV}boot0" ]
|
|
then
|
|
log $0 "Device ${ROOTDEV} might be Android, ignoring."
|
|
# Assume this is an android boot device and ignore it.
|
|
continue
|
|
fi
|
|
if [ -e "${DEV}" ] && \
|
|
[ ! -e "/storage/.please_resize_me" ]
|
|
then
|
|
GAMES_DEVICE=${DEV}
|
|
log $0 "Found ${DEV} available to mount."
|
|
mount_games "${DEV}"
|
|
else
|
|
log $0 "${DEV} not available."
|
|
fi
|
|
done
|
|
<<<<<<< HEAD
|
|
# If we're here there is no external storage to use, but we want to start the overlay anyway.
|
|
start_overlay
|
|
=======
|
|
log $0 "Could not find external card to mount, assume internal."
|
|
start_ms internal
|
|
create_game_dirs
|
|
exit 0
|
|
>>>>>>> upstream/dev
|
|
fi
|
|
}
|
|
|
|
## Main..
|
|
|
|
load_modules
|
|
|
|
### Unmount any existing storage before beginning operations.
|
|
unmount /storage/games-external
|
|
unmount /storage/roms
|
|
|
|
if [ -e "${GAMES_DEVICE}" ]
|
|
then
|
|
mount_games ${GAMES_DEVICE}
|
|
else
|
|
find_games
|
|
fi
|