diff --git a/CHANGELOG.md b/CHANGELOG.md index cd096b2..0ccb60d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v3.0.5 + +* `lib/apt-cyg`: Add initial support for `apt-cyg` on Cygwin systems +* Rewrote `bin/gen_tests.rb` in `bash` (@mondeja) +* Minor typo/tests fixes + +WARNING: The script won't work with docker container image +`opensuse/tumbleweed:latest`. See also +https://bugzilla.opensuse.org/show_bug.cgi?id=1190670 +and https://github.com/moby/moby/pull/42836 + ## v3.0.4 * `lib/swupd`: Add tests and more operations (credit: @mondeja) diff --git a/README.md b/README.md index dffdfe0..9fbe7ed 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ Simply install package with `pacapt -S htop` or `pacapt install htop` on any `Linux`, `BSD`, `OpenWrt` or `Mac OS` machines. It supports the following package managers: -* `pacman` by `Arch Linux`, `ArchBang`, `Manjaro`, etc. -* `dpkg/apt-get` by `Debian`, `Ubuntu`, etc. -* `homebrew` by `Mac OS X` -* `macports` by `Mac OS X` +* `pacman` on `Arch Linux`-based systems, `ArchBang`, `Manjaro`, etc. +* `apt-cyg` on Cygwin (via [apt-cyg](https://github.com/transcode-open/apt-cyg)) +* `apt-get` on `Debian`, `Ubuntu`, etc. +* `homebrew` on `Mac OS X` +* `macports` on `Mac OS X` * `yum/rpm` by `Redhat`, `CentOS`, `Fedora`, `Oracle Linux`, etc. * `portage` by `Gentoo` * `zypper` by `OpenSUSE` diff --git a/lib/00_core.sh b/lib/00_core.sh index 12b25a7..1a68a5a 100644 --- a/lib/00_core.sh +++ b/lib/00_core.sh @@ -116,6 +116,9 @@ _PACMAN_detect() { && return fi + if uname -a | "$GREP" -q Cygwin; then + command -v "apt-cyg" >/dev/null && _PACMAN="apt_cyg" && return + fi [ -x "/usr/bin/apt-get" ] && _PACMAN="dpkg" && return [ -x "/data/data/com.termux/files/usr/bin/apt-get" ] && _PACMAN="dpkg" && return [ -x "/usr/bin/cave" ] && _PACMAN="cave" && return diff --git a/lib/apt_cyg.sh b/lib/apt_cyg.sh new file mode 100644 index 0000000..547eb2e --- /dev/null +++ b/lib/apt_cyg.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh + +# Purpose : pacman-style wrapper for cygwin/apt-cyg tool +# Authors : Ky-Anh Huynh (icy) +# Date : 2021-10-04 +# License : Public domain + +_apt_cyg_init() { + : +} + +apt_cyg_Ss() { + apt-cyg search "$@" +} + +apt_cyg_S() { + apt-cyg install "$@" +} + +apt_cyg_Sy() { + apt-cyg update "$@" +} + +apt_cyg_Q() { + apt-cyg list "$@" +} + +apt_cyg_Qi() { + apt-cyg show "$@" +} + +apt_cyg_Ql() { + for pkg in "$@"; do + if [ "$_TOPT" = "q" ]; then + apt-cyg listfiles "$pkg" + else + apt-cyg listfiles "$pkg" \ + | pkg="$pkg" \ + awk '{printf("%s %s\n", ENVIRON["pkg"], $0)}' + fi + done +} + +apt_cyg_R() { + apt-cyg remove "$@" +} diff --git a/pacapt b/pacapt index a0f8d23..a71496a 100755 --- a/pacapt +++ b/pacapt @@ -3,7 +3,7 @@ # Purpose: A wrapper for all Unix package managers # License: Fair license (http://www.opensource.org/licenses/fair) # Source : http://github.com/icy/pacapt/ -# Version: 3.0.4 +# Version: 3.0.5 # Authors: Anh K. Huynh et al. # Copyright (C) 2010 - 2021 \ @@ -46,7 +46,7 @@ _print_pacapt_version() { cat <<_EOF_ -pacapt version '3.0.4' +pacapt version '3.0.5' Copyright (C) 2010 - 2021 \\ | 10sr (10sr) @@ -87,7 +87,7 @@ DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. _EOF_ } -export PACAPT_VERSION='3.0.4' +export PACAPT_VERSION='3.0.5' _help() { cat <<'EOF' @@ -297,6 +297,9 @@ _PACMAN_detect() { && return fi + if uname -a | "$GREP" -q Cygwin; then + command -v "apt-cyg" >/dev/null && _PACMAN="apt_cyg" && return + fi [ -x "/usr/bin/apt-get" ] && _PACMAN="dpkg" && return [ -x "/data/data/com.termux/files/usr/bin/apt-get" ] && _PACMAN="dpkg" && return [ -x "/usr/bin/cave" ] && _PACMAN="cave" && return @@ -641,6 +644,47 @@ apk_U() { # shellcheck disable=2086 apk add --allow-untrusted $_TOPT -- "$@" } + + +_apt_cyg_init() { + : +} + +apt_cyg_Ss() { + apt-cyg search "$@" +} + +apt_cyg_S() { + apt-cyg install "$@" +} + +apt_cyg_Sy() { + apt-cyg update "$@" +} + +apt_cyg_Q() { + apt-cyg list "$@" +} + +apt_cyg_Qi() { + apt-cyg show "$@" +} + +apt_cyg_Ql() { + for pkg in "$@"; do + if [ "$_TOPT" = "q" ]; then + apt-cyg listfiles "$pkg" + else + apt-cyg listfiles "$pkg" \ + | pkg="$pkg" \ + awk '{printf("%s %s\n", ENVIRON["pkg"], $0)}' + fi + done +} + +apt_cyg_R() { + apt-cyg remove "$@" +} #_!_POSIX_# #_!_POSIX_# #_!_POSIX_# @@ -2424,6 +2468,13 @@ _validate_operation() { "apk_Suy") ;; "apk_Sy") ;; "apk_U") ;; + "apt_cyg_Ss") ;; + "apt_cyg_S") ;; + "apt_cyg_Sy") ;; + "apt_cyg_Q") ;; + "apt_cyg_Qi") ;; + "apt_cyg_Ql") ;; + "apt_cyg_R") ;; "cave_Q") ;; "cave_Qi") ;; "cave_Ql") ;;