core: prefer raw binary on compressed rom, avoid upx on tmpfs devices

Adds store_on_rom() helper (tmpfs $TMPDIR + squashfs/ubifs/overlay
$BINDIR). On such devices core_webget no longer downloads the upx core
(its stub decompresses into a memfd = RAM at runtime); it fetches the
tar.gz instead and core_check stores the naked binary as
$BINDIR/CrashCore.raw, symlinked from $TMPDIR. The binary is
transparently compressed on rom and file-backed/reclaimable at runtime
(RssShmem 0). Other filesystems and explicit upx keep prior behavior.

Also corrects the upx branch symlink target $TMPDIR -> $BINDIR (same
dangling-symlink issue as #1295).

For #1304
This commit is contained in:
Xiaoyi
2026-07-11 15:59:42 +08:00
parent edd6936903
commit 55cfa65875

View File

@@ -2,6 +2,14 @@
[ -n "$(find --help 2>&1 | grep -o size)" ] && find_para=' -size +2000' #find命令兼容
#$TMPDIR为内存(tmpfs)且$BINDIR在透明压缩文件系统(squashfs/ubifs/overlay)上时返回0
#此类设备应把裸二进制存于$BINDIR(rom透明压缩)并软链,而非解压/memfd占用内存
store_on_rom(){
case "$(df -T "$TMPDIR" 2>/dev/null | awk 'END{print $2}')" in tmpfs|ramfs) ;; *) return 1 ;; esac
case "$(df -T "$BINDIR" 2>/dev/null | awk 'END{print $2}')" in squashfs|ubifs|overlay|overlayfs) return 0 ;; esac
return 1
}
core_unzip() { #$1:需要解压的文件 $2:目标文件名
if echo "$1" |grep -q 'tar.gz$' ;then
[ "$BINDIR" = "$TMPDIR" ] && rm -rf "$TMPDIR"/CrashCore #小闪存模式防止空间不足
@@ -48,18 +56,11 @@ core_check(){
return 2
else
rm -f "$BINDIR"/CrashCore.tar.gz "$BINDIR"/CrashCore.gz "$BINDIR"/CrashCore.upx "$BINDIR"/CrashCore.raw
#$TMPDIR为内存(tmpfs)且$BINDIR为透明压缩文件系统(squashfs/ubifs)时,直接以裸二进制存于$BINDIR并软链省内存
store_raw=0
tmp_fs=$(df -T "$TMPDIR" 2>/dev/null | awk 'END{print $2}')
rom_fs=$(df -T "$BINDIR" 2>/dev/null | awk 'END{print $2}')
case "$tmp_fs" in tmpfs|ramfs)
case "$rom_fs" in squashfs|ubifs|overlay|overlayfs) store_raw=1 ;; esac ;;
esac
if [ "$zip_type" = 'upx' ];then
mv -f "$1" "$BINDIR/CrashCore.upx"
rm -f "$TMPDIR"/core_new
ln -sf "$BINDIR/CrashCore.upx" "$TMPDIR/CrashCore"
elif [ "$store_raw" = 1 ];then
elif store_on_rom ;then
rm -f "$1"
mv -f "$TMPDIR/core_new" "$BINDIR/CrashCore.raw"
ln -sf "$BINDIR/CrashCore.raw" "$TMPDIR/CrashCore"
@@ -83,6 +84,8 @@ core_webget(){
. "$CRASHDIR"/libs/check_target.sh
if [ -z "$custcorelink" ];then
[ -z "$zip_type" ] && zip_type='tar.gz'
#压缩rom+内存tmp设备避免下载upx(运行时memfd占RAM)改取tar.gz的裸二进制存于rom
[ "$zip_type" = 'upx' ] && store_on_rom && zip_type='tar.gz'
get_bin "$TMPDIR/Coretmp.$zip_type" "bin/$crashcore/${target}-linux-${cpucore}.$zip_type"
else
case "$custcorelink" in