[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#803790: fakeupstream.cgi: New Google Fonts upstream



Package: qa.debian.org
Severity: wishlist
Tags: patch

Hello,

the attached patch adds support for a new upstream: Google Fonts via GitHub. The `upstream_parameter` format is `google-fonts/$font_licence/$font_name`, for example `google-fonts/ofl/pompiere`.

Before explaining the patch I need to explain why this is needed and the unusual way fonts on Google Fonts are "released". To start with, fonts made available on Google Fonts lack proper release tarballs. Each font is maintained in a subdirectory that is part of a huge git repository hosted on GitHub (previously on Google Code).

These fonts lack also meaningful version numbers. Modifications are, however, almost always recorded in the `FONTLOG.txt` file that is present in most directories. In addition, not all the revisions of a certain font are available in the git history, only the latest one is assured to be available. For all these reasons the most reliable way to identify a font version is the date recorded in `FONTLOG.txt`.

The modified `fakeupstream.cgi` generates a page with a list of available versions for a given font. Unfortunately it is not possible to link these versions to release tarballs because GitHub does not generate tarballs for subdirectories, so the links lead to fictitious URLs.

I tested the generated page with uscan 2.15.9 and it can detects the current and past versions of all the fonts I tested it with.

Regards,

--
Gioele Barabucci <gioele@svario.it>
--- fakeupstream.cgi.orig	2015-11-02 13:55:28.000000000 +0000
+++ fakeupstream.cgi	2015-11-02 19:33:53.928268787 +0000
@@ -23,6 +23,8 @@
 use LWP::UserAgent;
 use JSON;
 use File::Temp qw/ tempdir /;
+use Date::Format;
+use Date::Parse;
 use Dpkg::Version;
 
 my $ca_dir = '/etc/ssl/ca-global';
@@ -735,6 +737,65 @@
 	} );
 }
 
+# http://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=google-fonts/ofl/pompiere
+elsif( $upstream_param =~ m%^google-fonts/($project_char_re+)/($project_char_re+)$% )
+{
+	my $font_licence = $1;
+	my $font_name = $2;
+
+	my $github_repo_url = "https://github.com/google/fonts/tree/master/$font_licence/$font_name";;
+	my $svn_fontlog_url = "https://github.com/google/fonts/trunk/$font_licence/$font_name/FONTLOG.txt";;
+
+	my @command = (
+		'/usr/bin/svn',
+		'cat',
+		$svn_fontlog_url
+	);
+
+	my @versions_eng;
+
+	open(my $svn_cat_fh, '-|', @command)
+		or return_error("Can't run svn cat: $!");
+	while (<$svn_cat_fh>) {
+		chomp;
+
+		# 15 July 2011 (Author) version notes
+		next unless /^([0-9]{1,2}) ([A-Za-z]+) ([0-9]{4}) /;
+
+		push @versions_eng, "$1 $2 $3"
+	}
+	close($svn_cat_fh);
+
+	return_error("no versions found for font $font_licence/$font_name")
+		if (scalar(@versions_eng) == 0);
+
+	my @versions;
+	for my $version_eng (@versions_eng) {
+		my $date = str2time($version_eng);
+		my $version = time2str("%Y%m%d", $date);
+
+		push @versions, $version;
+	}
+
+	my $result = "\n";
+	for my $version (@versions) {
+		my $release = "$font_name-$version";
+
+		$result .= $q->li( $q->a( { -href => $q->self_url . "&download=$release.zip" }, $release ) ) . "\n";
+	}
+
+	print $q->header;
+	print $q->start_html;
+	print $q->h1( "Known versions of " . $q->em( $font_name ));
+	print $q->p( "Font available at " . $q->a( { -href => "$github_repo_url" }, $github_repo_url ) );
+	print $q->start_ul;
+	print $result;
+	print $q->end_ul;
+	print $q->end_html;
+
+	exit 0;
+}
+
 my %upstream_info_per_package =
 (
 	'stopwatch' =>

Reply to: