etc/mirrors.d/50-eprint-bib: Collect IACR ePrint bibliography.
[mirror-admin] / etc / mirrors.d / 50-eprint-bib
1 #! /bin/bash
2
3 set -e
4
5 ## Initial setup.
6 mkdir -p $MIRRORS/eprint-bib; cd $MIRRORS/eprint-bib
7 eprint=http://eprint.iacr.org
8 rm -f list tags
9
10 ## Fetch the master index.
11 curl -sS -o list -z '1 hour ago' $eprint/complete/
12 [ -r list ] || exit 0
13
14 ## Pick out the article tags.
15 sed -n '/^<a href="\/\([0-9]\+\/[0-9]\+\)">.*$/ s::\1:p' list >tags
16
17 ## For each tag, make sure we have the article information.
18 while read tag; do
19 dir=${tag%/*}
20 mkdir -p $dir
21 file=$dir/eprint-${tag/\//-}.bib
22 [ -r $file ] || {
23 curl -sS -o $file.in "$eprint/cgi-bin/cite.pl?entry=$tag"
24 sed -n "
25 /^<PRE>/,/<\/PRE>/ {
26 /^<PRE>/ d
27 s:</PRE>.*::
28 s%note =.*\$%url = {http://eprint.iacr.org/$tag},%
29 p
30 }" $file.in >$file.sed
31 mv $file.sed $file
32 rm -f $file.in
33 echo $tag
34 }
35 done <tags
36
37 ## Build the main bibliography.
38 {
39 cat header
40 find . -name 'eprint-*.bib' -print | sort | xargs cat
41 } >eprint.bib.new
42 mv eprint.bib.new eprint.bib