summaryrefslogtreecommitdiffstats
path: root/bin/metas/perl.d/cpandists
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-09-20 20:10:49 +0200
committerJustin Davis <jrcd83@gmail.com>2011-09-20 20:15:28 +0200
commit9d37bd99729f8b95a237f994d0c4566e566135a8 (patch)
treeaaee9c90dad4d9112bca6883fc5577503fe93962 /bin/metas/perl.d/cpandists
parentfed43dfa750961f3380594b5919a0d6b779b847a (diff)
downloadgenpkg-9d37bd99729f8b95a237f994d0c4566e566135a8.tar.gz
genpkg-9d37bd99729f8b95a237f994d0c4566e566135a8.tar.xz
Begin restructuring. Creates Makefile, etc.
bin/macros were moved to bin/metas. perl-cpan renamed to simply perl. Supporting scripts for perl-cpan moved to bin/metas/perl.d. No longer use the webpage to look up dists, we maintaing our own simple list of CPAN distributions. Unlike before, scripts in metas/ generate the data file and not the file parsed by pbjparse.awk.
Diffstat (limited to 'bin/metas/perl.d/cpandists')
-rwxr-xr-xbin/metas/perl.d/cpandists50
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/metas/perl.d/cpandists b/bin/metas/perl.d/cpandists
new file mode 100755
index 0000000..45dbef2
--- /dev/null
+++ b/bin/metas/perl.d/cpandists
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+mirror=ftp://cpan.pair.com
+path=/modules/02packages.details.txt.gz
+
+curl --silent $mirror$path | gzip -dc | awk '
+NR < 10 { next }
+{
+ file = a[split($3, a, "/")]
+ len = split(file, a, ".")
+
+ if (!match(a[1], /[-_][vV]?[0-9]+$/)) {
+ print "error: failed to grok " $3 | "cat 1>&2"
+ next
+ }
+ ver = substr(file, RSTART+1, RLENGTH-1)
+ dist = substr(file, 1, RSTART-1)
+ for (i=2; i<=len; i++) {
+ if (a[i] !~ /^[0-9]/) break
+ ver = ver "." a[i]
+ }
+ sub(/^[vV]/, "", ver)
+
+ if (lessthan(dists[dist], ver)) {
+ dists[dist] = ver
+ paths[dist] = $3
+ }
+}
+
+END {
+ for (dist in dists) print dist, dists[dist], paths[dist] | "sort"
+}
+
+function lessthan (l, r)
+{
+ return decver(l) < decver(r)
+}
+
+function decver (vs)
+{
+ pcnt = gsub(/[.]/, ".", vs)
+ if (pcnt < 2) return vs
+
+ len = split(vs, vc, ".")
+ dec = vc[1]
+ for (i=2; i<=len; i++) dec += (10 ^ (-i * 3)) * vc[i]
+ return dec
+}
+
+'