update 2026-05-12 18:27:45

This commit is contained in:
action 2026-05-12 18:27:45 +08:00
parent 7f3005ed5a
commit 33be405a88
4 changed files with 64 additions and 44 deletions

View File

@ -16,7 +16,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-amlogic
PKG_VERSION:=3.1.306
PKG_VERSION:=3.1.309
PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0 License

View File

@ -461,9 +461,10 @@ return view.extend({
dom.content(verKernel, s && s.current_kernel_version
? E('span', { class: 'amlogic-status-ok' }, _('Current Version') + ' [ ' + s.current_kernel_version + ' ] ')
: E('span', { class: 'amlogic-status-err' }, _('Invalid value.')));
dom.content(branchSpan, s && s.current_kernel_branch
? ' [ ' + s.current_kernel_branch + '.y ] '
: ' [ ' + _('Invalid value.') + ' ]');
var branchLabel = s && s.plugin_branch
? (s.plugin_branch === 'lua' ? 'Lua' : 'JavaScript')
: (s && s.has_luci_js ? 'JavaScript' : 'Lua');
dom.content(branchSpan, ' [ ' + branchLabel + ' ] ');
// Rescue row: show same kernel version directly via the verRescue span
dom.content(verRescue, s && s.current_kernel_version

View File

@ -64,38 +64,39 @@ fi
tolog "PLATFORM: [ ${PLATFORM} ]"
sleep 2
# Read plugin branch from UCI config; default to auto-detect when missing or empty.
# When amlogic_plugin_branch is missing, add it and auto-detect from system.
if [[ -f "${AMLOGIC_CONFIG_FILE}" ]]; then
plugin_branch="$(uci get amlogic.config.amlogic_plugin_branch 2>/dev/null | xargs)"
if ! grep -q "amlogic_plugin_branch" "${AMLOGIC_CONFIG_FILE}" 2>/dev/null; then
# Auto-detect: JS LuCI → js branch, Lua LuCI → lua branch
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
plugin_branch="main"
else
plugin_branch="lua"
fi
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
uci commit amlogic 2>/dev/null
fi
else
# Config file missing, detect from system
# Read and resolve plugin_branch from UCI config.
# Normalise to canonical values: "main" (JS) or "lua".
# Priority: UCI value → auto-detect from system.
plugin_branch="$(uci get amlogic.config.amlogic_plugin_branch 2>/dev/null | tr '[:upper:]' '[:lower:]' | xargs)"
# Normalize aliases (js / javascript / main → "main"; anything else → "lua")
case "${plugin_branch}" in
js | javascript | main)
plugin_branch="main"
;;
lua)
plugin_branch="lua"
;;
*)
# Empty, unknown, or missing → auto-detect from system
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
plugin_branch="main"
else
plugin_branch="lua"
fi
;;
esac
# Safety check: "main" requires JS LuCI; fall back when absent
if [[ "${plugin_branch}" == "main" && ! -f "/www/luci-static/resources/luci.js" ]]; then
plugin_branch="lua"
tolog "Warning: JS LuCI not found, falling back to lua branch."
fi
# If branch is still empty (old config set it to ''), auto-detect
if [[ -z "${plugin_branch}" ]]; then
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
plugin_branch="main"
else
plugin_branch="lua"
fi
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
uci commit amlogic 2>/dev/null
fi
# Persist the resolved value back to UCI (covers migration + branch-switch cases)
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
uci commit amlogic 2>/dev/null
tolog "Plugin branch: [ ${plugin_branch} ]"
sleep 1
get_plugin_info() {

View File

@ -92,6 +92,31 @@ function show_install_menu() {
return m ? m[1] : 'Unknown';
}
// Detect whether OpenWrt's root fs is on internal storage (eMMC/NVMe/fixed disk).
// Returns true → already installed, hide the Install menu.
// Returns false → running from USB/SD, show the Install menu.
//
// sd* devices can be either USB (removable=1) or internal SATA (removable=0);
// we read /sys/block/<base_dev>/removable to distinguish them.
// mmcblk* and nvme* are always internal storage on these platforms.
function root_on_internal_storage() {
const root_pt = trim(sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'"));
if (!root_pt) return false;
if (match(root_pt, /^mmcblk[0-9]+p[0-9]+$/) || match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)) {
// eMMC and NVMe are always internal
return true;
}
if (match(root_pt, /^[hsv]d[a-z][0-9]+$/)) {
// Strip trailing partition digit(s) to get base device (e.g. sda2 → sda)
const base_dev = replace(root_pt, /[0-9]+$/, '');
const removable = trim(sh('cat /sys/block/' + shq(base_dev) + '/removable 2>/dev/null'));
// removable=0 → internal SATA/fixed disk; removable=1 → USB/removable
return (removable == '0');
}
return false;
}
// Pick the helper script names for the current platform (as the original
// controller did).
function platform_scripts() {
@ -225,7 +250,8 @@ function m_state() {
current_kernel_version: current_kernel_version(),
current_kernel_branch: current_kernel_branch(),
kernel_release: sh('uname -r'),
has_luci_js: access('/www/luci-static/resources/luci.js') ? true : false
has_luci_js: access('/www/luci-static/resources/luci.js') ? true : false,
plugin_branch: access('/usr/lib/lua/luci/controller/amlogic.lua') ? 'lua' : 'main'
};
}
@ -242,14 +268,10 @@ function m_platform_info() {
const can_install = (index(p, 'amlogic') >= 0 || index(p, 'allwinner') >= 0 || index(m, 'yes') >= 0);
// can_armcpu: all platforms except qemu support CPU frequency settings
const can_armcpu = (index(p, 'qemu') < 0);
// is_installed: root fs is on an internal storage device (mmcblk/sd/hd/vd),
// meaning OpenWrt has already been installed to eMMC/NVMe/disk. When true,
// the Install OpenWrt menu should be hidden.
const root_pt = sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'");
const is_installed = (root_pt != '' &&
(match(root_pt, /^mmcblk[0-9]+p[1-4]$/) ||
match(root_pt, /^[hsv]d[a-z][0-9]+$/) ||
match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)));
// is_installed: root fs is on an internal storage device (eMMC/NVMe/fixed disk).
// sd* devices may be USB (removable=1) or internal SATA (removable=0); check
// /sys/block/<dev>/removable to distinguish. When true the Install menu is hidden.
const is_installed = root_on_internal_storage();
return {
platform: p,
install_menu: m,
@ -719,11 +741,7 @@ function m_sync_menu() {
const p = platform();
const m = show_install_menu();
// Detect whether OpenWrt has already been installed to internal storage
const root_pt = sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'");
const is_installed = (root_pt != '' &&
(match(root_pt, /^mmcblk[0-9]+p[1-4]$/) ||
match(root_pt, /^[hsv]d[a-z][0-9]+$/) ||
match(root_pt, /^nvme[0-9]+n[0-9]+p[0-9]+$/)));
const is_installed = root_on_internal_storage();
const can_install = (index(p, 'amlogic') >= 0 || index(p, 'allwinner') >= 0 || index(m, 'yes') >= 0);
const show_install = (can_install && !is_installed) ? 'yes' : 'no';
const show_armcpu = (index(p, 'qemu') < 0) ? 'yes' : 'no';