mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-07-27 08:31:44 +08:00
update 2026-05-12 18:27:45
This commit is contained in:
parent
7f3005ed5a
commit
33be405a88
@ -16,7 +16,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-amlogic
|
PKG_NAME:=luci-app-amlogic
|
||||||
PKG_VERSION:=3.1.306
|
PKG_VERSION:=3.1.309
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_LICENSE:=GPL-2.0 License
|
PKG_LICENSE:=GPL-2.0 License
|
||||||
|
|||||||
@ -461,9 +461,10 @@ return view.extend({
|
|||||||
dom.content(verKernel, s && s.current_kernel_version
|
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-ok' }, _('Current Version') + ' [ ' + s.current_kernel_version + ' ] ')
|
||||||
: E('span', { class: 'amlogic-status-err' }, _('Invalid value.')));
|
: E('span', { class: 'amlogic-status-err' }, _('Invalid value.')));
|
||||||
dom.content(branchSpan, s && s.current_kernel_branch
|
var branchLabel = s && s.plugin_branch
|
||||||
? ' [ ' + s.current_kernel_branch + '.y ] '
|
? (s.plugin_branch === 'lua' ? 'Lua' : 'JavaScript')
|
||||||
: ' [ ' + _('Invalid value.') + ' ]');
|
: (s && s.has_luci_js ? 'JavaScript' : 'Lua');
|
||||||
|
dom.content(branchSpan, ' [ ' + branchLabel + ' ] ');
|
||||||
|
|
||||||
// Rescue row: show same kernel version directly via the verRescue span
|
// Rescue row: show same kernel version directly via the verRescue span
|
||||||
dom.content(verRescue, s && s.current_kernel_version
|
dom.content(verRescue, s && s.current_kernel_version
|
||||||
|
|||||||
@ -64,38 +64,39 @@ fi
|
|||||||
tolog "PLATFORM: [ ${PLATFORM} ]"
|
tolog "PLATFORM: [ ${PLATFORM} ]"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Read plugin branch from UCI config; default to auto-detect when missing or empty.
|
# Read and resolve plugin_branch from UCI config.
|
||||||
# When amlogic_plugin_branch is missing, add it and auto-detect from system.
|
# Normalise to canonical values: "main" (JS) or "lua".
|
||||||
if [[ -f "${AMLOGIC_CONFIG_FILE}" ]]; then
|
# Priority: UCI value → auto-detect from system.
|
||||||
plugin_branch="$(uci get amlogic.config.amlogic_plugin_branch 2>/dev/null | xargs)"
|
plugin_branch="$(uci get amlogic.config.amlogic_plugin_branch 2>/dev/null | tr '[:upper:]' '[:lower:]' | xargs)"
|
||||||
if ! grep -q "amlogic_plugin_branch" "${AMLOGIC_CONFIG_FILE}" 2>/dev/null; then
|
|
||||||
# Auto-detect: JS LuCI → js branch, Lua LuCI → lua branch
|
# Normalize aliases (js / javascript / main → "main"; anything else → "lua")
|
||||||
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
|
case "${plugin_branch}" in
|
||||||
plugin_branch="main"
|
js | javascript | main)
|
||||||
else
|
plugin_branch="main"
|
||||||
plugin_branch="lua"
|
;;
|
||||||
fi
|
lua)
|
||||||
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
|
plugin_branch="lua"
|
||||||
uci commit amlogic 2>/dev/null
|
;;
|
||||||
fi
|
*)
|
||||||
else
|
# Empty, unknown, or missing → auto-detect from system
|
||||||
# Config file missing, detect from system
|
|
||||||
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
|
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
|
||||||
plugin_branch="main"
|
plugin_branch="main"
|
||||||
else
|
else
|
||||||
plugin_branch="lua"
|
plugin_branch="lua"
|
||||||
fi
|
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
|
fi
|
||||||
# If branch is still empty (old config set it to ''), auto-detect
|
|
||||||
if [[ -z "${plugin_branch}" ]]; then
|
# Persist the resolved value back to UCI (covers migration + branch-switch cases)
|
||||||
if [[ -f "/www/luci-static/resources/luci.js" ]]; then
|
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
|
||||||
plugin_branch="main"
|
uci commit amlogic 2>/dev/null
|
||||||
else
|
|
||||||
plugin_branch="lua"
|
|
||||||
fi
|
|
||||||
uci set amlogic.config.amlogic_plugin_branch="${plugin_branch}" 2>/dev/null
|
|
||||||
uci commit amlogic 2>/dev/null
|
|
||||||
fi
|
|
||||||
tolog "Plugin branch: [ ${plugin_branch} ]"
|
tolog "Plugin branch: [ ${plugin_branch} ]"
|
||||||
sleep 1
|
sleep 1
|
||||||
get_plugin_info() {
|
get_plugin_info() {
|
||||||
|
|||||||
@ -92,6 +92,31 @@ function show_install_menu() {
|
|||||||
return m ? m[1] : 'Unknown';
|
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
|
// Pick the helper script names for the current platform (as the original
|
||||||
// controller did).
|
// controller did).
|
||||||
function platform_scripts() {
|
function platform_scripts() {
|
||||||
@ -225,7 +250,8 @@ function m_state() {
|
|||||||
current_kernel_version: current_kernel_version(),
|
current_kernel_version: current_kernel_version(),
|
||||||
current_kernel_branch: current_kernel_branch(),
|
current_kernel_branch: current_kernel_branch(),
|
||||||
kernel_release: sh('uname -r'),
|
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);
|
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
|
// can_armcpu: all platforms except qemu support CPU frequency settings
|
||||||
const can_armcpu = (index(p, 'qemu') < 0);
|
const can_armcpu = (index(p, 'qemu') < 0);
|
||||||
// is_installed: root fs is on an internal storage device (mmcblk/sd/hd/vd),
|
// is_installed: root fs is on an internal storage device (eMMC/NVMe/fixed disk).
|
||||||
// meaning OpenWrt has already been installed to eMMC/NVMe/disk. When true,
|
// sd* devices may be USB (removable=1) or internal SATA (removable=0); check
|
||||||
// the Install OpenWrt menu should be hidden.
|
// /sys/block/<dev>/removable to distinguish. When true the Install menu is hidden.
|
||||||
const root_pt = sh("df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print $3}'");
|
const is_installed = root_on_internal_storage();
|
||||||
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]+$/)));
|
|
||||||
return {
|
return {
|
||||||
platform: p,
|
platform: p,
|
||||||
install_menu: m,
|
install_menu: m,
|
||||||
@ -719,11 +741,7 @@ function m_sync_menu() {
|
|||||||
const p = platform();
|
const p = platform();
|
||||||
const m = show_install_menu();
|
const m = show_install_menu();
|
||||||
// Detect whether OpenWrt has already been installed to internal storage
|
// 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_on_internal_storage();
|
||||||
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 can_install = (index(p, 'amlogic') >= 0 || index(p, 'allwinner') >= 0 || index(m, 'yes') >= 0);
|
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_install = (can_install && !is_installed) ? 'yes' : 'no';
|
||||||
const show_armcpu = (index(p, 'qemu') < 0) ? 'yes' : 'no';
|
const show_armcpu = (index(p, 'qemu') < 0) ? 'yes' : 'no';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user