diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl
index 2363716..d5d4690 100755
--- a/mirror-nixos-branch.pl
+++ b/mirror-nixos-branch.pl
@@ -3,14 +3,17 @@
use strict;
use warnings;
use Data::Dumper;
+use Digest::SHA;
use Fcntl qw(:flock);
use File::Basename;
use File::Path;
use File::Slurp;
+use File::stat;
use JSON::PP;
use LWP::UserAgent;
use List::MoreUtils qw(uniq);
use Net::Amazon::S3;
+use POSIX qw(strftime);
my $channelName = $ARGV[0];
my $releaseUrl = $ARGV[1];
@@ -153,9 +156,22 @@ if ($bucket->head_key("$releasePrefix/github-link")) {
system("xz", "$tmpDir/store-paths") == 0 or die;
}
+ my $now = strftime("%F %T", localtime);
+ my $title = "$channelName release $releaseName";
+ my $githubLink = "https://github.com/NixOS/nixpkgs-channels/commits/$rev";
+
+ my $html = "
";
+ $html .= "$title";
+ $html .= "$title
";
+ $html .= "Released on $now from Git commit $rev ";
+ $html .= "via Hydra evaluation $evalId.
";
+ $html .= "File name | Size | SHA-512 hash |
";
+
# Upload the release to S3.
- for my $fn (glob("$tmpDir/*")) {
- my $key = "$releasePrefix/" . basename $fn;
+ for my $fn (sort glob("$tmpDir/*")) {
+ my $basename = basename $fn;
+ my $key = "$releasePrefix/" . $basename;
+
unless (defined $bucket->head_key($key)) {
print STDERR "mirroring $fn to s3://$bucketName/$key...\n";
$bucket->add_key_filename(
@@ -163,23 +179,22 @@ if ($bucket->head_key("$releasePrefix/github-link")) {
{ content_type => $fn =~ /.sha256|src-url|binary-cache-url|git-revision/ ? "text/plain" : "application/octet-stream" })
or die $bucket->err . ": " . $bucket->errstr;
}
+
+ next if $basename =~ /.sha256$/;
+
+ my $size = stat($fn)->size;
+ my $sha256 = Digest::SHA::sha256_hex(read_file($fn));
+ $html .= "";
+ $html .= "$basename | ";
+ $html .= "$size | ";
+ $html .= "$sha256 | ";
+ $html .= "
";
}
- # Add dummy files at $releasePrefix to prevent nix-channel from barfing.
- for my $key ($releasePrefix, "$releasePrefix/") {
- $bucket->add_key("$key", "nix-channel compatibility placeholder",
- { content_type => "text/plain" })
- or die $bucket->err . ": " . $bucket->errstr;
- }
+ $html .= "
";
- # Make "github-link" a redirect to the GitHub history of this
- # release.
- my $link = "https://github.com/NixOS/nixpkgs-channels/commits/$rev";
- $bucket->add_key(
- "$releasePrefix/github-link", $link,
- { 'x-amz-website-redirect-location' => $link,
- content_type => "text/plain"
- })
+ $bucket->add_key($releasePrefix, $html,
+ { content_type => "text/html" })
or die $bucket->err . ": " . $bucket->errstr;
File::Path::remove_tree($tmpDir);