4 # AurUp, a tool to upload packages to AUR
5 # provided by Pierluigi, mOLOk and Dundee
7 # This is free software. You may redistribute
8 # copies of it under the terms of the GNU
9 # General Public License <https://www.gnu.org/licenses/gpl.html>.
10 # There is NO WARRANTY, to the extent permitted by law.
19 if [ ! -r ~
/.config
/aurup
]; then
20 echo "You should create ~/.config/aurup with inside:"
21 echo "user=YOUR_AUR_USERNAME"
22 echo "pass=YOUR_AUR_PASS"
23 echo "to avoid manual input of these data."
25 echo -n "Your AUR username: "
28 echo -n "Your AUR password: "
32 source ~
/.config
/aurup
36 if [ "$use_color" = "Y" -o "$use_color" = "y" ]; then
37 echo -e "\033[1;32m${1}\033[1;0m" >&2
44 if [ "$use_color" = "Y" -o "$use_color" = "y" ]; then
45 echo -e "\033[1;31mERROR: ${1}\033[1;0m" >&2
52 echo "aurup - version $ver"
54 echo "usage: $0 pkgfile.tar.gz category"
56 echo "pkgfile.tar.gz == tar.gz with PKGBUILD inside to send"
57 echo " (autarchy or makepkg --source can be used)"
58 echo "category == category of the package"
60 echo "$0 -h shows this help"
61 echo "$0 -l list available category"
62 echo "$0 -c check for out-of-date packages"
91 curl
-c $tmpdir/.aurup.cookies
-d "user=${user}&passwd=${pass}" https
://aur.archlinux.org
/index.php
&>/dev
/null
92 login
=`curl -s -b $tmpdir/.aurup.cookies -d "user=${user}&passwd=${pass}" https://aur.archlinux.org/index.php | grep -c "Bad username or password"`
93 [ $login = "1" ] && echo "Bad username or password" && exit
98 # do_Notify / do_UnNotify
100 # do_Adopt / do_Disown
101 # do_Vote / do_UnVote
107 if [[ $action == "do_MyPackages" ]]; then
108 curl
-b $tmpdir/.aurup.cookies
"https://aur.archlinux.org/packages.php?SeB=m&K=${user}&PP=100" 2>/dev
/null
110 curl
-b $tmpdir/.aurup.cookies
-d "IDs[${pkgid}]=1&ID=${pkgid}&${action}=1" https
://aur.archlinux.org
/packages.php
2>/dev
/null
112 } # end of aur_action()
117 #curl -F K=${pkgname} -F PP=100 https://aur.archlinux.org/packages.php 2>/dev/null > $tmpdir/.aurup1.tmp
118 curl https
://aur.archlinux.org
/packages.php?K
=${pkgname} 2>/dev
/null
> $tmpdir/.aurup1.tmp
119 for id
in `cat $tmpdir/.aurup1.tmp | grep href | grep packages\.php | grep ID | cut -d\' -f 6 | cut -d\= -f2`; do
120 url
="https://aur.archlinux.org/packages.php?do_Details=1&ID=${id}"
121 links
-dump $url > $tmpdir/.aurup2.tmp
122 name
=`cat $tmpdir/.aurup2.tmp | awk '/Package Details/,/Maintainer: /' | head -3 | tail -1 | awk '{ print $1 }'`
123 if [[ $name == ${pkgname} ]]; then
133 aur_action do_MyPackages
>$tmpdir/.aurup4.tmp
135 for idood
in `grep "outofdate" $tmpdir/.aurup4.tmp | egrep -o "\[[0-9]{1,}\]" | egrep -o "[0-9]{1,}"`; do
136 name
=`grep ID=${idood} $tmpdir/.aurup4.tmp | html2text | cut -d\ -f1`
137 echo -e "$name \t\t\t it's flagged out-of-date"
141 if [[ "$out" == "" ]]; then
142 echo "No package is flagged out-of-date"
150 #curl -F K=${pkgname} -F PP=100 https://aur.archlinux.org/packages.php 2>/dev/null > $tmpdir/.aurup1.tmp
151 curl https
://aur.archlinux.org
/packages.php?K
=${pkgname} 2>/dev
/null
> $tmpdir/.aurup1.tmp
152 for id
in `cat $tmpdir/.aurup1.tmp | grep href | grep packages\.php | grep ID | cut -d\' -f 6 | cut -d\= -f2`; do
153 url
="https://aur.archlinux.org/packages.php?do_Details=1&ID=${id}"
154 links
-dump $url > $tmpdir/.aurup2.tmp
155 name
=`cat $tmpdir/.aurup2.tmp | awk '/Package Details/,/Maintainer: /' | head -3 \
156 | tail -1 | awk '{ print $1 }'`
157 if [[ $name == ${pkgname} ]]; then
158 # category=`cat $tmpdir/.aurup2.tmp | awk '/Package Details/,/Maintainer: /' \
159 # | tail -2 | head -1 | awk '{ print $3 }'`
160 category
=`cat $tmpdir/.aurup2.tmp | awk '/Package Details/,/Maintainer: /' | tail -2 | head -1 | awk '{ print $3 }'`
165 rm -f $tmpdir/.aurup
{1,2}.tmp
166 } #end of aur_cat_finder()
170 curl
-H "Expect:" -b $tmpdir/.aurup.cookies
-F pkgsubmit
=1 -F MAX_FILE_SIZE
=2097152 -F category
="${num_category}" -F pfile
="@${pkgfile}" https
://aur.archlinux.org
/pkgsubmit.php
2>/dev
/null
> $tmpdir/.aurup3.tmp
171 rm -f $tmpdir/.aurup.cookies
175 if [[ `grep error $tmpdir/.aurup3.tmp` ]]; then
176 message
="`grep error $tmpdir/.aurup3.tmp | html2text`"
179 message
="`grep \/center $tmpdir/.aurup3.tmp |html2text`"
180 pkgid
=`id_finder ${pkgname}`
181 if [[ $auto_unflag == "Y" ||
$auto_unflag == "y" ]]; then
182 aur_action do_UnFlag
$pkgid &>/dev
/null
183 message
="$message (unflagged out of date)"
185 if [[ $auto_vote == "Y" ||
$auto_vote == "y" ]]; then
186 aur_action do_Vote
$pkgid &>/dev
/null
187 message
="$message (voted)"
189 if [[ $auto_notify == "Y" ||
$auto_notify == "y" ]]; then
190 aur_action do_Notify
$pkgid &>/dev
/null
191 message
="$message (added to notify list)"
196 #rm -f $tmpdir/.aurup3.tmp
197 } # end of print_message()
199 if [[ $1 == "-h" ||
$1 == "--help" ]]; then usage
; exit 0; fi
200 if [[ $1 == "-l" ||
$1 == "--list" ]]; then list_cat
; exit 0; fi
201 if [[ $1 == "-c" ||
$1 == "--check-out-of-date" ]]; then check_ood
; fi
202 if [[ $# != 2 ]]; then error
"wrong number of parameters" 1>&2 ; usage
; exit -1; fi
203 if [[ ! -f $1 ]]; then error
"$1 does not exist" 1>&2; exit -4; fi
207 pkgname
=`basename $1 .tar.gz`
208 pkgname
=`echo $pkgname | sed -re 's|^(.*)-[^-]+-[^-]+\.src\$|\1|'`
211 #pkgname_len=`echo $pkgname | wc -c`
212 #if [[ $pkgname_len -gt 32 ]]; then error "pkgname is longer than 32 characters, and this is not allowed in AUR"; exit -6; fi
216 for categ
in daemons devel editors emulators games gnome i18n kde \
217 lib modules multimedia network office science system x11 xfce kernels
; do
218 if [[ $category == $categ ]]; then num_category
=$i; fi
222 if [[ $num_category == 0 ]]; then
223 error
"insert a valid category name" 1>&2