Skip to content

Commit 65a5e8e

Browse files
authored
Merge pull request #213 from icy/cygwin
Initial support for Cygwin, closes #206
2 parents b9879e9 + b0f98e9 commit 65a5e8e

File tree

5 files changed

+119
-7
lines changed

5 files changed

+119
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## v3.0.5
2+
3+
* `lib/apt-cyg`: Add initial support for `apt-cyg` on Cygwin systems
4+
* Rewrote `bin/gen_tests.rb` in `bash` (@mondeja)
5+
* Minor typo/tests fixes
6+
7+
WARNING: The script won't work with docker container image
8+
`opensuse/tumbleweed:latest`. See also
9+
https://bugzilla.opensuse.org/show_bug.cgi?id=1190670
10+
and https://github.com/moby/moby/pull/42836
11+
112
## v3.0.4
213

314
* `lib/swupd`: Add tests and more operations (credit: @mondeja)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Simply install package with `pacapt -S htop` or `pacapt install htop`
77
on any `Linux`, `BSD`, `OpenWrt` or `Mac OS` machines.
88
It supports the following package managers:
99

10-
* `pacman` by `Arch Linux`, `ArchBang`, `Manjaro`, etc.
11-
* `dpkg/apt-get` by `Debian`, `Ubuntu`, etc.
12-
* `homebrew` by `Mac OS X`
13-
* `macports` by `Mac OS X`
10+
* `pacman` on `Arch Linux`-based systems, `ArchBang`, `Manjaro`, etc.
11+
* `apt-cyg` on Cygwin (via [apt-cyg](https://github.com/transcode-open/apt-cyg))
12+
* `apt-get` on `Debian`, `Ubuntu`, etc.
13+
* `homebrew` on `Mac OS X`
14+
* `macports` on `Mac OS X`
1415
* `yum/rpm` by `Redhat`, `CentOS`, `Fedora`, `Oracle Linux`, etc.
1516
* `portage` by `Gentoo`
1617
* `zypper` by `OpenSUSE`

lib/00_core.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ _PACMAN_detect() {
116116
&& return
117117
fi
118118

119+
if uname -a | "$GREP" -q Cygwin; then
120+
command -v "apt-cyg" >/dev/null && _PACMAN="apt_cyg" && return
121+
fi
119122
[ -x "/usr/bin/apt-get" ] && _PACMAN="dpkg" && return
120123
[ -x "/data/data/com.termux/files/usr/bin/apt-get" ] && _PACMAN="dpkg" && return
121124
[ -x "/usr/bin/cave" ] && _PACMAN="cave" && return

lib/apt_cyg.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env sh
2+
3+
# Purpose : pacman-style wrapper for cygwin/apt-cyg tool
4+
# Authors : Ky-Anh Huynh (icy)
5+
# Date : 2021-10-04
6+
# License : Public domain
7+
8+
_apt_cyg_init() {
9+
:
10+
}
11+
12+
apt_cyg_Ss() {
13+
apt-cyg search "$@"
14+
}
15+
16+
apt_cyg_S() {
17+
apt-cyg install "$@"
18+
}
19+
20+
apt_cyg_Sy() {
21+
apt-cyg update "$@"
22+
}
23+
24+
apt_cyg_Q() {
25+
apt-cyg list "$@"
26+
}
27+
28+
apt_cyg_Qi() {
29+
apt-cyg show "$@"
30+
}
31+
32+
apt_cyg_Ql() {
33+
for pkg in "$@"; do
34+
if [ "$_TOPT" = "q" ]; then
35+
apt-cyg listfiles "$pkg"
36+
else
37+
apt-cyg listfiles "$pkg" \
38+
| pkg="$pkg" \
39+
awk '{printf("%s %s\n", ENVIRON["pkg"], $0)}'
40+
fi
41+
done
42+
}
43+
44+
apt_cyg_R() {
45+
apt-cyg remove "$@"
46+
}

pacapt

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Purpose: A wrapper for all Unix package managers
44
# License: Fair license (http://www.opensource.org/licenses/fair)
55
# Source : http://github.com/icy/pacapt/
6-
# Version: 3.0.4
6+
# Version: 3.0.5
77
# Authors: Anh K. Huynh et al.
88

99
# Copyright (C) 2010 - 2021 \
@@ -46,7 +46,7 @@
4646

4747
_print_pacapt_version() {
4848
cat <<_EOF_
49-
pacapt version '3.0.4'
49+
pacapt version '3.0.5'
5050
5151
Copyright (C) 2010 - 2021 \\
5252
| 10sr (10sr)
@@ -87,7 +87,7 @@ DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
8787
_EOF_
8888
}
8989

90-
export PACAPT_VERSION='3.0.4'
90+
export PACAPT_VERSION='3.0.5'
9191

9292
_help() {
9393
cat <<'EOF'
@@ -297,6 +297,9 @@ _PACMAN_detect() {
297297
&& return
298298
fi
299299

300+
if uname -a | "$GREP" -q Cygwin; then
301+
command -v "apt-cyg" >/dev/null && _PACMAN="apt_cyg" && return
302+
fi
300303
[ -x "/usr/bin/apt-get" ] && _PACMAN="dpkg" && return
301304
[ -x "/data/data/com.termux/files/usr/bin/apt-get" ] && _PACMAN="dpkg" && return
302305
[ -x "/usr/bin/cave" ] && _PACMAN="cave" && return
@@ -641,6 +644,47 @@ apk_U() {
641644
# shellcheck disable=2086
642645
apk add --allow-untrusted $_TOPT -- "$@"
643646
}
647+
648+
649+
_apt_cyg_init() {
650+
:
651+
}
652+
653+
apt_cyg_Ss() {
654+
apt-cyg search "$@"
655+
}
656+
657+
apt_cyg_S() {
658+
apt-cyg install "$@"
659+
}
660+
661+
apt_cyg_Sy() {
662+
apt-cyg update "$@"
663+
}
664+
665+
apt_cyg_Q() {
666+
apt-cyg list "$@"
667+
}
668+
669+
apt_cyg_Qi() {
670+
apt-cyg show "$@"
671+
}
672+
673+
apt_cyg_Ql() {
674+
for pkg in "$@"; do
675+
if [ "$_TOPT" = "q" ]; then
676+
apt-cyg listfiles "$pkg"
677+
else
678+
apt-cyg listfiles "$pkg" \
679+
| pkg="$pkg" \
680+
awk '{printf("%s %s\n", ENVIRON["pkg"], $0)}'
681+
fi
682+
done
683+
}
684+
685+
apt_cyg_R() {
686+
apt-cyg remove "$@"
687+
}
644688
#_!_POSIX_#
645689
#_!_POSIX_#
646690
#_!_POSIX_#
@@ -2424,6 +2468,13 @@ _validate_operation() {
24242468
"apk_Suy") ;;
24252469
"apk_Sy") ;;
24262470
"apk_U") ;;
2471+
"apt_cyg_Ss") ;;
2472+
"apt_cyg_S") ;;
2473+
"apt_cyg_Sy") ;;
2474+
"apt_cyg_Q") ;;
2475+
"apt_cyg_Qi") ;;
2476+
"apt_cyg_Ql") ;;
2477+
"apt_cyg_R") ;;
24272478
"cave_Q") ;;
24282479
"cave_Qi") ;;
24292480
"cave_Ql") ;;

0 commit comments

Comments
 (0)