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

Bug#808790: marked as done (fakeupstream.cgi: add redirector for crates.io website)



Your message dated Wed, 23 Dec 2015 05:58:11 +0000
with message-id <E1aBcR9-0000fn-Mb@moszumanska.debian.org>
and subject line qa.debian.org bug fixed in revision 3457
has caused the Debian Bug report #808790,
regarding fakeupstream.cgi: add redirector for crates.io website
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
808790: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808790
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: qa.debian.org
Severity: wishlist
Tags: patch

The standard packaging tool for the Rust programming language ("cargo") distributes package sources via the https://crates.io/ website.  Unfortunately for uscan, the dynamic content for this website is all served via JSON.  According to a discussion with upstream[*], the upstream infrastructure isn't able to easily serve HTML-formatted dynamic content at this time.

The attached patch adds a wrapper to fakeupstream.cgi to reformat the relevant "versions" JSON blob as uscan-friendly HTML.  Please apply.

[*] Upstream discussion: https://github.com/rust-lang/crates.io/issues/238

Thanks!
 - Gus
Index: fakeupstream.cgi
===================================================================
--- fakeupstream.cgi	(revision 3453)
+++ fakeupstream.cgi	(working copy)
@@ -46,6 +46,7 @@
 my $project_char_re = '[a-zA-Z0-9\-]';
 my $pypi_project_char_re = '[a-zA-Z0-9\-\.]';
 my $npmjs_project_char_re = '[a-zA-Z0-9\-\.]';
+my $cratesio_project_char_re = '[a-zA-Z0-9_.-]';
 my $hg_repository_re = '[a-zA-Z0-9\.\-:/]+';
 my $href_char_re    = '[a-zA-Z0-9\-\._/]';
 my $href_p_char_re    = '[a-zA-Z0-9\-\._/%]';
@@ -735,6 +736,35 @@
 	} );
 }
 
+# https://packages.qa.debian.org/c/cargo.html
+# https://crates.io/crates/cargo
+# http://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=crates.io/cargo
+if( $upstream_param =~ m%^crates\.io/($cratesio_project_char_re+)% )
+{
+    my $project = $1;
+
+    my $url = "https://crates.io/api/v1/crates/$project/versions";;
+    my $ua = LWP::UserAgent->new;
+    my $response = $ua->get( $url );
+    return_error( "failed to read $url : $response->status_line" ) if( not $response->is_success );
+    my $json = JSON::decode_json( $response->decoded_content );
+    print $q->header;
+    print $q->start_html;
+    print $q->start_ul;
+    foreach my $vers ( @{$json->{"versions"}} )
+    {
+	next if $vers->{"yanked"};
+	my $version = $vers->{"num"};
+	my $dl_uri = URI->new_abs($vers->{"dl_path"}, $url);
+
+	print $q->li( $q->a( { -href => $dl_uri }, $version ) );
+    }
+
+    print $q->end_ul;
+    print $q->end_html;
+    exit 0;
+}
+
 my %upstream_info_per_package =
 (
 	'stopwatch' =>

--- End Message ---
--- Begin Message ---
Version: 3457

This bug was closed by Paul Wise (pabs) in SVN revision 3457.
Note that it might take some time until the qa.debian.org code has
been updated and cronjobs have picked up changed data.

Commit message:

fakeupstream.cgi: add redirector for crates.io website (Closes: #808790)

Patch-by: Angus Lees <gus@debian.org>

--- End Message ---

Reply to: