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

optional exFAT partition #1830

Draft
wants to merge 5 commits into
base: Lakka-v5.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
22 changes: 19 additions & 3 deletions packages/lakka/retroarch_base/retroarch/scripts/retroarch-config
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@ echo "LD_LIBRARY_PATH=\"/usr/lib:/tmp/cores\"" >> /run/libreelec/retroarch.conf
# which makes the combined controller index 2, but on Nintendo Switch Lite, on first boot we need to change this to 1
# or built in gamepad needs user intervention to be used.

SERIAL_PREFIX=$(cat /sys/firmware/devicetree/base/serial-number)
SERIAL_PREFIX=${SERIAL_PREFIX:0:3}
if [ -e /sys/firmware/devicetree/base/serial-number ]; then
SERIAL_PREFIX="$(cat /sys/firmware/devicetree/base/serial-number)"
SERIAL_PREFIX="${SERIAL_PREFIX:0:3}"
else
SERIAL_PREFIX=""
fi

if [ ${SERIAL_PREFIX} = "NXV" -a ! -f /storage/.config/retroarch/retroarch.cfg ]; then
if [ "${SERIAL_PREFIX}" = "NXV" -a ! -f /storage/.config/retroarch/retroarch.cfg ]; then
cp /etc/retroarch.cfg /storage/.config/retroarch/retroarch.cfg
sed -i -e 's|input_player1_joypad_index = \"2\"|input_player1_joypad_index = \"0\"|' /storage/.config/retroarch/retroarch.cfg
fi

if [ -d /storage/roms/EXFAT/bios ]; then
for bios in /storage/roms/EXFAT/bios/* ; do
if [ -e "${bios}" ]; then
[ ! -d /storage/roms/EXFAT/bios_copied ] && mkdir -p /storage/roms/EXFAT/bios_copied
echo -n "Copy: " >> /storage/roms/EXFAT/bios/copied/transfer_log.txt
cp -vr "${bios}" /tmp/system >> /storage/roms/EXFAT/bios_copied/transfer_log.txt 2>&1
echo -n "Backup: " >> /storage/roms/EXFAT/bios/copied/transfer_log.txt
mv -v "${bios}" /storage/roms/EXFAT/bios_copied >> /storage/roms/EXFAT/bios_copied/transfer_log.txt 2>&1
fi
done
fi
66 changes: 61 additions & 5 deletions packages/sysutils/busybox/scripts/fs-resize
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,57 @@ if [ -e /storage/.please_resize_me ] ; then
reboot -f
fi

# also not intended on Switch/Odin, which add fat32-boot to cmdline
FAT32_BOOT="no"
for arg in $(cat /proc/cmdline); do
case $arg in
fat32-boot)
FAT32_BOOT="yes"
;;
*)
;;
esac
done

if [ "$FAT32_BOOT" = "yes" ]; then
rm -f /storage/.please_resize_me
sync
echo "Some Vogons"
echo " wanted to"
echo " destroy"
echo " your device."
echo ""
echo ""
echo " **** *** * * * *****"
echo " * * * * ** * * *"
echo " * * * * * * * *"
echo " * * * * * ** *"
echo " **** *** * * *"
echo ""
echo " **** *** * * *** ***"
echo " * * * * ** * * * *"
echo " **** ***** * * * * *"
echo " * * * * ** * * *"
echo " * * * * * *** ***"
echo ""
echo " and enjoy this cute little counter :-)"
echo ""
StartProgress countdown " " 42 "NOW"
reboot -f
fi

# get the disk. /storage on 2nd partition
PART=$(grep "/storage " /proc/mounts | cut -d" " -f1 | grep '2$')

# get disk: /dev/sdx2 -> /dev/sdx, /dev/mmcblkxp2 -> /dev/mmcblkx
case $PART in
"/dev/mmcblk"*)
DISK=$(echo $PART | sed s/p2$//g)
EXPART="${DISK}p3"
;;
*)
DISK=$(echo $PART | sed s/2$//g)
EXPART="${DISK}3"
;;
esac

Expand All @@ -46,13 +87,28 @@ if [ -e /storage/.please_resize_me ] ; then
# identify the partition scheme, and if gpt fix minor issues such as gpt header not at end of disk
SCHEME=$(blkid -s PTTYPE -o value $DISK)
if [ "$SCHEME" = "gpt" ]; then
StartProgress spinner "Checking layout... " "sgdisk -e $DISK &>/dev/null"
StartProgress spinner "Checking layout... " "sgdisk -e $DISK &>/dev/null"
EXPARTTYPE="'EXFAT'"
else
EXPARTTYPE="primary"
fi

StartProgress spinner "Resizing partition... " "parted -s -m $DISK resizepart 2 100% &>/dev/null"
StartProgress spinner "Checking file system... " "e2fsck -f -p $PART &>/dev/null"
StartProgress spinner "Resizing file system... " "resize2fs $PART &>/dev/null"
StartProgress countdown "Rebooting in 15s... " 15 "NOW"
if [ -e /flash/create_exfat ] ; then
StartProgress spinner "Getting disk information... " "parted -s -f -m $DISK print all &>/dev/null"
StartProgress spinner "Resizing ext4 partition... " "parted -s -m $DISK resizepart 2 4GiB &>/dev/null"
StartProgress spinner "Checking file system... " "e2fsck -f -p $PART &>/dev/null"
StartProgress spinner "Resizing file system... " "resize2fs $PART &>/dev/null"
StartProgress spinner "Updating disk information... " "parted -s -f -m $DISK print all &>/dev/null"
EXSTART="$(( $(parted -s -f -m $DISK print all 2>/dev/null | grep -m1 ^2: | cut -d: -f3 | sed -e s/MB//) + 17 ))"
StartProgress spinner "Creating exFAT partition... " "parted -s -f -m $DISK mkpart $EXPARTTYPE ntfs ${EXSTART}MB 100% &>/dev/null"
StartProgress spinner "Probing partitions... " "partprobe &>/dev/null"
StartProgress spinner "Formatting exFAT partition... " "mkfs.exfat -f -L EXFAT $EXPART &>/dev/null"
else
StartProgress spinner "Resizing ext4 partition... " "parted -s -m $DISK resizepart 2 100% &>/dev/null"
StartProgress spinner "Checking file system... " "e2fsck -f -p $PART &>/dev/null"
StartProgress spinner "Resizing file system... " "resize2fs $PART &>/dev/null"
fi
StartProgress countdown "Rebooting in 15s... " 15 "NOW"
fi
fi
reboot -f &>/dev/null
6 changes: 6 additions & 0 deletions scripts/mkimage
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ elif [ "${BOOTLOADER}" = "u-boot" ]; then
exit
fi # bootloader

if [ "${DISTRO}" = "Lakka" ];then
# create placeholder for exFAT partition trigger.
touch ${LE_TMP}/no_create_exfat
mcopy -s "${LE_TMP}/no_create_exfat" :: >"${SAVE_ERROR}" 2>&1 || show_error
fi

# run fsck
echo "image: checking filesystem on part1..."
sync
Expand Down