forked from calculate/calculate-overlay
Signed-off-by: Alexander Kurakin <kuraga333@mail.ru>master
parent
d1e3f5dd2e
commit
c85c39dcda
@ -0,0 +1,39 @@
|
||||
From 9614658e6a31bf1b318972008fd9fd1301e9d92f Mon Sep 17 00:00:00 2001
|
||||
From: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
|
||||
Date: Sun, 13 Aug 2023 14:32:34 -0500
|
||||
Subject: [PATCH 2/3] Add -A/--ansi
|
||||
|
||||
Don't strip ANSI codes.
|
||||
---
|
||||
See also: https://github.com/zlin/wgetpaste/pull/46
|
||||
- Oskari
|
||||
|
||||
wgetpaste | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/wgetpaste b/wgetpaste
|
||||
index 5f4152d..1e3ae35 100755
|
||||
--- a/wgetpaste
|
||||
+++ b/wgetpaste
|
||||
@@ -556,6 +556,8 @@ Options:
|
||||
-X, --xpaste write resulting url to the X primary selection buffer (requires x11-misc/xclip)
|
||||
-C, --xclippaste write resulting url to the X clipboard selection buffer (requires x11-misc/xclip)
|
||||
-N, --no-ansi strip ANSI codes such as colors before pasting (requires app-text/ansifilter)
|
||||
+ -A, --ansi don't strip ANSI codes
|
||||
+ (useful for undoing NOANSI specified in a config file)
|
||||
|
||||
-r, --raw show url for the raw paste (no syntax highlighting or html)
|
||||
-t, --tee use tee to show what is being pasted
|
||||
@@ -789,6 +791,9 @@ while [[ -n $1 ]]; do
|
||||
-- )
|
||||
shift && getfilenames "$@" && break
|
||||
;;
|
||||
+ -A | --ansi )
|
||||
+ NOANSI=
|
||||
+ ;;
|
||||
-c | --command )
|
||||
requiredarg "$@"
|
||||
SOURCE="command"
|
||||
--
|
||||
2.41.0
|
||||
|
@ -0,0 +1,95 @@
|
||||
From cfe7dcd8a0e40b8c18556aad0b657f431c90505a Mon Sep 17 00:00:00 2001
|
||||
From: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
|
||||
Date: Sun, 13 Aug 2023 14:25:35 -0500
|
||||
Subject: [PATCH 1/3] Change arg parsing priority
|
||||
|
||||
Read config files before parsing CLI args. Allows all options to be set
|
||||
via config and overridden on the CLI.
|
||||
---
|
||||
See also: https://github.com/zlin/wgetpaste/pull/46
|
||||
- Oskari
|
||||
|
||||
wgetpaste | 53 ++++++++++++++++++++++++++++-------------------------
|
||||
1 file changed, 28 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/wgetpaste b/wgetpaste
|
||||
index fc0b559..5f4152d 100755
|
||||
--- a/wgetpaste
|
||||
+++ b/wgetpaste
|
||||
@@ -720,7 +720,32 @@ geturl() {
|
||||
fi | tail -n1
|
||||
}
|
||||
|
||||
-### read cli options
|
||||
+# read the config files
|
||||
+load_configs() {
|
||||
+ if [[ ! $IGNORECONFIGS ]]; then
|
||||
+ # compatibility code
|
||||
+ local f deprecated=
|
||||
+ for f in {/etc/,~/.}wgetpaste{.d/*.bash,}; do
|
||||
+ if [[ -f $f ]]; then
|
||||
+ if [[ -z $deprecated ]]; then
|
||||
+ echo "The config files for wgetpaste have changed to *.conf.$N" >&2
|
||||
+ deprecated=0
|
||||
+ fi
|
||||
+ echo "Please move ${f} to ${f%.bash}.conf" >&2
|
||||
+ source "$f" || die "Failed to source $f"
|
||||
+ fi
|
||||
+ done
|
||||
+ [[ -n $deprecated ]] && echo >&2
|
||||
+ # new locations override old ones in case they collide
|
||||
+ for f in {/etc/,~/.}wgetpaste{.d/*,}.conf; do
|
||||
+ if [[ -f $f ]]; then
|
||||
+ source "$f" || die "Failed to source $f"
|
||||
+ fi
|
||||
+ done
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
+### get runtime options
|
||||
|
||||
# separate groups of short options. replace --foo=bar with --foo bar
|
||||
while [[ -n $1 ]]; do
|
||||
@@ -756,6 +781,8 @@ done
|
||||
# set the separated options as input options.
|
||||
set -- "${ARGS[@]}"
|
||||
|
||||
+load_configs
|
||||
+
|
||||
while [[ -n $1 ]]; do
|
||||
((args=1))
|
||||
case "$1" in
|
||||
@@ -859,30 +886,6 @@ if [[ $NOANSI ]]; then
|
||||
fi
|
||||
|
||||
### defaults
|
||||
-load_configs() {
|
||||
- if [[ ! $IGNORECONFIGS ]]; then
|
||||
- # compatibility code
|
||||
- local f deprecated=
|
||||
- for f in {/etc/,~/.}wgetpaste{.d/*.bash,}; do
|
||||
- if [[ -f $f ]]; then
|
||||
- if [[ -z $deprecated ]]; then
|
||||
- echo "The config files for wgetpaste have changed to *.conf.$N" >&2
|
||||
- deprecated=0
|
||||
- fi
|
||||
- echo "Please move ${f} to ${f%.bash}.conf" >&2
|
||||
- source "$f" || die "Failed to source $f"
|
||||
- fi
|
||||
- done
|
||||
- [[ -n $deprecated ]] && echo >&2
|
||||
- # new locations override old ones in case they collide
|
||||
- for f in {/etc/,~/.}wgetpaste{.d/*,}.conf; do
|
||||
- if [[ -f $f ]]; then
|
||||
- source "$f" || die "Failed to source $f"
|
||||
- fi
|
||||
- done
|
||||
- fi
|
||||
-}
|
||||
-load_configs
|
||||
[[ $SERVICESET ]] && verifyservice "$SERVICESET" && SERVICE=$(escape "$SERVICESET")
|
||||
DEFAULT_NICK=${DEFAULT_NICK:-$(whoami)} || die "whoami failed"
|
||||
DEFAULT_SERVICE=${DEFAULT_SERVICE:-bpaste}
|
||||
--
|
||||
2.41.0
|
||||
|
@ -0,0 +1,171 @@
|
||||
From a1c0782e828bc5f0fc8b79d0131f1847c5e7b359 Mon Sep 17 00:00:00 2001
|
||||
From: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
|
||||
Date: Sun, 13 Aug 2023 14:52:20 -0500
|
||||
Subject: [PATCH 3/3] test_ansi: add -A to the tests
|
||||
|
||||
---
|
||||
See also: https://github.com/zlin/wgetpaste/pull/46
|
||||
- Oskari
|
||||
|
||||
test/test_ansi.sh | 92 +++++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 81 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/test/test_ansi.sh b/test/test_ansi.sh
|
||||
index 23b27a8..e1e95f0 100755
|
||||
--- a/test/test_ansi.sh
|
||||
+++ b/test/test_ansi.sh
|
||||
@@ -94,8 +94,8 @@ fi
|
||||
|
||||
# Paste stuff. Use a short timeout between requests (we're friendly after all!)
|
||||
sleep 1
|
||||
-echo -n "Pasting command output (cat): "
|
||||
-ERROR_LOG="$DL_DIR/command-error.log"
|
||||
+echo -n "Pasting command output with ANSI stripping (cat): "
|
||||
+ERROR_LOG="$DL_DIR/command-noansi-error.log"
|
||||
URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FAILED!"
|
||||
@@ -104,7 +104,7 @@ else
|
||||
echo "SUCCESS!"
|
||||
|
||||
echo -n "Downloading: "
|
||||
- if ! (wget -q "$URL" -O "$DL_DIR/command.txt" 2>>"$ERROR_LOG"); then
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/command-noansi.txt" 2>>"$ERROR_LOG"); then
|
||||
echo "FAILED!"
|
||||
FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
else
|
||||
@@ -112,13 +112,35 @@ else
|
||||
rm "$ERROR_LOG"
|
||||
|
||||
echo "Removing 'command run' header"
|
||||
- sed -i -e '1d' "$DL_DIR/command.txt"
|
||||
+ sed -i -e '1d' "$DL_DIR/command-noansi.txt"
|
||||
+ fi
|
||||
+fi
|
||||
+sleep 1
|
||||
+echo -n "Pasting command output without ANSI stripping (cat): "
|
||||
+ERROR_LOG="$DL_DIR/command-ansi-error.log"
|
||||
+URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
|
||||
+if [ $? -ne 0 ]; then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+else
|
||||
+ echo "SUCCESS!"
|
||||
+
|
||||
+ echo -n "Downloading: "
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/command-ansi.txt" 2>>"$ERROR_LOG"); then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+ else
|
||||
+ echo "SUCCESS"
|
||||
+ rm "$ERROR_LOG"
|
||||
+
|
||||
+ echo "Removing 'command run' header"
|
||||
+ sed -i -e '1d' "$DL_DIR/command-ansi.txt"
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
-echo -n "Pasting stdin (cat | wgetpaste): "
|
||||
-ERROR_LOG="$DL_DIR/stdin-error.log"
|
||||
+echo -n "Pasting stdin with ANSI stripping (cat | wgetpaste): "
|
||||
+ERROR_LOG="$DL_DIR/stdin-noansi-error.log"
|
||||
URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v 2>"$ERROR_LOG")"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FAILED!"
|
||||
@@ -127,7 +149,26 @@ else
|
||||
echo "SUCCESS!"
|
||||
|
||||
echo -n "Downloading: "
|
||||
- if ! (wget -q "$URL" -O "$DL_DIR/stdin.txt" 2>>"$ERROR_LOG"); then
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/stdin-noansi.txt" 2>>"$ERROR_LOG"); then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+ else
|
||||
+ echo "SUCCESS!"
|
||||
+ rm "$ERROR_LOG"
|
||||
+ fi
|
||||
+fi
|
||||
+sleep 1
|
||||
+echo -n "Pasting stdin without ANSI stripping (cat | wgetpaste): "
|
||||
+ERROR_LOG="$DL_DIR/stdin-ansi-error.log"
|
||||
+URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v 2>"$ERROR_LOG")"
|
||||
+if [ $? -ne 0 ]; then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+else
|
||||
+ echo "SUCCESS!"
|
||||
+
|
||||
+ echo -n "Downloading: "
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/stdin-ansi.txt" 2>>"$ERROR_LOG"); then
|
||||
echo "FAILED!"
|
||||
FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
else
|
||||
@@ -137,8 +178,8 @@ else
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
-echo -n "Pasting a file: "
|
||||
-ERROR_LOG="$DL_DIR/file-error.log"
|
||||
+echo -n "Pasting a file with ANSI stripping: "
|
||||
+ERROR_LOG="$DL_DIR/file-noansi-error.log"
|
||||
URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FAILED!"
|
||||
@@ -147,7 +188,26 @@ else
|
||||
echo "SUCCESS!"
|
||||
|
||||
echo -n "Downloading: "
|
||||
- if ! (wget -q "$URL" -O "$DL_DIR/file.txt" 2>>"$ERROR_LOG"); then
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/file-noansi.txt" 2>>"$ERROR_LOG"); then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+ else
|
||||
+ echo "SUCCESS!"
|
||||
+ rm "$ERROR_LOG"
|
||||
+ fi
|
||||
+fi
|
||||
+sleep 1
|
||||
+echo -n "Pasting a file without ANSI stripping: "
|
||||
+ERROR_LOG="$DL_DIR/file-ansi-error.log"
|
||||
+URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
|
||||
+if [ $? -ne 0 ]; then
|
||||
+ echo "FAILED!"
|
||||
+ FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
+else
|
||||
+ echo "SUCCESS!"
|
||||
+
|
||||
+ echo -n "Downloading: "
|
||||
+ if ! (wget -q "$URL" -O "$DL_DIR/file-ansi.txt" 2>>"$ERROR_LOG"); then
|
||||
echo "FAILED!"
|
||||
FAILED_PASTE=$((FAILED_PASTE + 1))
|
||||
else
|
||||
@@ -157,7 +217,7 @@ else
|
||||
fi
|
||||
|
||||
# Compare downloaded files
|
||||
-for dl_file in "$DL_DIR"/*.txt; do
|
||||
+for dl_file in "$DL_DIR"/*-noansi.txt; do
|
||||
echo -n "Testing file $dl_file: "
|
||||
# Ignore missing trailing newline and extra empty lines in downloaded file
|
||||
if (diff -q -Z -B "$NOANSI_FILE" "$dl_file" &>/dev/null); then
|
||||
@@ -167,6 +227,16 @@ for dl_file in "$DL_DIR"/*.txt; do
|
||||
DL_MISMATCH=$((DL_MISMATCH + 1))
|
||||
fi
|
||||
done
|
||||
+for dl_file in "$DL_DIR"/*-ansi.txt; do
|
||||
+ echo -n "Testing file $dl_file: "
|
||||
+ # Ignore missing trailing newline and extra empty lines in downloaded file
|
||||
+ if (diff -q -Z -B "$ANSI_FILE" "$dl_file" &>/dev/null); then
|
||||
+ echo "SUCCESS!"
|
||||
+ else
|
||||
+ echo "FAILED!"
|
||||
+ DL_MISMATCH=$((DL_MISMATCH + 1))
|
||||
+ fi
|
||||
+done
|
||||
|
||||
echo "Total failed pastes: $FAILED_PASTE"
|
||||
echo "Total mismatches: $DL_MISMATCH"
|
||||
--
|
||||
2.41.0
|
||||
|
@ -0,0 +1,57 @@
|
||||
# Copyright 1999-2023 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
# NOTE: This is a version of `app-text/wgetpaste-2.33-r5::gentoo` with additional services
|
||||
|
||||
EAPI=8
|
||||
|
||||
inherit optfeature
|
||||
|
||||
DESCRIPTION="Command-line interface to various pastebins"
|
||||
HOMEPAGE="https://github.com/zlin/wgetpaste"
|
||||
SRC_URI="https://github.com/zlin/wgetpaste/releases/download/${PV}/${P}.tar.xz"
|
||||
|
||||
LICENSE="MIT"
|
||||
SLOT="0"
|
||||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
|
||||
IUSE="+ssl"
|
||||
|
||||
PROPERTIES="test_network"
|
||||
RESTRICT="test"
|
||||
|
||||
RDEPEND="net-misc/wget[ssl?]"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/${PN}-2.33-tests.patch
|
||||
"${FILESDIR}"/${PN}-2.33-disable-sprunge.patch
|
||||
"${FILESDIR}"/${PN}-2.33-add-paste-gentoo-zip.patch
|
||||
"${FILESDIR}"/${PN}-2.33-change-arg-parsing-priority.patch
|
||||
"${FILESDIR}"/${PN}-2.33-add-A-ansi.patch
|
||||
"${FILESDIR}"/${PN}-2.33-test_ansi-add-A-to-the-tests.patch
|
||||
"${FILESDIR}"/${PN}-2.33-added-quiet-flag.patch
|
||||
"${FILESDIR}"/${PN}-2.33-add-paste-calculate.patch
|
||||
"${FILESDIR}"/${PN}-2.33-add-paste-orgru.patch
|
||||
)
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
|
||||
sed -i -e "s:/etc:\"${EPREFIX}\"/etc:g" wgetpaste || die
|
||||
}
|
||||
|
||||
src_test() {
|
||||
test/test.sh || die
|
||||
}
|
||||
|
||||
src_install() {
|
||||
dobin ${PN}
|
||||
insinto /usr/share/zsh/site-functions
|
||||
doins _wgetpaste
|
||||
insinto /etc/wgetpaste.d
|
||||
newins "${FILESDIR}"/wgetpaste-config-services services.conf
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
optfeature "ANSI (color code) stripping support" app-text/ansifilter
|
||||
optfeature "xclip support" x11-misc/xclip
|
||||
}
|
Loading…
Reference in new issue