summaryrefslogtreecommitdiff
path: root/pcr
diff options
context:
space:
mode:
authoraurelien <aurelien@xload.io>2014-05-30 18:51:42 +0200
committeraurelien <aurelien@xload.io>2014-05-30 18:51:42 +0200
commit494000bf5b23862160c9c1cd2a64e49031e8079e (patch)
tree310452cd9f9eec6faa1cb235bf433bdb66f75d96 /pcr
parent6909ff0810d2b6607e07229ddf97d178822efbb7 (diff)
downloadabslibre-494000bf5b23862160c9c1cd2a64e49031e8079e.tar.gz
abslibre-494000bf5b23862160c9c1cd2a64e49031e8079e.tar.bz2
abslibre-494000bf5b23862160c9c1cd2a64e49031e8079e.zip
aurvote
Diffstat (limited to 'pcr')
-rw-r--r--pcr/aurvote/PKGBUILD10
-rwxr-xr-x[-rw-r--r--]pcr/aurvote/aurvote46
2 files changed, 39 insertions, 17 deletions
diff --git a/pcr/aurvote/PKGBUILD b/pcr/aurvote/PKGBUILD
index 712e5d2c4..25dd1887d 100644
--- a/pcr/aurvote/PKGBUILD
+++ b/pcr/aurvote/PKGBUILD
@@ -1,8 +1,8 @@
-# Maintainer (Arch): tuxce <tuxce.net@gmail.com>
-# Maintainer: Parabola GNU / Linux-libre Aurelien Desbrieres <aurelien@cwb.io>
+# Contributor: tuxce <tuxce.net@gmail.com>
+# Maintainer : Parabola Aurélien DESBRIÈRES <aurelien@hackers.camp>
pkgname=aurvote
-pkgver=1.4
+pkgver=1.6
pkgrel=1
pkgdesc="Tool to vote for favorite AUR packages"
url="http://git.archlinux.fr/aurvote.git/"
@@ -11,8 +11,6 @@ arch=('any')
depends=('curl')
source=($pkgname)
-build() {
+package() {
install -D -m 755 "$srcdir/$pkgname" "$pkgdir/usr/bin/$pkgname"
}
-
-md5sums=('57f2f0822b833f6c858526eb7c8bb85f')
diff --git a/pcr/aurvote/aurvote b/pcr/aurvote/aurvote
index 1b9c8f1bf..833267f10 100644..100755
--- a/pcr/aurvote/aurvote
+++ b/pcr/aurvote/aurvote
@@ -20,12 +20,12 @@
#
NAME='aurvote'
-VERSION=1.4
+VERSION=1.6
TMPDIR=${TMPDIR:-/tmp}
AV_TMP="$TMPDIR/aurvote-$USER"
-CONFIGFILE=${XDG_HOME_CONFIG:-~/.config}/aurvote
+CONFIGFILE=${XDG_CONFIG_HOME:-~/.config}/aurvote
AUR_URL="https://aur.archlinux.org"
AUR_URL_LOGIN="$AUR_URL/login/"
@@ -35,7 +35,7 @@ AUR_DOMAIN="aur.archlinux.org"
AUR_COOKIE="AURSID"
AUR_COOKIE_VALUE=""
AUR_SETLANG="?setlang=en"
-
+AUR_TOKEN=""
version() {
echo "$NAME $VERSION"
@@ -87,13 +87,24 @@ aur_login() {
[[ $err ]] && error "$err"
}
+aur_get_pkg_page() {
+ local pkg=$1
+ curl $CURL_OPT -fs -b "$COOKIE_FILE" \
+ "${AUR_URL_PKG_PAGE}${pkg}${AUR_SETLANG}" \
+ -o "$AV_TMP/$pkg.$PID" ||
+ error "Unable to get $pkg page"
+}
+
+aur_set_token() {
+ aur_get_pkg_page "$1"
+ AUR_TOKEN=$(sed -n -e '/<input type="hidden" name="token"/ { s/.*value="\([0-9a-f]\+\)".*/\1/p;q }' "$AV_TMP/$pkg.$PID")
+ [[ ! $AUR_TOKEN ]] && error "Unable to get token from AUR page"
+}
+
aur_check_vote() {
local pkg
for pkg in "${pkgnames[@]}"; do
- curl $CURL_OPT -fs -b "$COOKIE_FILE" \
- "${AUR_URL_PKG_PAGE}${pkg}${AUR_SETLANG}" \
- -o "$AV_TMP/$pkg.$PID" ||
- error "Unable to get $pkg page"
+ aur_get_pkg_page "$pkg"
if sed '/<div id="news">/q' "$AV_TMP/$pkg.$PID" | grep -q /unvote/; then
echo "already voted"
elif sed '/<div id="news">/q' "$AV_TMP/$pkg.$PID" | grep -q /vote/; then
@@ -106,11 +117,21 @@ aur_check_vote() {
aur_vote() {
- local pkg
- (($1)) && vote="/vote/" || vote="/unvote/"
+ local pkg vote action
+ if (($1)); then
+ vote="/vote/"
+ action=do_Vote
+ else
+ vote="/unvote/"
+ action=do_UnVote
+ fi
for pkg in "${pkgnames[@]}"; do
+ [[ ! $AUR_TOKEN ]] && aur_set_token "$pkg"
curl $CURL_OPT -fs -b "$COOKIE_FILE" \
- "${AUR_URL_PKG_PAGE}${pkg}${vote}" -o /dev/null
+ "${AUR_URL_PKG_PAGE}${pkg}${vote}" \
+ -d token="$AUR_TOKEN" \
+ -d "$action"="(Un)Vote" \
+ -o /dev/null
if (($?)); then
echo "Error: Can't (un)vote for $pkg"
else
@@ -120,7 +141,10 @@ aur_vote() {
}
create_config_file() {
- local ans
+ local ans configdir=${CONFIGFILE%/*}
+ if [[ ! -d $configdir ]]; then
+ mkdir -p "$configdir" || error "Unable to create $configdir"
+ fi
if [[ -f "$CONFIGFILE" ]]; then
read -p "$CONFIGFILE exists. Replace ? [y/N] " ans
[[ $ans != 'Y' && $ans != 'y' ]] && return 0