You are not logged in.
Pages: 1
I'm trying to write a script to check the status of a package on aur; ie, to see if its been updated since I've installed it.
Here's what I have so far:
#!/bin/sh
PACK=$1 #package name
PACKID=$2 #package ID on AUR
#grab last updated of package on AUR
LUPD=`elinks -source http://aur.archlinux.org/packages.php?ID=$PACKID | grep "Last Updated" | awk -F : '{print $2}'`
LAST=`grep -c $PACK /var/log/pacman.log` #number of instances of package
INST=`grep $PACK /var/log/pacman.log | sed -n ${LAST}p` #get last instance
echo -e "Package: $PACK \n $INST \n Last Update: $LUPD"
This basically works fine for manually inputting a package name and AUR ID (though it needs to be prettied up):
[mike@esme abs]$ aurcheck rxvt-unicode-256color 13060
Package: rxvt-unicode-256color
[2008-04-18 20:01] installed rxvt-unicode-256color (9.02-1)
Last Update: Sun, 04 May 2008 14
but what I envision is having a two column file with the first column the package name and the second the ID but I can't figure out how to make this loop around for each line of such a file. If anyone can provide some help/pointers I'd greatly appreciate it.
PS Perhaps yaourt can do this for you, but I don't use yaourt and would like to learn how to do this even just to improve my scripting abilities
Thanks!
Offline
This is a little old, but I saw it because I was searching for something similar. To answer your question, to loop over each line in a file in a script, do:
#!/bin/bash
while read line; do
echo "Processing: $line"
done < input_file.txt
I also wrote my own script for doing this. It requires curl and bc. Place this script in the same folder as your AUR builds, and run it.
#!/bin/bash
COLUMNS=`stty size | cut -d' ' -f 2`
for pkg in *; do
pacman -Q $pkg &>/dev/null
if [ 0 == $? ]; then
DOTLEN=$(echo "$COLUMNS - ${#pkg} - 11" | bc)
echo -n "checking <$pkg>"
for i in `seq $DOTLEN`; do echo -n '.'; done
if [ -f $pkg/ignore ]; then
echo -e "\b\b\b\b\b\b\b\bskipping"
else
CURR=`pacman -Q $pkg`
curl "aur.archlinux.org/packages.php?K=$pkg" 2>/dev/null \
| grep "$CURR" >/dev/null
if [ 0 == $? ]; then
echo -e "\b\bok"
else
echo -e "\b\b\b\b\b\b\b\bmismatch"
MTCH=`curl "aur.archlinux.org/packages.php?K=$pkg" 2>/dev/null \
| egrep -o "<span class='black'>$pkg [0-9.-]+</span>"`
LEN=$(echo "${#MTCH} - 27" | bc)
REM=${MTCH:20:$LEN}
echo " local : $CURR"
echo " aur : $REM"
fi
fi
fi
done
It should produce some output like:
checking <jsmin>..............................................................ok
checking <lesspipe>...........................................................ok
checking <syck>.........................................................mismatch
local : syck 0.55-1
aur : syck 0.55-2
checking <tth>................................................................ok
If you have a package you built but is not found in AUR, you can skip that one by placing a file called ignore in that directory. For example, I have a custom built php. I created the filed php/ignore and when I run the script I see:
checking <pacman-color>.......................................................ok
checking <php>..........................................................skipping
checking <pycurl>.............................................................ok
Offline
oh god. no need to scrape the html.
use the rpcJson interface. It outputs json, which you can easily regex.. or use a json library to get an array out of it.
example:
APP_NAME="nload"
CUR_VERSION=$(wget -q "http://aur.archlinux.org/rpc.php?type=info&arg=${APP_NAME}" -O - |sed -r 's#.*"[Vv]ersion":[ "]*([^",]*).*#\1#g')
echo $CUR_VERSION
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Cool. I had no idea that existed. That definitely is easier and should be quicker too. Thanks.
#!/bin/bash
COLUMNS=`stty size | cut -d' ' -f 2`
for pkg in *; do
pacman -Q $pkg &>/dev/null
if [ 0 == $? ]; then
if [ ! -f $pkg/ignore ]; then
DOTLEN=$(echo "$COLUMNS - ${#pkg} - 11" | bc)
echo -n "checking <$pkg>"
for i in `seq $DOTLEN`; do echo -n '.'; done
LOCAL_VER=$(pacman -Q $pkg | awk '{print $2}')
AUR_VER=$(curl "aur.archlinux.org/rpc.php?type=info&arg=${pkg}" \
2>/dev/null | sed -r 's#.*"[Vv]ersion":[ "]*([^",]*).*#\1#g')
if [ $LOCAL_VER == $AUR_VER ]; then
echo -e "\b\bok"
else
echo -e "\b\b\b\b\b\b\b\bmismatch"
echo " local : $LOCAL_VER"
echo " aur : $AUR_VER"
fi
fi
fi
done
Runs almost twice as fast now.
Last edited by mazzarelli (2008-08-27 20:54:16)
Offline
mazzerelli, it might not be what you want, but take a look at my aurnotify and pacmansentry, both in AUR. You need to install adesklets.
Offline
Thanks for sharing this useful little script mazzarelli. I made a few minor changes for my own use.
#!/bin/bash
# Packages to skip
IGNORE=(
"blender-svn"
"xcursor-human"
)
COLUMNS=`stty size | cut -d' ' -f 2`
for pkg in *; do
if [[ -f ${pkg}/PKGBUILD ]]; then
DOTLEN=$(echo "$COLUMNS - ${#pkg} - 12" | bc)
echo -n "checking <${pkg}>"
for i in `seq ${DOTLEN}`; do echo -n '.'; done
for i in ${IGNORE}; do
if [[ ${i} == ${pkg} ]]; then
echo -e "\b\b\b\b\b\b\b\bskipping"
continue 2
fi
done
AUR_INFO=`curl "aur.archlinux.org/rpc.php?type=info&arg=${pkg}" 2>/dev/null`
if [[ $AUR_INFO == *"No result found"* ]]; then
echo -e "\b\b\bn/a"
else
LOCAL_VER=`sed -rn -e 's/^pkgver=(.*)$/\1-/p' \
-e 's/^pkgrel=(.*)$/\1/p' ${pkg}/PKGBUILD | tr -d "\n"`
AUR_VER=`echo ${AUR_INFO} | sed -r 's#.*"[Vv]ersion":[ "]*([^",]*).*#\1#g'`
if [[ $LOCAL_VER == $AUR_VER ]]; then
echo -e "\b\bok"
else
echo -e "\b\b\b\b\b\b\b\bmismatch"
echo " local version : $LOCAL_VER"
echo " aur version : $AUR_VER"
fi
if [[ `echo $AUR_INFO -n | grep -c '"OutOfDate":"1"'` == "1" ]]; then
echo " aur flag : out of date"
fi
fi
fi
done
unset IGNORE COLUMNS DOTLEN LOCAL_VER AUR_INFO AUR_VER
Offline
Why not use spidermonkeys commandline javascript tool directly to parse the JSON? Here's a proof of concept:
0 1 # js -e "
> o=`wget -q -O - http://aur.archlinux.org/rpc.php?type=search\&arg=ifile`;
> if (o.type !== 'error') {
> r = o.results;
> for (i in r) {
> print(r[i]['Name'], '\t', r[i]['Description']);
> }
> }
> "
avifile A library that allows you to read and write compressed AVI files
perl-config-inifiles A Perl module for reading .ini-style configuration files
libtifiles2 libtifiles2 for ktigcc, tilp2 and tiemu3
libtifiles TI File format library
Offline
Oh wow, I had no idea such a thing existed... Very cool!
[git] | [AURpkgs] | [arch-games]
Offline
Oh wow, I had no idea such a thing existed... Very cool!
Expanding on my suggestion, here's the bash/js-script I use to find packages in AUR:
wget="/usr/bin/wget -q -O-"
aurrepo="http://aur.archlinux.org/rpc.php?type=search&arg="
js="/usr/bin/js"
aur() {
local iam="${FUNCNAME[0]}:"
local cmd="${1}"
local what="${2}"
local aurresult=""
[[ -z "${cmd}" ]] && {
echo "${iam}: use ${iam} (cmd) searchstring"
return 1
}
aurresult="$(${wget} ${aurrepo}${what})"
${js} -e "
var out = ${aurresult};
var res = out.results;
var i, j, len;
var tabs = ' ';
var tabstop1 = 13;
var oneline1 = {
'ID':true, 'CategoryID':true, 'NumVotes':true,
'OutOfDate':true, 'License':true
};
var oneline2 = {'Name':true, 'Version':true};
var line1='', line2='';
var others = {};
function tabto(string) {
return tabs.substring(1, tabstop1 - string.length);
};
if (out.type === 'error') {
print(res);
quit(1);
}
for (i in res) {
others = {};
line1 = '';
line2 = '';
for (j in res[i]) {
if ((typeof oneline1[j] !== 'undefined')
&& (typeof res[i][j] === 'string')) {
if (line1.length > 0) line1 = line1 + '; ';
line1 = line1 + j + ': ' + res[i][j];
} else if ((typeof oneline2[j] !== 'undefined')
&& (typeof res[i][j] === 'string')) {
if (line2.length > 0) line2 = line2 + '; ';
line2 = line2 + j + ': ' + res[i][j];
} else {
others[j] = res[i][j];
};
}
print(line2);
print(line1);
for (k in others) {
print(k + ':' + tabto(others[k]) + others[k]);
}
print('---');
};
quit(0);
"
return $?
}
Note that js(1), which has no man-page or other documentation, is part of "spidermonkey", which in turn is part of "firefox". It makes sense to assume that people have this browser installed. If at all possible, the javascript shell should have the file-methods compiled in to be able to use it like many other scripting languages, especially with JSON code. The scriptlet above works with an unmodified standard install.
Offline
novel idea using spidermonkey aurino.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
I'm trying to write a script to check the status of a package on aur; ie, to see if its been updated since I've installed it.
yaourt -Syvu --aur
is not enough ?
Zygfryd Homonto
Offline
+1 yaourt, the mere fact it updates everything means it's teh r0x0r
Offline
Pages: 1