Unverified Commit 75198506 authored by Daniel Thau's avatar Daniel Thau Committed by GitHub

Bedrock Linux fixes (#1675)

Neofetch is Bedrock-aware by default, but ignores Bedrock and restricts itself to the local layer of the Bedrock system when run in Bedrock's "restricted" mode. Previously, neofetch checked for restricted mode by looking at the $PATH, which can fail in some workflows. Instead, check for $BEDROCK_RESTRICT, which is more robust. Neofetch previously counted Bedrock stratum aliases when counting packages for some package managers. This resulted in over-counting packages. This commit restricts neofetch to only counting actual strata, not aliases.
parent 0dd28db3
...@@ -971,7 +971,7 @@ get_distro() { ...@@ -971,7 +971,7 @@ get_distro() {
case $os in case $os in
Linux|BSD|MINIX) Linux|BSD|MINIX)
if [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]]; then if [[ -f /bedrock/etc/bedrock-release && -z $BEDROCK_RESTRICT ]]; then
case $distro_shorthand in case $distro_shorthand in
on|tiny) distro="Bedrock Linux" ;; on|tiny) distro="Bedrock Linux" ;;
*) distro=$(< /bedrock/etc/bedrock-release) *) distro=$(< /bedrock/etc/bedrock-release)
...@@ -1505,7 +1505,9 @@ get_packages() { ...@@ -1505,7 +1505,9 @@ get_packages() {
# pac: If packages > 0, log package manager name. # pac: If packages > 0, log package manager name.
# tot: Count lines in command output. # tot: Count lines in command output.
has() { type -p "$1" >/dev/null && manager=$1; } has() { type -p "$1" >/dev/null && manager=$1; }
dir() { ((packages+=$#)); pac "$(($#-pkgs_h))"; } # globbing is intentional here
# shellcheck disable=SC2206
dir() { pkgs=($@); ((packages+=${#pkgs[@]})); pac "$((${#pkgs[@]}-pkgs_h))"; }
pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; } pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; }
tot() { tot() {
IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")"; IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")";
...@@ -1513,14 +1515,22 @@ get_packages() { ...@@ -1513,14 +1515,22 @@ get_packages() {
pac "$((${#pkgs[@]}-pkgs_h))"; pac "$((${#pkgs[@]}-pkgs_h))";
} }
# Redefine tot() for Bedrock Linux. # Redefine tot() and dir() for Bedrock Linux.
[[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && { [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && {
br_strata=$(brl list)
tot() { tot() {
IFS=$'\n' read -d "" -ra pkgs <<< "$(for s in $(brl list); do strat -r "$s" "$@"; done)" IFS=$'\n' read -d "" -ra pkgs <<< "$(for s in ${br_strata}; do strat -r "$s" "$@"; done)"
((packages+="${#pkgs[@]}")) ((packages+="${#pkgs[@]}"))
pac "$((${#pkgs[@]}-pkgs_h))"; pac "$((${#pkgs[@]}-pkgs_h))";
}
dir() {
local pkgs=()
# globbing is intentional here
# shellcheck disable=SC2206
for s in ${br_strata}; do pkgs+=(/bedrock/strata/$s/$@); done
((packages+=${#pkgs[@]}))
pac "$((${#pkgs[@]}-pkgs_h))"
} }
br_prefix="/bedrock/strata/*"
} }
case $os in case $os in
...@@ -1560,16 +1570,16 @@ get_packages() { ...@@ -1560,16 +1570,16 @@ get_packages() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
{ {
shopt -s nullglob shopt -s nullglob
has brew && dir "$(brew --cellar)"/* has brew && dir "$(brew --cellar)/*"
has emerge && dir ${br_prefix}/var/db/pkg/*/*/ has emerge && dir "/var/db/pkg/*/*"
has Compile && dir ${br_prefix}/Programs/*/ has Compile && dir "/Programs/*/"
has eopkg && dir ${br_prefix}/var/lib/eopkg/package/* has eopkg && dir "/var/lib/eopkg/package/*"
has crew && dir ${br_prefix}/usr/local/etc/crew/meta/*.filelist has crew && dir "/usr/local/etc/crew/meta/*.filelist"
has pkgtool && dir ${br_prefix}/var/log/packages/* has pkgtool && dir "/var/log/packages/*"
has scratch && dir ${br_prefix}/var/lib/scratchpkg/index/*/.pkginfo has scratch && dir "/var/lib/scratchpkg/index/*/.pkginfo"
has kagami && dir ${br_prefix}/var/lib/kagami/pkgs/* has kagami && dir "/var/lib/kagami/pkgs/*"
has cave && dir ${br_prefix}/var/db/paludis/repositories/cross-installed/*/data/*/ \ has cave && dir "/var/db/paludis/repositories/cross-installed/*/data/*/ \
${br_prefix}/var/db/paludis/repositories/installed/data/*/ /var/db/paludis/repositories/installed/data/*/"
shopt -u nullglob shopt -u nullglob
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment