oshazard / apacman

ArchLinux User Repository (AUR) helper and pacman wrapper
https://aur.archlinux.org/packages/apacman/
GNU General Public License v3.0
70 stars 11 forks source link

new RPC call (high priority- AUR access broken without this fix) #56

Open ghost opened 8 years ago

ghost commented 8 years ago

03:06:18 < r00t^2> anyone know what the heck's going on with the AUR RPC? 03:06:29 < sheep> r00t^2: what's happening for you? 03:06:36 < demize> r00t^2: Could you be a bit more specific?.. 03:06:48 < r00t^2> demize: [root@dawid ~]# curl -LfG --data-urlencode "arg=dumpet" https://aur.archlinux.org/rpc.php?type=info 03:06:49 < r00t^2> {"version":1,"type":"info","resultcount":0,"results":[]} 03:07:01 < sheep> and what's the expected output? 03:07:06 < r00t^2> yet, https://aur.archlinux.org/packages/dumpet/ 03:07:24 < r00t^2> sheep: "not none" 03:07:40 < sheep> try curl -LfG "https://aur.archlinux.org/rpc.php?type=info&arg=dumpet" 03:07:58 < demize> r00t^2: curl 'https://aur.archlinux.org/rpc/?v=5&type=info&arg\[\]=dumpet' works fine. 03:08:35 < r00t^2> hrm.. was that changed recently? 03:09:09 < sheep> I thought what demize said was always the correct way 03:10:57 < r00t^2> hrm.. the rpc docs seem to indicate that. what on earth. thanks sheep, demize! 03:11:21 < r00t^2> i'm guessing that was AUR3 functionality that was removed finally or something 03:11:28 < sheep> possibly 03:11:59 < sheep> https://aur.archlinux.org/rpc/?v=5&type=info&arg=dumpet' still works 03:12:08 < demize> arg has been an array since version 5

ghost commented 8 years ago

a wild patch emerges!

--- a/usr/bin/apacman   2015-11-04 23:53:56.000000000 -0500
+++ b/usr/bin/apacman   2016-02-29 04:45:47.317438823 -0500
@@ -72,7 +72,7 @@
 pager="less -R"
 [[ $PAGER ]] && pager="$PAGER"

-RPCURL="https://aur.archlinux.org/rpc.php?type"
+RPCURL="https://aur.archlinux.org/rpc/?v=5&type"
 PKGURL="https://aur.archlinux.org"
 WEBURL="https://www.archlinux.org"
 ABSURL="rsync.archlinux.org"
@@ -221,7 +221,8 @@
   pkgver=$(jshon -Qe results < $1 -Qe Version -u)
   pkgbase=$(jshon -Qe results < $1 -Qe PackageBase -u)
   url=$(jshon -Qe results < $1 -Qe URL -u)
-  license=($(jshon -Qe results < $1 -Qe License -u))
+  licnum=$(($(jshon -Qe results < $1 -a -e License -l)-1))
+  license=$(while [ ${licnum} -ge '0' ]; do jshon -e results < $1 -a -e License -e ${licnum} -u ; ((licnum-=1)) ; done)
   groups=$(jshon -Qe results < $1 -Qe PackageBase -u)
 }

@@ -481,7 +482,7 @@

 pkglink() {
   rpcinfo $1
-  echo "${PKGURL}$(jshon -Q -e results -e URLPath -u < "$tmpdir/$1.info")"
+  echo "${PKGURL}$(jshon -Q -e results -a -e URLPath -u < "$tmpdir/$1.info")"
 }

 absrepo() {
@@ -545,7 +546,7 @@
   rpcinfo "$1"
   unset aurversion
   if existsinaur "$1"; then
-    aurversion="$(jshon -Q -e results -e Version -u < "$tmpdir/$1.info")"
+    aurversion="$(jshon -Q -e results -a -e Version -u < "$tmpdir/$1.info")"
     if [[ "$(LC_ALL=C vercmp "$aurversion" "$2")" -gt 0  ]]; then
       return 0
     fi
@@ -555,7 +556,7 @@

 isoutofdate() {
   rpcinfo "$1"
-  [[ "$(jshon -Q -e results -e OutOfDate -u < "$tmpdir/$1.info")" = "1" ]]
+  [[ "$(jshon -Q -e results -a -e OutOfDate -u < "$tmpdir/$1.info")" = "1" ]]
 }

 # List bundle package files

the downside is with the looping (ever since the license field was force-checked to be an array in pacman 5.x) (such as here, and also affecting the actual apacman and related PKGBUILDs in the AUR)... it seems to add a considerable time cost, but i wasn't sure how else to handle it. but it sucks.

anyways, this should at least get people working with apacman again.

Airblader commented 8 years ago

+1

The patch above works for me as well (thanks!)