etc/mirrors.d/50-eprint-bib: Collect IACR ePrint bibliography.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 27 Oct 2012 12:26:43 +0000 (13:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 27 Oct 2012 12:26:43 +0000 (13:26 +0100)
It's worth considering collecting the entire archive.

etc/mirrors.d/50-eprint-bib [new file with mode: 0755]

diff --git a/etc/mirrors.d/50-eprint-bib b/etc/mirrors.d/50-eprint-bib
new file mode 100755 (executable)
index 0000000..8065424
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/bash
+
+set -e
+
+## Initial setup.
+mkdir -p $MIRRORS/eprint-bib; cd $MIRRORS/eprint-bib
+eprint=http://eprint.iacr.org
+rm -f list tags
+
+## Fetch the master index.
+curl -sS -o list -z '1 hour ago' $eprint/complete/
+[ -r list ] || exit 0
+
+## Pick out the article tags.
+sed -n '/^<a href="\/\([0-9]\+\/[0-9]\+\)">.*$/ s::\1:p' list >tags
+
+## For each tag, make sure we have the article information.
+while read tag; do
+  dir=${tag%/*}
+  mkdir -p $dir
+  file=$dir/eprint-${tag/\//-}.bib
+  [ -r $file ] || {
+    curl -sS -o $file.in "$eprint/cgi-bin/cite.pl?entry=$tag"
+    sed -n "
+    /^<PRE>/,/<\/PRE>/ {
+      /^<PRE>/ d
+      s:</PRE>.*::
+      s%note =.*\$%url = {http://eprint.iacr.org/$tag},%
+      p
+    }" $file.in >$file.sed
+    mv $file.sed $file
+    rm -f $file.in
+    echo $tag
+  }
+done <tags
+
+## Build the main bibliography.
+{
+  cat header
+  find . -name 'eprint-*.bib' -print | sort | xargs cat
+} >eprint.bib.new
+mv eprint.bib.new eprint.bib