etc/mirrors.d/50-eprint-bib: Collect IACR ePrint bibliography.
[mirror-admin] / etc / mirrors.d / 50-eprint-bib
CommitLineData
1d7a7472
MW
1#! /bin/bash
2
3set -e
4
5## Initial setup.
6mkdir -p $MIRRORS/eprint-bib; cd $MIRRORS/eprint-bib
7eprint=http://eprint.iacr.org
8rm -f list tags
9
10## Fetch the master index.
11curl -sS -o list -z '1 hour ago' $eprint/complete/
12[ -r list ] || exit 0
13
14## Pick out the article tags.
15sed -n '/^<a href="\/\([0-9]\+\/[0-9]\+\)">.*$/ s::\1:p' list >tags
16
17## For each tag, make sure we have the article information.
18while 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 }
35done <tags
36
37## Build the main bibliography.
38{
39 cat header
40 find . -name 'eprint-*.bib' -print | sort | xargs cat
41} >eprint.bib.new
42mv eprint.bib.new eprint.bib