mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
Merge pull request #3848 from sky42src/le92-early-squashfs
[le92] busybox: init: mount squashfs early
This commit is contained in:
commit
f979e6ab62
@ -15,6 +15,9 @@
|
|||||||
/usr/bin/busybox mkdir -p /sysroot
|
/usr/bin/busybox mkdir -p /sysroot
|
||||||
/usr/bin/busybox mkdir -p /storage
|
/usr/bin/busybox mkdir -p /storage
|
||||||
|
|
||||||
|
# temp mountpoint for updates
|
||||||
|
/usr/bin/busybox mkdir -p /update
|
||||||
|
|
||||||
# mount all needed special filesystems
|
# mount all needed special filesystems
|
||||||
/usr/bin/busybox mount -t devtmpfs devtmpfs /dev
|
/usr/bin/busybox mount -t devtmpfs devtmpfs /dev
|
||||||
/usr/bin/busybox mount -t proc proc /proc
|
/usr/bin/busybox mount -t proc proc /proc
|
||||||
@ -243,35 +246,40 @@ mount_part() {
|
|||||||
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
|
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount the specified SYSTEM file and output arch from /etc/os-release
|
mount_sysroot() {
|
||||||
get_project_arch() {
|
if [ "$SYSTEM_TORAM" = "yes" ]; then
|
||||||
mount_part "$1" "/sysroot" "ro,loop" || return
|
cp /flash/$IMAGE_SYSTEM /dev/$IMAGE_SYSTEM
|
||||||
|
mount_part "/dev/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
||||||
if [ -f /sysroot/etc/os-release ]; then
|
else
|
||||||
. /sysroot/etc/os-release
|
mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
||||||
echo "${LIBREELEC_ARCH:-${OPENELEC_ARCH}}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umount /sysroot
|
if [ -f /flash/post-sysroot.sh ]; then
|
||||||
|
. /flash/post-sysroot.sh
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the project/arch of current matches the upgrade, then it is considered compatible.
|
# mount the specified SYSTEM file and output arch from /etc/os-release
|
||||||
# Otherwise, mount the upgrade SYSTEM partition and, if canupdate.sh is available,
|
get_project_arch() {
|
||||||
# call the script to determine if the current upgrade file can be applied on to the
|
if [ -f ${1}/etc/os-release ]; then
|
||||||
|
. ${1}/etc/os-release
|
||||||
|
echo "${LIBREELEC_ARCH:-${OPENELEC_ARCH}}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# If the project/arch of current matches the update, then it is considered compatible.
|
||||||
|
# Otherwise, mount the update SYSTEM partition and, if canupdate.sh is available,
|
||||||
|
# call the script to determine if the current update file can be applied on to the
|
||||||
# current system - 0 means it is compatible, non-zero that it is not compatible.
|
# current system - 0 means it is compatible, non-zero that it is not compatible.
|
||||||
is_compatible() {
|
is_compatible() {
|
||||||
local result=1
|
local result=1
|
||||||
|
|
||||||
if [ "${2}" = "${3}" ]; then
|
if [ "${1}" = "${2}" ]; then
|
||||||
result=0
|
result=0
|
||||||
else
|
else
|
||||||
mount_part "$1" "/sysroot" "ro,loop"
|
if [ -f /update/usr/share/bootloader/canupdate.sh ]; then
|
||||||
|
sh /update/usr/share/bootloader/canupdate.sh "${1}" "${2}" && result=0
|
||||||
if [ -f /sysroot/usr/share/bootloader/canupdate.sh ]; then
|
|
||||||
sh /sysroot/usr/share/bootloader/canupdate.sh "${2}" "${3}" && result=0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umount /sysroot
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return ${result}
|
return ${result}
|
||||||
@ -280,17 +288,15 @@ is_compatible() {
|
|||||||
# determine if the new SYSTEM file is compatible with the current SYSTEM file
|
# determine if the new SYSTEM file is compatible with the current SYSTEM file
|
||||||
check_is_compatible() {
|
check_is_compatible() {
|
||||||
local update_filename="${1}"
|
local update_filename="${1}"
|
||||||
local old_system="${2}"
|
|
||||||
local new_system="${3}"
|
|
||||||
local old_project_arch new_project_arch
|
local old_project_arch new_project_arch
|
||||||
|
|
||||||
old_project_arch="$(get_project_arch "${old_system}")" || return
|
old_project_arch="$(get_project_arch "/sysroot")" || return
|
||||||
new_project_arch="$(get_project_arch "${new_system}")" || return
|
new_project_arch="$(get_project_arch "/update")" || return
|
||||||
|
|
||||||
# If old or new project/arch isn't available then could be very old (pre-/etc/os-release) build - have to trust it
|
# If old or new project/arch isn't available then could be very old (pre-/etc/os-release) build - have to trust it
|
||||||
if [ -n "${old_project_arch}" -a -n "${new_project_arch}" ]; then
|
if [ -n "${old_project_arch}" -a -n "${new_project_arch}" ]; then
|
||||||
# If the old project/arch is not compatible with the new project/arch then abort...
|
# If the old project/arch is not compatible with the new project/arch then abort...
|
||||||
if ! is_compatible "${new_system}" "${old_project_arch}" "${new_project_arch}"; then
|
if ! is_compatible "${old_project_arch}" "${new_project_arch}"; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "ERROR: $(basename "${update_filename}") is not compatible with ${old_project_arch} hardware - update cancelled."
|
echo "ERROR: $(basename "${update_filename}") is not compatible with ${old_project_arch} hardware - update cancelled."
|
||||||
echo ""
|
echo ""
|
||||||
@ -341,9 +347,7 @@ update_bootloader() {
|
|||||||
local result
|
local result
|
||||||
|
|
||||||
export BOOT_ROOT="/flash"
|
export BOOT_ROOT="/flash"
|
||||||
export SYSTEM_ROOT="/sysroot"
|
export SYSTEM_ROOT="/update"
|
||||||
|
|
||||||
mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
|
||||||
|
|
||||||
if [ -f $SYSTEM_ROOT/usr/share/bootloader/update.sh ]; then
|
if [ -f $SYSTEM_ROOT/usr/share/bootloader/update.sh ]; then
|
||||||
StartProgress spinner "Updating Boot Files... "
|
StartProgress spinner "Updating Boot Files... "
|
||||||
@ -352,8 +356,6 @@ update_bootloader() {
|
|||||||
StopProgress "done"
|
StopProgress "done"
|
||||||
[ -n "${result}" ] && echo "${result}"
|
[ -n "${result}" ] && echo "${result}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umount /sysroot
|
|
||||||
}
|
}
|
||||||
|
|
||||||
load_modules() {
|
load_modules() {
|
||||||
@ -640,7 +642,7 @@ check_out_of_space() {
|
|||||||
if [ "$(df /storage | awk '/[0-9]%/{print $4}')" -eq "0" ]; then
|
if [ "$(df /storage | awk '/[0-9]%/{print $4}')" -eq "0" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "The $1 is corrupt, or there is not enough"
|
echo "The $1 is corrupt, or there is not enough"
|
||||||
echo "free space on /storage to complete the upgrade!"
|
echo "free space on /storage to complete the update!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please free up space on your /storage partition"
|
echo "Please free up space on your /storage partition"
|
||||||
echo "by deleting unecessary files, then try again."
|
echo "by deleting unecessary files, then try again."
|
||||||
@ -708,7 +710,7 @@ check_update() {
|
|||||||
mkdir -p $UPDATE_DIR/.tmp &>/dev/null
|
mkdir -p $UPDATE_DIR/.tmp &>/dev/null
|
||||||
sync
|
sync
|
||||||
|
|
||||||
echo "UPGRADE IN PROGRESS"
|
echo "UPDATE IN PROGRESS"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please do not reboot or turn off your @DISTRONAME@ device!"
|
echo "Please do not reboot or turn off your @DISTRONAME@ device!"
|
||||||
echo ""
|
echo ""
|
||||||
@ -859,10 +861,12 @@ check_update() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify that the new upgrade is compatible with the current system - this should avoid creating
|
mount_part "$UPDATE_DIR/$UPDATE_SYSTEM" "/update" "ro,loop"
|
||||||
|
|
||||||
|
# Verify that the new update is compatible with the current system - this should avoid creating
|
||||||
# non-booting systems after (for example) an RPi tar is incorrectly applied to an RPi2 system.
|
# non-booting systems after (for example) an RPi tar is incorrectly applied to an RPi2 system.
|
||||||
if [ ! -f "$UPDATE_ROOT/.nocompat" ]; then
|
if [ ! -f "$UPDATE_ROOT/.nocompat" ]; then
|
||||||
if ! check_is_compatible "$UPDATE_FILENAME" "/flash/$IMAGE_SYSTEM" "$UPDATE_DIR/$UPDATE_SYSTEM"; then
|
if ! check_is_compatible "$UPDATE_FILENAME"; then
|
||||||
do_cleanup
|
do_cleanup
|
||||||
StartProgress countdown "Normal startup in 60s... " 60 "NOW"
|
StartProgress countdown "Normal startup in 60s... " 60 "NOW"
|
||||||
return 0
|
return 0
|
||||||
@ -913,8 +917,10 @@ check_update() {
|
|||||||
else
|
else
|
||||||
update_file "Kernel" "$UPDATE_KERNEL" "/flash/$IMAGE_KERNEL"
|
update_file "Kernel" "$UPDATE_KERNEL" "/flash/$IMAGE_KERNEL"
|
||||||
fi
|
fi
|
||||||
|
umount /sysroot
|
||||||
update_file "System" "$UPDATE_SYSTEM" "/flash/$IMAGE_SYSTEM"
|
update_file "System" "$UPDATE_SYSTEM" "/flash/$IMAGE_SYSTEM"
|
||||||
update_bootloader
|
update_bootloader
|
||||||
|
umount /update
|
||||||
do_cleanup
|
do_cleanup
|
||||||
do_reboot
|
do_reboot
|
||||||
}
|
}
|
||||||
@ -922,13 +928,6 @@ check_update() {
|
|||||||
prepare_sysroot() {
|
prepare_sysroot() {
|
||||||
progress "Preparing system"
|
progress "Preparing system"
|
||||||
|
|
||||||
if [ "$SYSTEM_TORAM" = "yes" ]; then
|
|
||||||
cp /flash/$IMAGE_SYSTEM /dev/$IMAGE_SYSTEM
|
|
||||||
mount_part "/dev/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
|
||||||
else
|
|
||||||
mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mount --move /flash /sysroot/flash
|
mount --move /flash /sysroot/flash
|
||||||
mount --move /storage /sysroot/storage
|
mount --move /storage /sysroot/storage
|
||||||
|
|
||||||
@ -1086,6 +1085,7 @@ for BOOT_STEP in \
|
|||||||
cleanup_flash \
|
cleanup_flash \
|
||||||
update_bootmenu \
|
update_bootmenu \
|
||||||
load_splash \
|
load_splash \
|
||||||
|
mount_sysroot \
|
||||||
mount_storage \
|
mount_storage \
|
||||||
check_update \
|
check_update \
|
||||||
prepare_sysroot; do
|
prepare_sysroot; do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user