Skip to content

Commit

Permalink
Merge pull request #213 from icy/cygwin
Browse files Browse the repository at this point in the history
Initial support for Cygwin, closes #206
  • Loading branch information
icy authored Oct 11, 2021
2 parents b9879e9 + b0f98e9 commit 65a5e8e
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions lib/00_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions lib/apt_cyg.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
}
57 changes: 54 additions & 3 deletions pacapt
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_#
Expand Down Expand Up @@ -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") ;;
Expand Down

0 comments on commit 65a5e8e

Please sign in to comment.