Versioned TeX Live distfiles

Status

Last update: Sun Apr 20 22:42:01 CEST 2014

17455 versioned tarballs (6748 MB) of 9551 upstream tarballs (2444 MB).

Meta

#!/bin/sh
set -e

mirror_dir="/var/mirror/distrib-coffee.ipsl.jussieu.fr"
www_dir="/var/www/texlive-distfiles.blogreen.org"

mkdir -p "${mirror_dir}" "${www_dir}"

/usr/local/bin/rsync -aqP --no-motd --delete "rsync://distrib-coffee.ipsl.jussieu.fr/pub/mirrors/ctan/systems/texlive/tlnet/archive/" "${mirror_dir}"

find "${mirror_dir}" -type f -mtime -2d -name '*.tar.xz' | while read file; do
	version=`stat -f '%Sm' -t '%Y%m%d' "${file}"`
	cp -p "${file}" "$(echo "${file}" | sed -Ee "s|${mirror_dir}|${www_dir}|" -e "s|^(.*)(\\.tar\\.xz)$|\1-${version}\2|")"
done

upstream_count=`find "${mirror_dir}" -name '*.tar.xz' | wc -l`
local_count=`find "${www_dir}" -name '*.tar.xz' | wc -l`

if [ ! -f "${www_dir}/database.rrd" ]; then
	/usr/local/bin/rrdtool create -s 3600 "${www_dir}/database.rrd" \
		"DS:upstream:GAUGE:7200:0:1000000" \
		"DS:local:GAUGE:7200:0:1000000" \
		"RRA:AVERAGE:0.5:1:8760"
fi
/usr/local/bin/rrdtool update "${www_dir}/database.rrd" \
	"N:${upstream_count}:${local_count}"
/usr/local/bin/rrdtool graph "${www_dir}/graph.png" --imgformat PNG        \
	--disable-rrdtool-tag --end now --start end-90d                    \
	"DEF:upstream_count=${www_dir}/database.rrd:upstream:AVERAGE"      \
	"DEF:local_count=${www_dir}/database.rrd:local:AVERAGE"            \
	"LINE2:upstream_count#0088ff:Unversioned (upstream) tarball count" \
	"LINE2:local_count#ff8800:Versioned tarball count" > /dev/null

cat > "${www_dir}/index.html" << EOT
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>TeX Live versioned distfiles for FreeBSD-TeXLive</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> 
  </head>
  <body>
    <h1>Versioned TeX Live distfiles</h1>
    <h2>Status</h2>
    <p>Last update: `date`</p>
    <p>${local_count} versioned tarballs (`du -m "${www_dir}" | cut -f 1` MB)
       of ${upstream_count} upstream tarballs (`du -m "${mirror_dir}" | cut -f 1` MB).</p>
    <p><img src="graph.png" alt="" /></p>
    <h2>Meta</h2>
    <pre>`cat $0 | sed -e 's|&|\&amp;|g' -e 's|<|\&lt;|g' -e 's|>|\&gt;|g' `</pre>
    <hr />
    <p>Server sponsored by <a href="http://www.nfrance.com">NFrance</a>. Thanks!</p>
  </body>
</html>
EOT

Server sponsored by NFrance. Thanks!