From 41a936f0b1445f6ebd69658a1500b1dbfcde969f Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 20 Apr 2021 11:34:14 +0300 Subject: os.sh: support Manjaro --- %HOME%/.bash_utils/os.sh | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/%HOME%/.bash_utils/os.sh b/%HOME%/.bash_utils/os.sh index f5af0f6..949116d 100644 --- a/%HOME%/.bash_utils/os.sh +++ b/%HOME%/.bash_utils/os.sh @@ -12,6 +12,7 @@ _UBUNTU='Ubuntu' _MINT='Linux Mint' _ARCH='Arch Linux' _ARCH_ARM='Arch Linux ARM' +_MANJARO='Manjaro Linux' _FEDORA='Fedora' os_detect() { @@ -26,6 +27,7 @@ os_detect() { -o "$_os" == "$_MINT" \ -o "$_os" == "$_ARCH" \ -o "$_os" == "$_ARCH_ARM" \ + -o "$_os" == "$_MANJARO" \ -o "$_os" == "$_FEDORA" \ && return 0 @@ -37,13 +39,15 @@ os_detect os_detected() { test -n "$_os" ; } -os_is_cygwin() { test "$_os" == "$_CYGWIN" ; } -os_is_ubuntu() { test "$_os" == "$_UBUNTU" ; } -os_is_mint() { test "$_os" == "$_MINT" ; } -os_is_arch() { test "$_os" == "$_ARCH" -o "$_os" == "$_ARCH_ARM" ; } -os_is_fedora() { test "$_os" == "$_FEDORA" ; } +os_is_cygwin() { test "$_os" == "$_CYGWIN" ; } +os_is_ubuntu() { test "$_os" == "$_UBUNTU" ; } +os_is_mint() { test "$_os" == "$_MINT" ; } +os_is_arch() { test "$_os" == "$_ARCH" -o "$_os" == "$_ARCH_ARM" ; } +os_is_manjaro() { test "$_os" == "$_MANJARO" ; } +os_is_fedora() { test "$_os" == "$_FEDORA" ; } os_is_debian_based() { os_is_ubuntu || os_is_mint ; } +os_is_arch_based() { os_is_arch || os_is_manjaro ; } # Cygwin @@ -84,7 +88,7 @@ pkg_list_ubuntu() ( | cut -d ':' -f 1 ) -# Arch Linux +# Arch Linux/Manjaro setup_pkg_list_arch() ( set -o errexit -o nounset -o pipefail @@ -103,10 +107,22 @@ user_pkg_list_arch() ( <( setup_pkg_list_arch ) ) +user_pkg_list_manjaro() ( + set -o errexit -o nounset -o pipefail + + # https://forum.manjaro.org/t/how-do-i-get-a-list-of-all-packages-installed-on-a-system/50289/8 + comm -12 <( grep --perl-regexp --only-matching -e '\[ALPM\] installed \K\S*' /var/log/pacman.log | sort | uniq ) \ + <( pacman -Qeqn | sort ) +) + pkg_list_arch() { pacman -Qq } +pkg_list_manjaro() { + pkg_list_arch +} + # Fedora pkg_list_fedora() ( @@ -126,6 +142,8 @@ pkg_list() ( pkg_list_ubuntu elif os_is_arch; then pkg_list_arch + elif os_is_manjaro; then + pkg_list_manjaro elif os_is_fedora; then pkg_list_fedora else @@ -133,3 +151,18 @@ pkg_list() ( return 1 fi ) + +user_pkg_list() ( + set -o errexit -o nounset -o pipefail + + if os_is_ubuntu || os_is_mint; then + user_pkg_list_ubuntu + elif os_is_arch; then + user_pkg_list_arch + elif os_is_manjaro; then + user_pkg_list_manjaro + else + echo "${FUNCNAME[0]}: unsupported OS" >&2 + return 1 + fi +) -- cgit v1.2.3