Skip to content

Commit 95a01b4

Browse files
committed
desktops: detect installed DE via marker file, add Bianbu menu entries
`module_desktops status de=<X>` is the gate every Desktops submenu entry runs to decide whether to show its "Uninstall / Disable login / Change tier" actions. The check was a plain `dpkg -l "$DESKTOP_PRIMARY_PKG" | grep ^ii`, which misfires whenever two desktops share a primary-tier package — most notably on a Bianbu install, where bianbu-desktop-minimal-en pulls gnome-session as a dependency. The Desktops menu would then offer "Uninstall GNOME" and "Change GNOME to full" while the actual installed DE is Bianbu, and clicking them would tear down packages Bianbu owns. Three coupled changes, since fixing detection without also rounding out the Bianbu menu would leave a Bianbu user with an empty submenu and only a single mid-tier install entry where every other DE exposes minimal/mid/full: 1. Introduce _module_desktops_is_installed and route the three status callers (status, tier, at-tier) through it. Three layers, falling through in order: a. /etc/armbian/desktop/<de>.tier exists → installed. Authoritative because install/remove maintain the marker. b. A different DE has its marker present → not installed. The other DE's marker is the tiebreaker against the dpkg fallback when desktops share packages. c. No markers anywhere AND DESKTOP_PRIMARY_PKG is dpkg-installed → legacy installs that pre-date the marker convention or were done with apt directly. 2. Add the standard six management entries for Bianbu in config.system.json (Uninstall, autologin on/off, tier minimal/mid/full), gated on `module_desktops status de=bianbu`, so the submenu has actual options once the GNOME entries correctly hide. IDs allocated as BIAN02/03/04/07/08/09 to match the slot numbers used by the other DEs. 3. Bring Bianbu's install entries in line with the rest of the menu: BIAN01 was the only Bianbu install slot and was misnamed — labelled "Install Bianbu" with tier=mid, where every other DE's slot 01 is minimal. Repoint BIAN01 to tier=minimal and add BIAN05 (mid) and BIAN06 (full) so the user sees the full minimal/mid/full choice on a clean install instead of just one entry.
1 parent 645a8a0 commit 95a01b4

2 files changed

Lines changed: 133 additions & 9 deletions

File tree

tools/json/config.system.json

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,39 @@
340340
},
341341
{
342342
"id": "BIAN01",
343-
"description": "Install Bianbu [CSC]",
343+
"description": "Install Bianbu (minimal) [CSC]",
344344
"short": "Bianbu [CSC]",
345+
"command": [
346+
"module_desktops install de=bianbu tier=minimal"
347+
],
348+
"status": "Stable",
349+
"author": "@igorpecovnik",
350+
"condition": "! module_desktops installed && module_desktop_supported bianbu",
351+
"help": "Install Bianbu — SpacemiT K1 RISC-V desktop (minimal tier: bare DE + K1 hardware enablement: img-gpu-powervr, k1x-vpu-firmware, spacemit-uart-bt, kernel modules, Mesa stack pinned to SpacemiT's archive for PVR DRI). riscv64 on noble/resolute only. [community-supported, best-effort]."
352+
},
353+
{
354+
"id": "BIAN05",
355+
"description": "Install Bianbu (mid) [CSC]",
356+
"short": "Bianbu mid [CSC]",
345357
"command": [
346358
"module_desktops install de=bianbu tier=mid"
347359
],
348360
"status": "Stable",
349361
"author": "@igorpecovnik",
350362
"condition": "! module_desktops installed && module_desktop_supported bianbu",
351-
"help": "Install Bianbu — SpacemiT K1 RISC-V desktop (mid tier: full DE + standard utilities + K1 camera stack). riscv64 on noble/resolute only; uses SpacemiT's pinned archive (priority >1000 to override distro for K1-specific packages). [community-supported, best-effort]."
363+
"help": "Install Bianbu (mid tier): minimal + full Bianbu desktop apps + standard utilities + K1 camera stack (k1x-cam). riscv64 on noble/resolute only. [community-supported, best-effort]."
364+
},
365+
{
366+
"id": "BIAN06",
367+
"description": "Install Bianbu (full) [CSC]",
368+
"short": "Bianbu full [CSC]",
369+
"command": [
370+
"module_desktops install de=bianbu tier=full"
371+
],
372+
"status": "Stable",
373+
"author": "@igorpecovnik",
374+
"condition": "! module_desktops installed && module_desktop_supported bianbu",
375+
"help": "Install Bianbu (full tier): mid + Chinese locale (bianbu-desktop-zh) + development tooling (bianbu-development). riscv64 on noble/resolute only. [community-supported, best-effort]."
352376
},
353377
{
354378
"id": "XFCE01",
@@ -408,6 +432,17 @@
408432
"condition": "module_desktops status de=gnome",
409433
"help": "Uninstall the GNOME desktop environment"
410434
},
435+
{
436+
"id": "BIAN02",
437+
"description": "Uninstall Bianbu",
438+
"command": [
439+
"module_desktops remove de=bianbu"
440+
],
441+
"status": "Stable",
442+
"author": "@igorpecovnik",
443+
"condition": "module_desktops status de=bianbu",
444+
"help": "Uninstall the Bianbu desktop environment"
445+
},
411446
{
412447
"id": "MATE02",
413448
"description": "Uninstall MATE",
@@ -518,6 +553,17 @@
518553
"condition": "module_desktops status de=gnome && ! module_desktops login de=gnome",
519554
"help": "Enable automatic desktop login for GNOME"
520555
},
556+
{
557+
"id": "BIAN03",
558+
"description": "Enable autologin (Bianbu)",
559+
"command": [
560+
"module_desktops auto de=bianbu"
561+
],
562+
"status": "Stable",
563+
"author": "@igorpecovnik",
564+
"condition": "module_desktops status de=bianbu && ! module_desktops login de=bianbu",
565+
"help": "Enable automatic desktop login for Bianbu"
566+
},
521567
{
522568
"id": "MATE03",
523569
"description": "Enable autologin (MATE)",
@@ -628,6 +674,17 @@
628674
"condition": "module_desktops status de=gnome && module_desktops login de=gnome",
629675
"help": "Disable automatic desktop login for GNOME"
630676
},
677+
{
678+
"id": "BIAN04",
679+
"description": "Disable autologin (Bianbu)",
680+
"command": [
681+
"module_desktops manual de=bianbu"
682+
],
683+
"status": "Stable",
684+
"author": "@igorpecovnik",
685+
"condition": "module_desktops status de=bianbu && module_desktops login de=bianbu",
686+
"help": "Disable automatic desktop login for Bianbu"
687+
},
631688
{
632689
"id": "MATE04",
633690
"description": "Disable autologin (MATE)",
@@ -760,6 +817,17 @@
760817
"condition": "module_desktops status de=gnome && ! module_desktops at-tier de=gnome tier=minimal",
761818
"help": "Downgrade GNOME to the minimal tier"
762819
},
820+
{
821+
"id": "BIAN07",
822+
"description": "Change Bianbu to minimal",
823+
"command": [
824+
"module_desktops set-tier de=bianbu tier=minimal"
825+
],
826+
"status": "Stable",
827+
"author": "@igorpecovnik",
828+
"condition": "module_desktops status de=bianbu && ! module_desktops at-tier de=bianbu tier=minimal",
829+
"help": "Downgrade Bianbu to the minimal tier (bare DE + K1 hardware enablement)"
830+
},
763831
{
764832
"id": "GNME08",
765833
"description": "Change GNOME to mid",
@@ -771,6 +839,17 @@
771839
"condition": "module_desktops status de=gnome && ! module_desktops at-tier de=gnome tier=mid",
772840
"help": "Move GNOME to the mid tier"
773841
},
842+
{
843+
"id": "BIAN08",
844+
"description": "Change Bianbu to mid",
845+
"command": [
846+
"module_desktops set-tier de=bianbu tier=mid"
847+
],
848+
"status": "Stable",
849+
"author": "@igorpecovnik",
850+
"condition": "module_desktops status de=bianbu && ! module_desktops at-tier de=bianbu tier=mid",
851+
"help": "Move Bianbu to the mid tier (full DE + standard utilities + K1 camera stack)"
852+
},
774853
{
775854
"id": "GNME09",
776855
"description": "Change GNOME to full",
@@ -782,6 +861,17 @@
782861
"condition": "module_desktops status de=gnome && ! module_desktops at-tier de=gnome tier=full",
783862
"help": "Upgrade GNOME to the full tier"
784863
},
864+
{
865+
"id": "BIAN09",
866+
"description": "Change Bianbu to full",
867+
"command": [
868+
"module_desktops set-tier de=bianbu tier=full"
869+
],
870+
"status": "Stable",
871+
"author": "@igorpecovnik",
872+
"condition": "module_desktops status de=bianbu && ! module_desktops at-tier de=bianbu tier=full",
873+
"help": "Upgrade Bianbu to the full tier (adds zh locale and development tooling)"
874+
},
785875
{
786876
"id": "MATE07",
787877
"description": "Change MATE to minimal",

tools/modules/desktops/module_desktops.sh

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,44 @@ function _module_desktops_configure_networking() {
424424
return 0
425425
}
426426

427+
#
428+
# Detect whether desktop $de is installed. Returns 0 if so, 1 otherwise.
429+
# Layered to avoid the dpkg-only check misfiring when DEs share
430+
# packages (e.g. Bianbu's bianbu-desktop-minimal-en depends on
431+
# gnome-session, so a naive dpkg check would mark gnome as installed
432+
# on a Bianbu-only system and surface a "Uninstall GNOME" entry that
433+
# would actually nuke Bianbu's display stack).
434+
#
435+
# 1. /etc/armbian/desktop/<de>.tier exists → installed. The marker
436+
# is written by `install` and removed by `remove`, so it tracks
437+
# exactly what configng put on the system. Authoritative.
438+
#
439+
# 2. A different DE has its marker present → not installed. The
440+
# other DE's marker is the tiebreaker against the dpkg fallback.
441+
#
442+
# 3. No markers anywhere AND dpkg shows DESKTOP_PRIMARY_PKG
443+
# installed → legacy installs that pre-date the marker
444+
# convention or were done with apt directly. Caller must have
445+
# populated DESKTOP_PRIMARY_PKG via module_desktop_yamlparse.
446+
#
447+
function _module_desktops_is_installed() {
448+
local de="$1"
449+
[[ -n "$de" ]] || return 1
450+
# Layer 1
451+
if [[ -f "/etc/armbian/desktop/${de}.tier" ]]; then
452+
return 0
453+
fi
454+
# Layer 2 — any other DE's marker means dpkg is unsafe
455+
local m
456+
for m in /etc/armbian/desktop/*.tier; do
457+
[[ -f "$m" ]] || continue
458+
return 1
459+
done
460+
# Layer 3 — legacy dpkg fallback
461+
[[ -n "${DESKTOP_PRIMARY_PKG:-}" ]] || return 1
462+
dpkg -l "$DESKTOP_PRIMARY_PKG" 2>/dev/null | grep -q "^ii"
463+
}
464+
427465
#
428466
# Module to install and manage desktop environments (YAML-driven)
429467
#
@@ -875,10 +913,7 @@ function module_desktops() {
875913
return 1
876914
fi
877915
module_desktop_yamlparse "$de" || return 1
878-
if [[ -n "$DESKTOP_PRIMARY_PKG" ]] && dpkg -l "$DESKTOP_PRIMARY_PKG" 2>/dev/null | grep -q "^ii"; then
879-
return 0
880-
fi
881-
return 1
916+
_module_desktops_is_installed "$de"
882917
;;
883918

884919
"${commands[5]}")
@@ -1107,7 +1142,7 @@ function module_desktops() {
11071142
return 1
11081143
fi
11091144
module_desktop_yamlparse "$de" || return 1
1110-
if [[ -n "$DESKTOP_PRIMARY_PKG" ]] && dpkg -l "$DESKTOP_PRIMARY_PKG" 2>/dev/null | grep -q "^ii"; then
1145+
if _module_desktops_is_installed "$de"; then
11111146
if [[ -f "/etc/armbian/desktop/${de}.tier" ]]; then
11121147
cat "/etc/armbian/desktop/${de}.tier"
11131148
else
@@ -1131,8 +1166,7 @@ function module_desktops() {
11311166
return 1
11321167
fi
11331168
module_desktop_yamlparse "$de" || return 1
1134-
[[ -n "$DESKTOP_PRIMARY_PKG" ]] || return 1
1135-
dpkg -l "$DESKTOP_PRIMARY_PKG" 2>/dev/null | grep -q "^ii" || return 1
1169+
_module_desktops_is_installed "$de" || return 1
11361170
local current="minimal"
11371171
[[ -f "/etc/armbian/desktop/${de}.tier" ]] && current=$(< "/etc/armbian/desktop/${de}.tier")
11381172
[[ "$current" == "$tier" ]]

0 commit comments

Comments
 (0)