Commit 3bcea87b authored by george's avatar george

added ccr-tools, updated ccr pkgbuild

parent e452cd4e
......@@ -7,7 +7,7 @@
pkgname=ccr
pkgver=4.0.1
pkgrel=3
pkgrel=4
pkgdesc="A Bash wrapper for the CCR"
license="GPL"
arch=('any')
......@@ -16,10 +16,12 @@ optdepends=('sudo: install and update packages as non-root')
#source=("http://chakra-project.org/sources/ccr/ccr-$pkgver.tar.xz"
categories=('system')
source=("http://chakra-linux.org/sources/ccr/ccr-$pkgver.tar.gz"
"ccr-submit"
"ccr-vote"
"fixnumbering.patch")
md5sums=('0f01f2ea1606f04ee9cd51b51b9e15c9'
'8c179875982d98c542ebb826f50f7924'
'bf1076c88c72a114f3f9edb38b76db74'
'6437df892eab6c4071b16bfaf4935818'
'f62fdaece2b8789ed95294fa259509a1')
package() {
......@@ -31,4 +33,5 @@ package() {
cd $srcdir
install -m 775 -D ccr-vote "$pkgdir/usr/bin/ccr-vote"
install -m 775 -D ccr-submit "$pkgdir/usr/bin/ccr-submit"
}
#!/bin/bash
ver=0.1
tempdir=$(mktemp -d)
configrc=$HOME/.config/ccr-toolsrc
ccrbaseurl="http://chakra-linux.org/ccr/"
submiturl="${ccrbaseurl}pkgsubmit.php"
# Defining some functions needed by main program
getcat() {
declare -A categories
categories=(
["daemons"]="2"
["devel"]="3"
["editors"]="4"
["educational"]="15"
["emulators"]="5"
["games"]="6"
["gnome"]="7"
["i18n"]="8"
["kde"]="9"
["lib"]="10"
["lib32"]="19"
["modules"]="11"
["multimedia"]="12"
["network"]="13"
["office"]="14"
["system"]="16"
["utils"]="18"
["x11"]="17"
)
catvalue=${categories[$1]}
if [[ "${catvalue}" == "" ]]; then
echo "'$1' is not a valid category."
die 1
fi
}
die() {
if [ -d "$tempdir" ]; then
rm -rf "$tempdir"
fi
exit $1
}
version() {
echo "ccr-submit - version $ver"
echo
echo " https://github.com/Ram-Z/ccr-tools"
die 0
}
use() {
echo "ccr-submit - version $ver"
echo
echo "usage: ccr-submit -c <category> <pkgsrc>"
echo
echo "ccr-submit --version, -V shows version"
echo "ccr-submit --help, -h shows this help"
echo
echo " example: ccr-submit -c devel ccr-submit-$ver.src.tar.gz"
echo
echo "You can create ~/.config/ccr-toolsrc containing:"
echo "user=YOUR_CCR_USERNAME"
echo "pass=YOUR_CCR_PASS"
echo
echo "To create a new account just go to:"
echo "http://chakra-linux.org/ccr/account.php"
echo
echo "Fork of ccr-vote"
echo "written by Ram-Z <samir.benmendil[at]gmail[dot]com>"
echo " https://github.com/Ram-Z/ccr-tools"
}
urlencode(){
echo $@ | LANG=C awk '
BEGIN {
split ("1 2 3 4 5 6 7 8 9 A B C D E F", hextab, " ")
hextab [0] = 0
for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0
}
{
encoded = ""
for ( i=1; i<=length ($0); ++i ) {
c = substr ($0, i, 1)
if ( c ~ /[a-zA-Z0-9.-]/ ) {
encoded = encoded c # safe character
} else if ( c == " " ) {
encoded = encoded "+" # special handling
} else {
# unsafe character, encode it as a two-digit hex-number
lo = ord [c] % 16
hi = int (ord [c] / 16);
encoded = encoded "%" hextab [hi] hextab [lo]
}
}
print encoded
}
END {
}
'
}
### MAIN PROGRAM ###
while [ "$#" -ne "0" ]; do
case $1 in
--help|-h)
use
die 0
;;
--version|-V) version;;
--category|-c) shift; category=$1;;
--*|-*)
use
die 0
;;
*)
pkgsrc=$1
;;
esac
shift
done
if [[ $pkgsrc == "" ]]; then
use
die 0
fi
# we don't even want to submit something different than source files
if [[ ! -f $pkgsrc || $pkgsrc != *.src.tar.gz ]]; then
echo "`basename ${pkgsrc}` is not a source package!"
die 1
fi
# check for category
if [[ $category == "" ]]; then
echo "You must provide a category."
die 1
fi
getcat $category
# Check config file
if [ -r ~/.ccr-toolsrc ] && [ ! -r "$configrc" ]; then
echo "Moving ~/.ccr-toolsrc to $configrc"
mv ~/.ccr-toolsrc $configrc
fi
[ -r "$configrc" ] && source $configrc
[[ -z $user ]] && read -p "please enter your CCR username: " user
[[ -z $pass ]] && read -p "please enter your CCR password: " -s pass && echo
#logins to ccr and keeps sesion alive
umask 077
curl -Ss --cookie-jar "$tempdir/cjar" --output /dev/null ${ccrbaseurl}
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" \
--data "user=$user" --data "passwd=$(urlencode $pass)" \
--location --output "$tempdir/ccrvote.login" \
${ccrbaseurl}
if grep --quiet "'error'>Bad username or password" "$tempdir/ccrvote.login"; then
echo "incorrect password: check $configrc file"
die 1
fi
# submit file
echo "`basename ${pkgsrc}`"
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" \
--form "pkgsubmit=1" \
--form "pfile=@${pkgsrc}" \
--form "category=${catvalue}" \
--output /dev/null \
"${submiturl}"
die 0
# vim: sts=4 ts=4 sw=4 et
......@@ -2,43 +2,50 @@
ver=0.1
tempdir=$(mktemp -d)
configrc=$HOME/.config/ccr-toolsrc
ccrurl="http://chakra-linux.org/ccr/packages.php"
idurl="http://chakra-linux.org/ccr/rpc.php?type=info&arg="
checkurl="http://chakra-linux.org/ccr/packages.php?ID="
ccrbaseurl="http://chakra-linux.org/ccr/"
ccrurl="${ccrbaseurl}packages.php"
idurl="${ccrbaseurl}rpc.php?type=info&arg="
checkurl="${ccrbaseurl}packages.php?ID="
# Defining some functions needed by main program
die() {
if [ -d "$tempdir" ]; then
rm -rf "$tempdir"
fi
exit $1
if [ -d "$tempdir" ]; then
rm -rf "$tempdir"
fi
exit $1
}
version() {
echo "ccr-vote - version $ver"
echo
echo " http://cruznick.github.com/"
die 0
echo "ccr-vote - version $ver"
echo
echo " http://cruznick.github.com/"
die 0
}
use() {
echo "ccr-vote - version $ver"
echo
echo "usage: ccr-vote <option> <pkgname1> <pkgname2> ..."
echo
echo "ccr-vote --version, -V shows version"
echo "ccr-vote --help, -h shows this help"
echo "ccr-vote --vote, -v vote for packages"
echo "ccr-vote --unvote, -u unvote packages"
echo "ccr-vote --check, -c check for voted packages"
echo
echo " example: ccr-vote --vote shake bfilter"
echo
echo "Fork of aurvote <http://archlinux.fr/>"
echo "written by cruznick <cruznick at archlinux dot us>"
echo " http://cruznick.github.com"
echo "ccr-vote - version $ver"
echo
echo "usage: ccr-vote <option> <pkgname1> <pkgname2> ..."
echo
echo "ccr-vote --version, -V shows version"
echo "ccr-vote --help, -h shows this help"
echo "ccr-vote --vote, -v vote for packages"
echo "ccr-vote --unvote, -u unvote packages"
echo "ccr-vote --check, -c check for voted packages"
echo
echo " example: ccr-vote --vote shake bfilter"
echo
echo "You can create ~/.config/ccr-toolsrc containing:"
echo "user=YOUR_CCR_USERNAME"
echo "pass=YOUR_CCR_PASS"
echo
echo "To create a new account just go to:"
echo "http://chakra-linux.org/ccr/account.php"
echo "Fork of aurvote <http://archlinux.fr/>"
echo "written by cruznick <cruznick at archlinux dot us>"
echo " http://cruznick.github.com"
}
......@@ -75,7 +82,7 @@ action="vote"
while [ "$#" -ne "0" ]; do
case $1 in
--help|-h)
usage
use
die 0
;;
--version|-V) version;;
......@@ -83,7 +90,7 @@ while [ "$#" -ne "0" ]; do
--vote|-v) action="vote";;
--unvote|-u) action="unvote";;
--*|-*)
usage
use
die 0
;;
*)
......@@ -102,26 +109,20 @@ fi
if [ -r ~/.ccr-toolsrc ] && [ ! -r "$configrc" ]; then
echo "Moving ~/.ccr-toolsrc to $configrc"
mv ~/.ccr-toolsrc $configrc
elif [ ! -r $configrc ]; then
echo "You have to create ~/.config/ccr-toolsrc with inside:"
echo "user=YOUR_CCR_USERNAME"
echo "pass=YOUR_CCR_PASS"
echo
echo "To create a new account just go to:"
echo "http://chakra-linux.org/ccr/account.php"
die 1
fi
source $configrc || die 1
[ -r "$configrc" ] && source $configrc
[[ -z $user ]] && read -p "please enter your CCR username: " user
[[ -z $pass ]] && read -p "please enter your CCR password: " -s pass && echo
#logins to ccr and keeps sesion alive
umask 077
curl -Ss --cookie-jar "$tempdir/cjar" --output /dev/null http://chakra-linux.org/ccr/
curl -Ss --cookie-jar "$tempdir/cjar" --output /dev/null ${ccrbaseurl}
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" \
--data "user=$user" --data "passwd=$(urlencode $pass)" \
--location --output "$tempdir/ccrvote.login" \
http://chakra-project.org/ccr/
${ccrbaseurl}
if grep --quiet "'error'>Bad username or password" "$tempdir/ccrvote.login";then
echo "incorrect password: check $configrc file"
die 1
......@@ -129,12 +130,12 @@ fi
# vote/unvote/check for each package
for pkgname in ${pkgnames[@]}; do
ccrid=$(wget --quiet "${idurl}${pkgname}" -O - | \
sed 's/.*"ID":"\([^"]*\)".*/\1/;q')
if [ -z "$ccrid" ]; then
echo "$pkgname was not found on CCR"
continue
fi
ccrid=$(wget --quiet "${idurl}${pkgname}" -O - | \
sed 's/.*"ID":"\([^"]*\)".*/\1/;q')
if [ -z "$ccrid" ]; then
echo "$pkgname was not found on CCR"
continue
fi
if [ "$action" = "check" ]; then
echo -n "$pkgname: "
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" --output "$tempdir/$pkgname" "${checkurl}${ccrid}"
......@@ -165,3 +166,5 @@ for pkgname in ${pkgnames[@]}; do
done
die 0
# vim: sts=4 ts=4 sw=4 et
#!/bin/bash
ver=0.1
tempdir=$(mktemp -d)
configrc=$HOME/.config/ccr-toolsrc
ccrurl="http://chakra-linux.org/ccr/packages.php"
idurl="http://chakra-linux.org/ccr/rpc.php?type=info&arg="
checkurl="http://chakra-linux.org/ccr/packages.php?ID="
# Defining some functions needed by main program
die() {
if [ -d "$tempdir" ]; then
rm -rf "$tempdir"
fi
exit $1
}
version() {
echo "ccr-vote - version $ver"
echo
echo " http://cruznick.github.com/"
die 0
}
use() {
echo "ccr-vote - version $ver"
echo
echo "usage: ccr-vote <option> <pkgname1> <pkgname2> ..."
echo
echo "ccr-vote --version, -V shows version"
echo "ccr-vote --help, -h shows this help"
echo "ccr-vote --vote, -v vote for packages"
echo "ccr-vote --unvote, -u unvote packages"
echo "ccr-vote --check, -c check for voted packages"
echo
echo " example: ccr-vote --vote shake bfilter"
echo
echo "Fork of aurvote <http://archlinux.fr/>"
echo "written by cruznick <cruznick at archlinux dot us>"
echo " http://cruznick.github.com"
}
urlencode(){
echo $@ | LANG=C awk '
BEGIN {
split ("1 2 3 4 5 6 7 8 9 A B C D E F", hextab, " ")
hextab [0] = 0
for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0
}
{
encoded = ""
for ( i=1; i<=length ($0); ++i ) {
c = substr ($0, i, 1)
if ( c ~ /[a-zA-Z0-9.-]/ ) {
encoded = encoded c # safe character
} else if ( c == " " ) {
encoded = encoded "+" # special handling
} else {
# unsafe character, encode it as a two-digit hex-number
lo = ord [c] % 16
hi = int (ord [c] / 16);
encoded = encoded "%" hextab [hi] hextab [lo]
}
}
print encoded
}
END {
}
'
}
### MAIN PROGRAM ###
action="vote"
while [ "$#" -ne "0" ]; do
case $1 in
--help|-h)
usage
die 0
;;
--version|-V) version;;
--check|-c) action="check";;
--vote|-v) action="vote";;
--unvote|-u) action="unvote";;
--*|-*)
usage
die 0
;;
*)
pkgnames[${#pkgnames[@]}]=$1
;;
esac
shift
done
if [ ${#pkgnames[@]} -eq 0 ]; then
use
die 0
fi
# Check config file
if [ -r ~/.ccr-toolsrc ] && [ ! -r "$configrc" ]; then
echo "Moving ~/.ccr-toolsrc to $configrc"
mv ~/.ccr-toolsrc $configrc
elif [ ! -r $configrc ]; then
echo "You have to create ~/.config/ccr-toolsrc with inside:"
echo "user=YOUR_CCR_USERNAME"
echo "pass=YOUR_CCR_PASS"
echo
echo "To create a new account just go to:"
echo "http://chakra-linux.org/ccr/account.php"
die 1
fi
source $configrc || die 1
#logins to ccr and keeps sesion alive
umask 077
curl -Ss --cookie-jar "$tempdir/cjar" --output /dev/null http://chakra-linux.org/ccr/
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" \
--data "user=$user" --data "passwd=$(urlencode $pass)" \
--location --output "$tempdir/ccrvote.login" \
http://chakra-project.org/ccr/
if grep --quiet "'error'>Bad username or password" "$tempdir/ccrvote.login";then
echo "incorrect password: check $configrc file"
die 1
fi
# vote/unvote/check for each package
for pkgname in ${pkgnames[@]}; do
ccrid=$(wget --quiet "${idurl}${pkgname}" -O - | \
sed 's/.*"ID":"\([^"]*\)".*/\1/;q')
if [ -z "$ccrid" ]; then
echo "$pkgname was not found on CCR"
continue
fi
if [ "$action" = "check" ]; then
echo -n "$pkgname: "
curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" --output "$tempdir/$pkgname" "${checkurl}${ccrid}"
if grep -q "type='submit' class='button' name='do_UnVote'" $tempdir/$pkgname; then
echo "already voted"
elif grep -q "type='submit' class='button' name='do_Vote'" $tempdir/$pkgname; then
echo "not voted"
else
echo "voted status not found"
fi
elif [ "$action" = "vote" ]; then
if curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" --data "IDs[${ccrid}]=1" \
--data "ID=${ccrid}" --data "do_Vote=1" \
--output /dev/null http://chakra-linux.org/ccr/packages.php; then
echo "$pkgname now voted"
else
echo "ERROR: Can't access $ccrurl"
fi
elif [ "$action" = "unvote" ]; then
if curl -Ss --cookie "$tempdir/cjar" --cookie-jar "$tempdir/cjar" --data "IDs[${ccrid}]=1" \
--data "ID=${ccrid}" --data "do_UnVote=1" \
--output /dev/null http://chakra-linux.org/ccr/packages.php; then
echo "$pkgname now unvoted"
else
echo "ERROR: Can't access $ccrurl"
fi
fi
done
die 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment