From ab9b908eadba7fe26a4bfb2ebc653debbcf05c2d Mon Sep 17 00:00:00 2001 From: lasers Date: Mon, 26 Jun 2017 01:00:08 -0500 Subject: [PATCH 1/3] Add support for Void Linux --- lib/00_core.sh | 1 + lib/xbps.sh | 204 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 lib/xbps.sh diff --git a/lib/00_core.sh b/lib/00_core.sh index b6ac6a7b..d08fece4 100644 --- a/lib/00_core.sh +++ b/lib/00_core.sh @@ -110,6 +110,7 @@ _PACMAN_detect() { [[ -x "/sbin/apk" ]] && _PACMAN="apk" && return [[ -x "/usr/bin/tazpkg" ]] && _PACMAN="tazpkg" && return [[ -x "/usr/bin/swupd" ]] && _PACMAN="swupd" && return + [[ -x "/usr/bin/xbps-install" ]] && _PACMAN="xbps" && return command -v brew >/dev/null && _PACMAN="homebrew" && return diff --git a/lib/xbps.sh b/lib/xbps.sh new file mode 100644 index 00000000..33633cb8 --- /dev/null +++ b/lib/xbps.sh @@ -0,0 +1,204 @@ +#!/bin/sh + +# Purpose: Void Linux support +# Author : lasers +# License: Fair license (http://www.opensource.org/licenses/fair) +# Source : http://github.com/icy/pacapt/ + +# Copyright (C) 2017 lasers +# +# Usage of the works is permitted provided that this instrument is +# retained with the works, so that any entity that uses the works is +# notified of this instrument. +# +# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. + +_xbps_init() { + : + } + +_xbps_pkgs_only() { + echo ="$(xbps-query --list-pkgs \ + | awk '{ print $2 }' \ + | xargs -n1 xbps-uhelper getpkgname \ + | fmt)" +} + +xbps_D_asexplicit() { + # how do we use this? # pacman -D --asexplicit + xbps-pkgdb -m manual "$@" +} + +xbps_Q() { + PKGS="$@" + if [ -z "$PKGS" ] + then + xbps-query --list-pkgs + else + for PKG in $PKGS + do + xbps-query --list-pkgs | grep -i "$PKG" + done + fi +} + +# untested + blocked: function not supported? +xbps_Qet() { + PKGS="$@" + if [ -z "$PKGS" ] + then + xbps-query -m + else + for PKG in $PKGS + do + xbps-query -m | grep -i "$PKG" + done + fi +} + +xbps_Qi() { + PKGS="$@" + RED="$(tput setaf 9)" + RESET="$(tput sgr0)" + if [ -z "$PKGS" ] + then + PKGS="$(_xbps_pkgs_only)" + fi + for PKG in $PKGS + do + xbps-query --show "$PKG" + if [ "$?" -eq 0 ] + then + echo + else + echo "${RED}error: ${RESET}package '$PKG' was not found" + fi + done +} + +xbps_Ql() { + PKGS="$@" + CYAN="$(tput setaf 14)" + RESET="$(tput sgr0)" + if [ -z "$PKGS" ] + then + PKGS="$(_xbps_pkgs_only)" + fi + for PKG in $PKGS + do + xbps-query --files "$PKG" | sed -e "s/^/${CYAN}${PKG} ${RESET}/g" + done +} + +xbps_Qo() { + PKGS="$@" + RED="$(tput setaf 9)" + RESET="$(tput sgr0)" + for PKG in $PKGS + do + if [ -f "$PKG" ] + then + xbps-query --ownedby "$PKG" + elif which $PKG &>/dev/null + then + xbps-query --ownedby "$(which $PKG)" + else + echo "${RED}error: ${RESET}failed to find '$PKG' in PATH: No such file or directory" + fi + done +} + +xbps_Qp() { + _not_implemented +} + +xbps_Qs() { + if [ ! -z "$@" ] + then + xbps-query --search "$@" + else + xbps-query --search '''' + fi +} + +xbps_Qu() { + xbps-install --sync --update --dry-run "$@" +} + +xbps_R() { + xbps-remove "$@" +} + +xbps_Rn() { + xbps-remove --recursive "$@" +} + +xbps_Rs() { + xbps-remove --recursive "$@" +} + +xbps_Rns() { + xbps-remove --recursive "$@" +} + +xbps_S() { + xbps-install --force $_TOPT "$@" +} + +xbps_S_asdeps() { + # how do we use this? pacman -S --asdeps + xbps-pkgdb -m auto "$@" +} + +xbps_Sc() { + xbps-remove --clean-cache "$@" +} + +xbps_Scc() { + xbps-remove --remove-orphans "$@" +} + +xbps_Sccc() { + xbps-remove --clean-cache --remove-orphans "$@" +} + +xbps_Si() { + PKGS="$@" + if [ -z "$PKGS" ] + then + PKGS="$(_xbps_pkgs_only)" + fi + for PKG in $PKGS + do + xbps-query --repository --deps "$PKG" + echo + done +} + +xbps_Sii() { + xbps-query --repository --revdeps "$@" +} + +xbps_Ss() { + xbps-query --repository --search "$@" +} + +xbps_Su() { + xbps-install --update "$@" +} + +xbps_Suy() { + xbps-install --sync --update $_TOPT "$@" +} + +xbps_Sw() { + _not_implemented +} + +xbps_Sy() { + xbps-install --sync "$@" +} + +xbps_U() { + _not_implemented +} From 95cdfac79e249ae02951f9292edac2a87cb1f22a Mon Sep 17 00:00:00 2001 From: lasers Date: Tue, 27 Jun 2017 06:57:25 -0500 Subject: [PATCH 2/3] Add support for Void Linux (2) --- lib/xbps.sh | 121 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 35 deletions(-) diff --git a/lib/xbps.sh b/lib/xbps.sh index 33633cb8..c512793b 100644 --- a/lib/xbps.sh +++ b/lib/xbps.sh @@ -18,82 +18,87 @@ _xbps_init() { } _xbps_pkgs_only() { - echo ="$(xbps-query --list-pkgs \ + echo "$(xbps-query --list-pkgs \ | awk '{ print $2 }' \ | xargs -n1 xbps-uhelper getpkgname \ | fmt)" } +_xbps_inputs_only() { + RESULT="" + for PKG in $@ + do + RESULT="$RESULT|$PKG" + done + RESULT="$(echo $RESULT | sed -e 's/^|//')" + echo "$RESULT" +} + xbps_D_asexplicit() { # how do we use this? # pacman -D --asexplicit xbps-pkgdb -m manual "$@" } xbps_Q() { - PKGS="$@" - if [ -z "$PKGS" ] + if [ $# -eq 0 ] then xbps-query --list-pkgs else - for PKG in $PKGS - do - xbps-query --list-pkgs | grep -i "$PKG" - done + RESULT="$(_xbps_inputs_only $@)" + xbps-query --list-pkgs | grep -iE "$RESULT" fi } # untested + blocked: function not supported? xbps_Qet() { PKGS="$@" - if [ -z "$PKGS" ] + if [ $# -eq 0 ] then xbps-query -m else - for PKG in $PKGS - do - xbps-query -m | grep -i "$PKG" - done + RESULT="$(_xbps_inputs_only $@)" + xbps-query -m | grep -iE "$RESULT" fi } xbps_Qi() { PKGS="$@" - RED="$(tput setaf 9)" - RESET="$(tput sgr0)" - if [ -z "$PKGS" ] + COLOR_CYAN="$(tput setaf 14)" + COLOR_RESET="$(tput sgr0)" + if [ $# -eq 0 ] then PKGS="$(_xbps_pkgs_only)" fi for PKG in $PKGS do - xbps-query --show "$PKG" + RESULT="$(xbps-query "$PKG")" if [ "$?" -eq 0 ] then + echo "${COLOR_CYAN}name: ${COLOR_RESET}$PKG" + xbps-query "$PKG" echo else - echo "${RED}error: ${RESET}package '$PKG' was not found" + _error "package '$PKG' was not found" fi done } xbps_Ql() { PKGS="$@" - CYAN="$(tput setaf 14)" - RESET="$(tput sgr0)" + COLOR_CYAN="$(tput setaf 14)" + COLOR_RESET="$(tput sgr0)" if [ -z "$PKGS" ] then PKGS="$(_xbps_pkgs_only)" fi for PKG in $PKGS do - xbps-query --files "$PKG" | sed -e "s/^/${CYAN}${PKG} ${RESET}/g" + xbps-query --files "$PKG" | sed -e 's/^/${COLOR_CYAN}${PKG} ${COLOR_RESET}/g' done } xbps_Qo() { PKGS="$@" - RED="$(tput setaf 9)" - RESET="$(tput sgr0)" for PKG in $PKGS do if [ -f "$PKG" ] @@ -103,7 +108,7 @@ xbps_Qo() { then xbps-query --ownedby "$(which $PKG)" else - echo "${RED}error: ${RESET}failed to find '$PKG' in PATH: No such file or directory" + _error "failed to find '$PKG' in PATH: No such file or directory" fi done } @@ -113,11 +118,19 @@ xbps_Qp() { } xbps_Qs() { - if [ ! -z "$@" ] + if [ $# -eq 0 ] + then + xbps-query --search '''' + elif [ $# -eq 1 ] then xbps-query --search "$@" else - xbps-query --search '''' + RESULT="" + for PKG in $@ + do + RESULT="$(xbps-query --search '''' | grep -i "$PKG")" + done + echo "$RESULT" fi } @@ -142,7 +155,7 @@ xbps_Rns() { } xbps_S() { - xbps-install --force $_TOPT "$@" + xbps-install $_TOPT "$@" } xbps_S_asdeps() { @@ -164,23 +177,61 @@ xbps_Sccc() { xbps_Si() { PKGS="$@" - if [ -z "$PKGS" ] + COLOR_CYAN="$(tput setaf 14)" + COLOR_RESET="$(tput sgr0)" + if [ $# -eq 1 ] then - PKGS="$(_xbps_pkgs_only)" + RESULT="$(xbps-query --repository "$PKG")" + if [ "$?" -eq 0 ] + then + echo "${COLOR_CYAN}name: ${COLOR_RESET}$PKG" + xbps-query --repository "$PKG" + fi + else + if [ $# -eq 0 ] + then + PKGS="$(_xbps_pkgs_only)" + fi + for PKG in $PKGS + do + RESULT="$(xbps-query --repository "$PKG")" + if [ "$?" -eq 0 ] + then + echo "${COLOR_CYAN}name: ${COLOR_RESET}$PKG" + xbps-query --repository "$PKG" + echo + fi + done fi - for PKG in $PKGS - do - xbps-query --repository --deps "$PKG" - echo - done } xbps_Sii() { - xbps-query --repository --revdeps "$@" + COLOR_CYAN="$(tput setaf 14)" + COLOR_RESET="$(tput sgr0)" + PKGS="$@" + for PKG in $PKGS + do + RESULT="$(xbps-query --repository --revdeps "$PKG")" + if [ "$?" -eq 0 ] + then + echo "$RESULT" \ + | xargs -n1 xbps-uhelper getpkgname \ + | xargs \ + | sed -e "s/ / /g" -e "s/^/${COLOR_CYAN}${PKG} ${COLOR_RESET}/g" + else + _error "package '$PKG' was not found or has no dependenices" + fi + done } xbps_Ss() { - xbps-query --repository --search "$@" + if [ $# -eq 1 ] + then + xbps-query --repository --search "$@" + else + RESULT="$(_xbps_inputs_only $@)" + xbps-query --repository --search '''' | grep -iE "$RESULT" + fi } xbps_Su() { From 5e6fb8d24fdb9c7cac3d2151ff4907cf00540b39 Mon Sep 17 00:00:00 2001 From: lasers Date: Tue, 11 Jul 2017 16:46:52 -0500 Subject: [PATCH 3/3] Add support for Void Linux (3) --- lib/00_core.sh | 1 + lib/xbps.sh | 69 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/lib/00_core.sh b/lib/00_core.sh index d08fece4..fdbc6c14 100644 --- a/lib/00_core.sh +++ b/lib/00_core.sh @@ -189,6 +189,7 @@ _translate_noconfirm() { "zypper") _opt="--no-confirm";; "pkgng") _opt="-y";; "tazpkg") _opt="--auto";; + "xbps") _opt="--yes";; *) _opt="" _ret=1 diff --git a/lib/xbps.sh b/lib/xbps.sh index c512793b..f9f324c4 100644 --- a/lib/xbps.sh +++ b/lib/xbps.sh @@ -34,30 +34,38 @@ _xbps_inputs_only() { echo "$RESULT" } -xbps_D_asexplicit() { - # how do we use this? # pacman -D --asexplicit - xbps-pkgdb -m manual "$@" -} +# PACAPT DOES NOT SUPPORT D ? // CANNOT TEST +# xbps_D() { +# if [ "$_TOPT" == "asexplicit" ] +# then +# # how do we use this? # pacman -D --asexplicit +# xbps-pkgdb -m manual "$@" +# else +# _not_implemented +# fi +# } xbps_Q() { - if [ $# -eq 0 ] - then - xbps-query --list-pkgs - else - RESULT="$(_xbps_inputs_only $@)" - xbps-query --list-pkgs | grep -iE "$RESULT" - fi -} - -# untested + blocked: function not supported? -xbps_Qet() { - PKGS="$@" - if [ $# -eq 0 ] + # PACAPT DOES NOT SUPPORT Qe ? // CANNOT TEST + if [[ "$_TOPT" == "e" ]] then - xbps-query -m + if [ $# -eq 0 ] + then + xbps-query --list-manual-pkgs + else + RESULT="$(_xbps_inputs_only $@)" + xbps-query --list-manual-pkgs | grep -iE "$RESULT" + fi + elif [[ "$_TOPT" == "" ]]; then + if [ $# -eq 0 ] + then + xbps-query --list-pkgs + else + RESULT="$(_xbps_inputs_only $@)" + xbps-query --list-pkgs | grep -iE "$RESULT" + fi else - RESULT="$(_xbps_inputs_only $@)" - xbps-query -m | grep -iE "$RESULT" + _not_implemented fi } @@ -93,11 +101,15 @@ xbps_Ql() { fi for PKG in $PKGS do - xbps-query --files "$PKG" | sed -e 's/^/${COLOR_CYAN}${PKG} ${COLOR_RESET}/g' + xbps-query --files "$PKG" | sed -e "s/^/${COLOR_CYAN}${PKG} ${COLOR_RESET}/g" done } xbps_Qo() { + if [ $# -eq 0 ] + then + _error "no targets specified" + fi PKGS="$@" for PKG in $PKGS do @@ -158,10 +170,11 @@ xbps_S() { xbps-install $_TOPT "$@" } -xbps_S_asdeps() { - # how do we use this? pacman -S --asdeps - xbps-pkgdb -m auto "$@" -} +# THIS BELONGS IN 00_core.sh? // CANNOT TEST +# xbps_S_asdeps() { +# # how do we use this? pacman -S --asdeps +# xbps-pkgdb -m auto "$@" +# } xbps_Sc() { xbps-remove --clean-cache "$@" @@ -181,11 +194,11 @@ xbps_Si() { COLOR_RESET="$(tput sgr0)" if [ $# -eq 1 ] then - RESULT="$(xbps-query --repository "$PKG")" + RESULT="$(xbps-query --repository "$PKGS")" if [ "$?" -eq 0 ] then - echo "${COLOR_CYAN}name: ${COLOR_RESET}$PKG" - xbps-query --repository "$PKG" + echo "${COLOR_CYAN}name: ${COLOR_RESET}$PKGS" + xbps-query --repository "$PKGS" fi else if [ $# -eq 0 ]