Skip to content

Commit

Permalink
Fix for new RPC behavior
Browse files Browse the repository at this point in the history
The new version of aurget-web changes two RPC behaviors:

- `+` in URL params is no longer accepted, must use `%20`
- The order of fields in the JSON response has changed

Fixing the former was a trivial simplification.

Depending on a fixed order of keys in JSON is a (long-standing) bug and the
fix would be to depend on an actual JSON parser, like `jq`. We may do that in
the future, but for now we are getting aurget functional again by simply reading
the keys in the new order they come out.

Co-authored-by: patrick brisbin <pbrisbin@gmail.com>
  • Loading branch information
aragon999 and pbrisbin authored Feb 12, 2022
1 parent da7c9a8 commit 799bc18
Show file tree
Hide file tree
Showing 177 changed files with 481 additions and 379 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man

PERC = '%'

doc/aurget.1: doc/aurget.1.md
kramdown-man < doc/aurget.1.md > doc/aurget.1
[ -s doc/aurget.1 ]
Expand All @@ -14,6 +16,21 @@ man: doc/aurget.1 doc/aurgetrc.5
test:
FIXTURES_NO_RECORD=1 cram test

fixtures.reset:
@echo "Running tests with fixture updates..."
cram test
@echo "Cleaning up any fixtures not recently accessed..."
for x in test/fixtures/*/*/last-access; do \
now=$$(date +'$(PERC)s'); \
last_access=$$(date --date="$$(cat $$x)" +'$(PERC)s'); \
age=$$((now - $$last_access)); \
if ((age > 60)); then \
echo "$$x is $${age}s old, removing"; \
rm "$$x"; \
fi; \
done


install:
install -Dm755 aurget $(DESTDIR)/$(PREFIX)/bin/aurget
install -Dm644 aurgetrc $(DESTDIR)/$(PREFIX)/share/doc/aurget/samples/aurgetrc
Expand All @@ -38,4 +55,4 @@ release: test
git push --follow-tags
aur-release aurget "$(RELEASE_TAG)"

.PHONY: test install uninstall release
.PHONY: test fixtures.reset install uninstall release
21 changes: 10 additions & 11 deletions aurget
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ debug() {
url_encode() {
hexdump -v -e '1/1 "%02x\t"' -e '1/1 "%_c\n"' <<<"$*" |
LANG=C awk '
$1 == "20" { printf("%s", "+"); next }
$1 ~ /0[adAD]/ { next }
$2 ~ /^[a-zA-Z0-9.*()\/_-]$/ { printf("%s", $2); next }
{ printf("%%%s", $1) }
Expand Down Expand Up @@ -140,13 +139,13 @@ parse_rpc() {
return str
}
/Name":/ { printf "%s", unstring($0) }
/Description":/ { printf "%s", unstring($0) }
/Name":/ { printf "|%s", unstring($0) }
/NumVotes":/ { printf "|%s", unstring($0) }
/OutOfDate":/ { printf "|%s", unstring($0) }
/PackageBase":/ { printf "|%s", unstring($0) }
/Version":/ { printf "|%s", unstring($0) }
/Description":/ { printf "|%s", unstring($0) }
/URL":/ { printf "|%s", unstring($0) }
/NumVotes":/ { printf "|%s", unstring($0) }
/OutOfDate":/ { printf "|%s\n", unstring($0) }
/Version":/ { printf "|%s\n", unstring($0) }
'
}

Expand Down Expand Up @@ -451,15 +450,15 @@ perform_search() {
case "$search_mode" in
search) rpc_search "$*" | print_search ;;
info) rpc_info "$@" | print_info ;;
quiet) rpc_search "$*" | cut -d '|' -f 1 ;;
quiet) rpc_search "$*" | cut -d '|' -f 2 ;;
print) for name; do pkgbuild "$name"; done ;;
esac
}

print_search() {
local name version description outofdate ood

while IFS='|' read -r name _ version description _ _ outofdate; do
while IFS='|' read -r description name _ outofdate _ _ version; do
ood=''

((outofdate)) && ood="${colorR}[out of date]${nocolor}"
Expand All @@ -472,7 +471,7 @@ print_search() {
print_info() {
local name version description url votes outofdate ood

while IFS='|' read -r name pkgbase version description url votes outofdate; do
while IFS='|' read -r description name votes outofdate pkgbase url version; do
ood='No'

((outofdate)) && ood="${colorR}Yes$nocolor"
Expand Down Expand Up @@ -514,7 +513,7 @@ available_upgrades() {

debug "found $colorG${#versions[@]}$nocolor foreign packages to check"

while IFS='|' read -r name pkgbase versN _; do
while IFS='|' read -r _ name _ _ pkgbase _ versN; do
if is_devel "$name"; then
$devels && output_upgrade "$name" 'development package'
continue
Expand Down Expand Up @@ -622,7 +621,7 @@ setup_targets() {

info 'Searching AUR...'

while IFS='|' read -r name pkgbase version _; do
while IFS='|' read -r _ name _ _ pkgbase _ version; do
debug "found $colorG$name$nocolor in the AUR at version $colorG$version$nocolor"
pkgbases[$name]=$pkgbase
versions[$name]=$version
Expand Down
2 changes: 1 addition & 1 deletion test/build.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Building the package for aurget
warning: * (glob)
:: Searching AUR...

Targets (1): aurget-4.6.0-1
Targets (1): aurget-4.7.5-1

Proceed with installation? [Y/n] Y
:: Retrieving taurball from AUR...
Expand Down
6 changes: 3 additions & 3 deletions test/dependencies.t
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$ source "$TESTDIR/helper.sh"

Resolving dependencies for aws-cli
Resolving dependencies for aws-cli-v2

$ echo n | aurget -Sb --builddir "$PWD" --noedit --deps aws-cli
$ echo n | aurget -Sb --builddir "$PWD" --noedit --deps aws-cli-v2
warning: * (glob)
:: Resolving dependencies...
:: Searching AUR...

Targets (2): python-botocore-1.3.30-1 aws-cli-1.10.8-1
Targets (2): python-botocore-v2-git-r7659.1a4caa8d1-1 aws-cli-v2-2.0.60-1

Proceed with installation? [Y/n] (no-eol)
4 changes: 2 additions & 2 deletions test/download.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Downloading the taurball for aurget
warning: * (glob)
:: Searching AUR...

Targets (1): aurget-4.6.0-1
Targets (1): aurget-4.7.5-1

Proceed with installation? [Y/n] Y
:: Retrieving taurball from AUR...
Expand All @@ -22,7 +22,7 @@ Downloading a taurball with special characters
warning: * (glob)
:: Searching AUR...

Targets (1): bisonc++-4.13.00-1
Targets (1): bisonc++-6.04.02-1

Proceed with installation? [Y/n] Y
:: Retrieving taurball from AUR...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--silent --fail https://aur.archlinux.org/rpc/?v=5&type=info&arg\[\]=ruby-kramdown-man&arg\[\]=google-cloud-sdk&arg\[\]=aurget&arg\[\]=csslint&arg\[\]=downgrade&arg\[\]=chruby&arg\[\]=codeclimate&arg\[\]=ruby-install&arg\[\]=laptop-mode-tools&arg\[\]=python2-notify2&arg\[\]=neovim-symlinks&arg\[\]=python-bcdoc&arg\[\]=rxvt-unicode-patched&arg\[\]=python-behave&arg\[\]=cram&arg\[\]=xrectsel&arg\[\]=rcm&arg\[\]=python-parse_type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wed Feb 9 18:21:34 GMT 2022
1 change: 1 addition & 0 deletions test/fixtures/curl/13d06cae04f8685140c93f1fc962ee6e/stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"resultcount":18,"results":[{"Depends":["docker"],"Description":"Command line interface for the Code Climate analysis platform. It allows you to run Code Climate engines on your local machine inside of Docker containers. Make sure that your current user belongs to docker group and that docker is running.","FirstSubmitted":1435163516,"Groups":["codeclimate"],"ID":314834,"Keywords":[],"LastModified":1466439993,"License":["MIT"],"Maintainer":"manzo","Name":"codeclimate","NumVotes":5,"OutOfDate":1557576297,"PackageBase":"codeclimate","PackageBaseID":95172,"Popularity":0,"URL":"https://github.com/codeclimate/codeclimate","URLPath":"/cgit/aur.git/snapshot/codeclimate.tar.gz","Version":"0.34.1-1"},{"Conflicts":["ffcast<1:2.2.0"],"Depends":["libx11"],"Description":"print the geometry of a rectangular screen region","FirstSubmitted":1440793786,"ID":345465,"Keywords":[],"LastModified":1476139016,"License":["GPL3"],"Maintainer":"lolilolicon","MakeDepends":["autoconf","automake"],"Name":"xrectsel","NumVotes":21,"OutOfDate":null,"PackageBase":"xrectsel","PackageBaseID":98910,"Popularity":0.945483,"URL":"https://github.com/lolilolicon/xrectsel","URLPath":"/cgit/aur.git/snapshot/xrectsel.tar.gz","Version":"0.3.2-1"},{"Depends":["bash"],"Description":"Changes the current ruby. Supports both zsh and bash.","FirstSubmitted":1357326246,"ID":362188,"Keywords":[],"LastModified":1480792229,"License":["MIT"],"Maintainer":"jasonwryan","MakeDepends":["gnupg"],"Name":"chruby","NumVotes":33,"OptDepends":["zsh"],"OutOfDate":null,"PackageBase":"chruby","PackageBaseID":66020,"Popularity":0.835558,"URL":"https://github.com/postmodern/chruby","URLPath":"/cgit/aur.git/snapshot/chruby.tar.gz","Version":"0.3.9-3"},{"Depends":["python2","python2-dbus"],"Description":"Python interface to DBus notifications","FirstSubmitted":1360332617,"ID":538180,"Keywords":[],"LastModified":1535200686,"License":["BSD"],"Maintainer":null,"Name":"python2-notify2","NumVotes":46,"OutOfDate":null,"PackageBase":"python2-notify2","PackageBaseID":67043,"Popularity":0,"URL":"https://pypi.python.org/pypi/notify2/","URLPath":"/cgit/aur.git/snapshot/python2-notify2.tar.gz","Version":"0.3.1-2"},{"Conflicts":["rxvt-unicode"],"Depends":["libxft","perl","startup-notification","rxvt-unicode-terminfo"],"Description":"Unicode enabled rxvt-clone terminal emulator (urxvt) with fixed font spacing","FirstSubmitted":1292895575,"ID":621541,"Keywords":[],"LastModified":1560511063,"License":["GPL"],"Maintainer":"blueyed","Name":"rxvt-unicode-patched","NumVotes":254,"OptDepends":["gtk2-perl"],"OutOfDate":1592936364,"PackageBase":"rxvt-unicode-patched","PackageBaseID":44649,"Popularity":0.006856,"Provides":["rxvt-unicode"],"URL":"http://software.schmorp.de/pkg/rxvt-unicode.html","URLPath":"/cgit/aur.git/snapshot/rxvt-unicode-patched.tar.gz","Version":"9.22-11"},{"Depends":["python"],"Description":"Tools to help document botocore-based projects.","FirstSubmitted":1378343964,"ID":668960,"Keywords":[],"LastModified":1574304116,"License":["Apache"],"Maintainer":"severach","MakeDepends":["python","python-distribute"],"Name":"python-bcdoc","NumVotes":28,"OutOfDate":null,"PackageBase":"python-bcdoc","PackageBaseID":73186,"Popularity":0,"URL":"https://github.com/boto/bcdoc","URLPath":"/cgit/aur.git/snapshot/python-bcdoc.tar.gz","Version":"0.16.0-1"},{"Conflicts":["vim","vi","vi-vim-symlink"],"Depends":["neovim","sh"],"Description":"Runs neovim if vi or vim is called","FirstSubmitted":1439232709,"ID":671479,"Keywords":[],"LastModified":1574994128,"License":[],"Maintainer":"Scimmia","Name":"neovim-symlinks","NumVotes":57,"OutOfDate":null,"PackageBase":"neovim-symlinks","PackageBaseID":97124,"Popularity":2.448786,"Provides":["vim","vi"],"URL":null,"URLPath":"/cgit/aur.git/snapshot/neovim-symlinks.tar.gz","Version":"4-1"},{"Depends":["python","python-parse>=1.6.3","python-parse_type>=0.3.4","python-six"],"Description":"behaviour-driven development, Python style","FirstSubmitted":1448262035,"ID":726952,"Keywords":[],"LastModified":1587940308,"License":["BSD"],"Maintainer":"severach","MakeDepends":["python","python-distribute"],"Name":"python-behave","NumVotes":19,"OutOfDate":null,"PackageBase":"python-behave","PackageBaseID":103697,"Popularity":0,"URL":"https://github.com/behave/behave","URLPath":"/cgit/aur.git/snapshot/python-behave.tar.gz","Version":"1.2.7.dev1-1"},{"Depends":["sh"],"Description":"Power saving tool for Linux","FirstSubmitted":1390649408,"ID":767303,"Keywords":[],"LastModified":1595171613,"License":["GPL"],"Maintainer":"dbermond","MakeDepends":["procps-ng"],"Name":"laptop-mode-tools","NumVotes":176,"OptDepends":["acpid","bluez-utils","hdparm","sdparm","ethtool","iw","xorg-xset","hal","python","python-pyqt5"],"OutOfDate":null,"PackageBase":"laptop-mode-tools","PackageBaseID":78209,"Popularity":0.533718,"URL":"https://github.com/rickysarraf/laptop-mode-tools/","URLPath":"/cgit/aur.git/snapshot/laptop-mode-tools.tar.gz","Version":"1.74-1"},{"Conflicts":["rcm-git"],"Description":"rc file (dotfiles) management","FirstSubmitted":1439442748,"ID":803992,"Keywords":["dotfiles","rcm","thoughtbot"],"LastModified":1602584042,"License":["BSD"],"Maintainer":"Felixoid","Name":"rcm","NumVotes":16,"OutOfDate":null,"PackageBase":"rcm","PackageBaseID":97463,"Popularity":0.907076,"Provides":["rcm"],"URL":"https://github.com/thoughtbot/rcm","URLPath":"/cgit/aur.git/snapshot/rcm.tar.gz","Version":"1.3.4-1"},{"Depends":["python","python-parse>=1.6","python-six"],"Description":"simplifies to build parse types based on the parse module","FirstSubmitted":1448260463,"ID":832267,"Keywords":[],"LastModified":1607729924,"License":["BSD"],"Maintainer":"severach","MakeDepends":["python","python-distribute"],"Name":"python-parse_type","NumVotes":18,"OutOfDate":1643680377,"PackageBase":"python-parse_type","PackageBaseID":103694,"Popularity":0,"URL":"https://github.com/jenisys/parse_type","URLPath":"/cgit/aur.git/snapshot/python-parse_type.tar.gz","Version":"0.5.6-1"},{"Description":"A simple, Pacman-like AUR helper","FirstSubmitted":1257968246,"ID":860608,"Keywords":[],"LastModified":1612800696,"License":["GPL"],"Maintainer":"brisbin33","Name":"aurget","NumVotes":158,"OptDepends":["customizepkg"],"OutOfDate":null,"PackageBase":"aurget","PackageBaseID":31933,"Popularity":0.015437,"URL":"https://github.com/pbrisbin/aurget","URLPath":"/cgit/aur.git/snapshot/aurget.tar.gz","Version":"4.7.5-1"},{"Depends":["ruby","ruby-kramdown>=1.0"],"Description":"A Kramdown converter for converting Markdown files into man pages","FirstSubmitted":1423283322,"ID":901499,"Keywords":[],"LastModified":1620068039,"License":["MIT"],"Maintainer":"brisbin33","MakeDepends":["rubygems"],"Name":"ruby-kramdown-man","NumVotes":0,"OutOfDate":null,"PackageBase":"ruby-kramdown-man","PackageBaseID":90219,"Popularity":0,"URL":"https://github.com/postmodern/kramdown-man","URLPath":"/cgit/aur.git/snapshot/ruby-kramdown-man.tar.gz","Version":"0.1.8-1"},{"Depends":["bash"],"Description":"Installs Ruby, JRuby, Rubinius, MRuby or TruffleRuby.","FirstSubmitted":1442410787,"ID":977949,"Keywords":[],"LastModified":1634915324,"License":["MIT"],"Maintainer":"DenSchub","MakeDepends":["gnupg"],"Name":"ruby-install","NumVotes":15,"OptDepends":["zsh"],"OutOfDate":null,"PackageBase":"ruby-install","PackageBaseID":100122,"Popularity":2e-6,"URL":"https://github.com/postmodern/ruby-install","URLPath":"/cgit/aur.git/snapshot/ruby-install.tar.gz","Version":"0.8.3-1"},{"Conflicts":["csslint-git"],"Depends":["nodejs"],"Description":"Automated linting of Cascading Stylesheets","FirstSubmitted":1399073099,"ID":991376,"Keywords":[],"LastModified":1637359806,"License":["GPL"],"Maintainer":"Thaodan","MakeDepends":["npm","jq"],"Name":"csslint","NumVotes":11,"OutOfDate":null,"PackageBase":"csslint","PackageBaseID":81489,"Popularity":0.26078,"URL":"https://github.com/stubbornella/csslint","URLPath":"/cgit/aur.git/snapshot/csslint.tar.gz","Version":"1.0.5-2"},{"Depends":["python"],"Description":"functional testing framework for command line applications","FirstSubmitted":1450299624,"ID":1002098,"Keywords":[],"LastModified":1639380396,"License":["GPL2"],"Maintainer":"grawlinson","Name":"cram","NumVotes":2,"OutOfDate":null,"PackageBase":"cram","PackageBaseID":104721,"Popularity":0.722572,"URL":"https://bitheap.org/cram/","URLPath":"/cgit/aur.git/snapshot/cram.tar.gz","Version":"0.7-3"},{"Depends":["pacman-contrib","fzf"],"Description":"Bash script for downgrading one or more packages to a version in your cache or the A.L.A.","FirstSubmitted":1257990537,"ID":1024430,"Keywords":[],"LastModified":1643039551,"License":["GPL"],"Maintainer":"brisbin33","Name":"downgrade","NumVotes":629,"OptDepends":["sudo"],"OutOfDate":null,"PackageBase":"downgrade","PackageBaseID":31937,"Popularity":10.496822,"URL":"https://github.com/pbrisbin/downgrade","URLPath":"/cgit/aur.git/snapshot/downgrade.tar.gz","Version":"11.0.0-1"},{"Depends":["python"],"Description":"A set of command-line tools for the Google Cloud Platform. Includes gcloud (with beta and alpha commands), gsutil, and bq.","FirstSubmitted":1401783013,"ID":1033797,"Keywords":["cloud","gcloud","gcp","google","sdk"],"LastModified":1644379299,"License":["Apache"],"Maintainer":"sudoforge","Name":"google-cloud-sdk","NumVotes":160,"OptDepends":["python2","python-crcmod"],"OutOfDate":null,"PackageBase":"google-cloud-sdk","PackageBaseID":82463,"Popularity":1.517441,"URL":"https://cloud.google.com/sdk/","URLPath":"/cgit/aur.git/snapshot/google-cloud-sdk.tar.gz","Version":"372.0.0-1"}],"type":"multiinfo","version":5}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--silent --fail https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=python-ruamel-yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wed Feb 9 18:21:26 GMT 2022

This file was deleted.

117 changes: 0 additions & 117 deletions test/fixtures/curl/1c601784ee62894ed6dc6cd5b6f028e8/stdout

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fri Feb 5 14:32:10 GMT 2021
Wed Feb 9 18:21:36 GMT 2022
Loading

0 comments on commit 799bc18

Please sign in to comment.