blob: a27a16873fcb73e78dd305e90f006f81172daae8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#!/bin/bash
# alfplayer
# 2014-06-12
#
# Prints Parabola PCR packages with the corresponding AUR
# packages, only if the version of the Parabola package is older
# than the Arch package version.
set -e
name="aur-vs-pcr"
baseconfpath="/etc/libredbdiff"
basedbpath="/var/lib/libredbdiff"
conffile="$baseconfpath/pacman.conf.parabola"
conffilearch="$baseconfpath/pacman.conf.archlinux"
dbpath="$basedbpath/pacman.parabola"
dbpatharch="$basedbpath/pacman.archlinux"
field_pkgname=40
field_version=40
field_time=10
error() { echo -e "Error. $@" > /dev/stderr ; exit 1; }
verbose=1
while true ; do
if [[ $1 =~ ^(-v|--verbose)$ ]] ; then
verbose=0
shift
elif [[ $# == 1 && $1 =~ ^(-h|--help)$ ]] ; then
echo -e "${name}. Show PCR repository packages that need to be updated from AUR.
Usage:
${name} [pattern]\t\tRegular output.
${name} -v [pattern]\t\tAlso print package names of unmatched and updated packages.
Specify [pattern] to filter package names. It can be empty to show all PCR packages.
Examples:
${name} pkgtool\t\tSearches for package names including the substring \"pkgtool\".
${name} ^emacs.*\t\tSearches for package names starting with \"emacs\".
${name} -v emacs.*\t\tSame as previous but it also prints unmatched and updated packages."
exit 0
else
pattern="$1"
if [[ $2 ]] ; then
error "Bad arguments. Nothing done. Run \"aur-vs-pcr -h\" for usage information."
else
break
fi
fi
done
if ! which jshon > /dev/null ; then
echo "jshon is not installed (package \"jshon\")"
fi
# Save PCR package information to a file
expac -S '%r/%n %v %b %p' -t '%F' | grep "^pcr" | cut -b 5- | \
awk -v pattern="$pattern" "\$1 ~ pattern" > /tmp/aur-vs-pcr.tmp
pkgname_list="$(head -c -1 /tmp/aur-vs-pcr.tmp | awk '{print $1}' | sed ':a;N;$!ba;s/\n/ /g')"
declare -Ax ver_arch time_arch maintainer_arch ood_arch provides_string_arch desc_arch
pkg_count="$(wc -w <<< "${pkgname_list}")"
set +m
shopt -s lastpipe
# Query using the HTTP AUR RPC about 400 packages at a time. The request is denied using 500.
for (( j=0 ; j<pkg_count ; j=j+400 )); do
arg="$(cut -f $((j+1))-$((j+400)) -d ' ' <<< ${pkgname_list})"
arg_url="$(sed -e '1s/^/\&arg[]=/' -e 's/ /\&arg[]=/g' <<< "${arg}")"
i=1
curl -Lkgs "https://aur.archlinux.org/rpc.php?type=multiinfo${arg_url}" |
jshon -e results -a -e Name -u -p -e Version -u -p \
-e LastModified -u -p -e OutOfDate -u -p \
-e Maintainer -u -p -e Description -u |
while read -r var ; do
if [[ $i == 1 ]] ; then
pkgname="$var"
elif [[ $i == 2 ]] ; then
ver_arch["$pkgname"]="$var"
elif [[ $i == 3 ]] ; then
time_arch["$pkgname"]="$(date -d @${var} +'%Y-%m-%d')"
elif [[ $i == 4 ]] ; then
ood_arch["$pkgname"]="$var"
elif [[ $i == 5 ]] ; then
maintainer_arch["$pkgname"]="$var"
elif [[ $i == 6 ]] ; then
desc_arch["$pkgname"]="$var"
i=0
fi
((++i))
done
done
if [[ $verbose == 0 ]] ; then
printf_format="%s %-${field_pkgname}s%${field_version}s %${field_time}s %s\n"
printf_format_arch=" %-${field_pkgname}s%${field_version}s %${field_time}s %s\n"
else
printf_format="%-$((field_pkgname+2))s%${field_version}s %${field_time}s %s\n"
printf_format_arch="%-$((field_pkgname+2))s%${field_version}s %${field_time}s %s\n"
fi
# Loop over PCR packages and print comparative information if the PCR version is older than AUR's version.
while IFS= read -r line
do
set -- ${line}
pkgname="$1"
ver="$2"
time="$3"
maintainer="${*:4}"
if [[ ${ver_arch["${pkgname}"]} ]] ; then
if [[ ${ver} < ${ver_arch["${pkgname}"]} ]] ; then
if [[ $verbose == 0 ]] ; then
# Print Parabola package data line
printf "${printf_format}" \
"<" \
"${pkgname}" \
"${ver}" \
"${time}" \
"${maintainer}"
else
# Print Parabola package data line
printf "${printf_format}" \
"${pkgname}" \
"${ver}" \
"${time}" \
"${maintainer}"
fi
# Print AUR package data line
printf "${printf_format_arch}" \
"" \
"${ver_arch["${pkgname}"]}" \
"${time_arch["${pkgname}"]}" \
"${maintainer_arch["${pkgname}"]}"
elif [[ ${ver} == ${ver_arch["${pkgname}"]} ]] ; then
if [[ $verbose == 0 ]] ; then
echo "= ${pkgname}"
fi
else
if [[ $verbose == 0 ]] ; then
echo "> ${pkgname}"
fi
fi
else
if [[ $verbose == 0 ]] ; then
echo "o ${pkgname}"
fi
fi
done < /tmp/aur-vs-pcr.tmp
|