From a3e79347be1cb4bf4171e0e2d43a6248ce1d920a Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:15:53 +0100 Subject: [PATCH 1/6] my poor attempt at perl --- mirror-nixos-branch.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index e480aa6..4601947 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -227,3 +227,21 @@ system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die; # Update channel on channels.nixos.org $bucketChannels->add_key($channelsDir, $target, { "x-amz-website-redirect-location" => $target }); $bucketChannels->add_key("$channelsDir/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }); + +# for nixos channels also create redirects for latest images +if ($channelName =~ /nixos/) { + for my $artifact ("nixos-graphical", + "nixos-plasma5", + "nixos-gnome", + "nixos-minimal", + "nixos-plasma5-x86_64-linux.ova" + "nixos-gnome-x86_64-linux.ova" + ) { + for my $arch ("x86_64", "i686") { + for my $format ("ova", "iso") { + $bucketChannels->add_key("$channelsDir/latest-$artifact-$arch-linux.$format", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format" }); + $bucketChannels->add_key("$channelsDir/latest-$artifact-$arch-linux.$format.sha256", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format.sha256" }); + } + } + } +} From 1729eb92c8d8d2534059a2052216ff32fbbd9f61 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:48:11 +0100 Subject: [PATCH 2/6] remove not needed lines --- mirror-nixos-branch.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 4601947..80770d8 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -234,8 +234,6 @@ if ($channelName =~ /nixos/) { "nixos-plasma5", "nixos-gnome", "nixos-minimal", - "nixos-plasma5-x86_64-linux.ova" - "nixos-gnome-x86_64-linux.ova" ) { for my $arch ("x86_64", "i686") { for my $format ("ova", "iso") { From a8671842d9a01d847ff5c21d66dfcd6e33f02b22 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:49:52 +0100 Subject: [PATCH 3/6] channelsDir -> channelName --- mirror-nixos-branch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 80770d8..1ae73b3 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -237,8 +237,8 @@ if ($channelName =~ /nixos/) { ) { for my $arch ("x86_64", "i686") { for my $format ("ova", "iso") { - $bucketChannels->add_key("$channelsDir/latest-$artifact-$arch-linux.$format", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format" }); - $bucketChannels->add_key("$channelsDir/latest-$artifact-$arch-linux.$format.sha256", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format.sha256" }); + $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format" }); + $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format.sha256", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format.sha256" }); } } } From 0893b43140efc79edd40b079498e533d704eab62 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:51:19 +0100 Subject: [PATCH 4/6] channelsDir -> channelName --- mirror-nixos-branch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 1ae73b3..74b4df1 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -225,8 +225,8 @@ system("git push origin $rev:refs/heads/$channelName >&2") == 0 or die; system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die; # Update channel on channels.nixos.org -$bucketChannels->add_key($channelsDir, $target, { "x-amz-website-redirect-location" => $target }); -$bucketChannels->add_key("$channelsDir/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }); +$bucketChannels->add_key($channelName, $target, { "x-amz-website-redirect-location" => $target }); +$bucketChannels->add_key("$channelName/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }); # for nixos channels also create redirects for latest images if ($channelName =~ /nixos/) { From 15ff4aff86f0ac340552c5452dcde0a155273403 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:52:09 +0100 Subject: [PATCH 5/6] added error handling --- mirror-nixos-branch.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 74b4df1..9fb5e05 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -225,8 +225,8 @@ system("git push origin $rev:refs/heads/$channelName >&2") == 0 or die; system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die; # Update channel on channels.nixos.org -$bucketChannels->add_key($channelName, $target, { "x-amz-website-redirect-location" => $target }); -$bucketChannels->add_key("$channelName/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }); +$bucketChannels->add_key($channelName, $target, { "x-amz-website-redirect-location" => $target }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; +$bucketChannels->add_key("$channelName/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; # for nixos channels also create redirects for latest images if ($channelName =~ /nixos/) { @@ -237,8 +237,8 @@ if ($channelName =~ /nixos/) { ) { for my $arch ("x86_64", "i686") { for my $format ("ova", "iso") { - $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format" }); - $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format.sha256", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format.sha256" }); + $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format" }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; + $bucketChannels->add_key("$channelName/latest-$artifact-$arch-linux.$format.sha256", "", {"x-amz-website-redirect-location" => "$target/$artifact-$releaseThingy-$arch-linux.$format.sha256" }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; } } } From 4d53dba964f33aa6c51305c7f7de0bd0b1b0eec0 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 10 Mar 2020 12:52:59 +0100 Subject: [PATCH 6/6] wrong content --- mirror-nixos-branch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 9fb5e05..d72bec3 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -226,7 +226,7 @@ system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die; # Update channel on channels.nixos.org $bucketChannels->add_key($channelName, $target, { "x-amz-website-redirect-location" => $target }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; -$bucketChannels->add_key("$channelName/nixexprs.tar.xz", $target, { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; +$bucketChannels->add_key("$channelName/nixexprs.tar.xz", "$target/nixexprs.tar.xz", { "x-amz-website-redirect-location" => "$target/nixexprs.tar.xz" }) or die $bucketChannels->err . ": " . $bucketChannels->errstr; # for nixos channels also create redirects for latest images if ($channelName =~ /nixos/) {