summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2016-05-17 15:53:10 +0000
committerintrigeri <intrigeri@boum.org>2016-05-17 17:09:39 +0000
commita4b809d933db8bf7698e44cbb6f67ffb0515a36c (patch)
tree0b40bde04849e80a40ddff6ad3368415a5f87c73
parent75b8a30ddc63612d4e2a1a66168fed1d9dc21568 (diff)
Implement scenarios + corresponding code for the APT mirror selection: stable branch, and branches based on stable.
-rwxr-xr-xauto/scripts/apt-mirror49
-rw-r--r--features/build.feature82
-rw-r--r--features/step_definitions/build.rb31
-rw-r--r--features/support/env.rb36
4 files changed, 194 insertions, 4 deletions
diff --git a/auto/scripts/apt-mirror b/auto/scripts/apt-mirror
index 1484760..4eab9f8 100755
--- a/auto/scripts/apt-mirror
+++ b/auto/scripts/apt-mirror
@@ -1,11 +1,54 @@
-#!/bin/sh
+#!/bin/bash
set -e
set -u
+. "$(dirname $0)/utils.sh"
+
ARCHIVE="$1"
+output_tagged_snapshot() {
+ local archive="$1"
+ local tag="$2"
+ echo "http://tagged.snapshots.deb.tails.boum.org/$tag/$archive"
+}
+
+output_time_based_snapshot() {
+ local archive="$1"
+ local serial="$2"
+ echo "http://time-based.snapshots.deb.tails.boum.org/$archive/$serial"
+}
+
+### Sanity checks
+
[ -n "$ARCHIVE" ] || exit 1
-echo -n "http://time-based.snapshots.deb.tails.boum.org/$ARCHIVE/"
-cat "tmp/APT_snapshots.d/$ARCHIVE/serial"
+### Main
+
+SERIAL=$(cat "config/APT_snapshots.d/$ARCHIVE/serial")
+RESOLVED_SERIAL=$(cat "tmp/APT_snapshots.d/$ARCHIVE/serial")
+
+if [ "$(base_branch)" = stable ]; then
+ if version_was_released "$(version_in_changelog)"; then
+ [ "$(current_branch)" = stable ] \
+ || fatal "Not building from stable, but last version in changelog" \
+ "was released"
+ output_tagged_snapshot "$ARCHIVE" "$(version_in_changelog)"
+ else
+ version_was_released "$(previous_version_in_changelog)" \
+ || fatal "None of the two last version in changelog were released"
+ case "$ARCHIVE" in
+ debian-security)
+ output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
+ ;;
+ *)
+ if [ "$SERIAL" = latest ]; then
+ output_tagged_snapshot "$ARCHIVE" "$(previous_version_in_changelog)"
+ else
+ output_time_based_snapshot "$ARCHIVE" "$SERIAL"
+ fi
+ esac
+ fi
+else
+ output_time_based_snapshot "$ARCHIVE" "$RESOLVED_SERIAL"
+fi
diff --git a/features/build.feature b/features/build.feature
index 583a214..6206365 100644
--- a/features/build.feature
+++ b/features/build.feature
@@ -24,6 +24,34 @@ Feature: custom APT sources to build branches
And I should see the 'bugfix-bar' suite
But I should not see the '1.0' suite
+ Scenario: build from an untagged stable branch with no encoded time-based snapshot
+ Given I am working on the stable base branch
+ And Tails 0.10 has been released
+ And the last versions mentioned in debian/changelog are 0.10 and 1.0
+ And Tails 1.0 has not been released yet
+ And no frozen APT snapshot is encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see a time-based snapshot
+
+ Scenario: build from an untagged stable branch with encoded time-based snapshots
+ Given I am working on the stable base branch
+ And Tails 0.10 has been released
+ And the last versions mentioned in debian/changelog are 0.10 and 1.0
+ And Tails 1.0 has not been released yet
+ And frozen APT snapshots are encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see a time-based snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see a time-based snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see a time-based snapshot
+
Scenario: build from a tagged stable branch where the config/APT_overlays.d directory is empty
Given Tails 0.10 has been released
And the last version mentioned in debian/changelog is 0.10
@@ -40,6 +68,32 @@ Feature: custom APT sources to build branches
When I run tails-custom-apt-sources
Then it should fail
+ Scenario: build from a tagged stable branch with no encoded time-based snapshot
+ Given I am working on the stable base branch
+ And Tails 0.10 has been released
+ And the last version mentioned in debian/changelog is 0.10
+ And no frozen APT snapshot is encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see the 0.10 tagged snapshot
+
+ Scenario: build from a tagged stable branch with encoded time-based snapshots
+ Given I am working on the stable base branch
+ And Tails 0.10 has been released
+ And the last version mentioned in debian/changelog is 0.10
+ And frozen APT snapshots are encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see the 0.10 tagged snapshot
+
Scenario: build from a bugfix branch without overlays for a stable release
Given Tails 0.10 has been released
And the last version mentioned in debian/changelog is 0.10.1
@@ -62,6 +116,34 @@ Feature: custom APT sources to build branches
And I should see the 'bugfix-bar' suite
But I should not see the '0.10' suite
+ Scenario: build from a bugfix branch with no encoded time-based snapshot for a stable release
+ Given Tails 0.10 has been released
+ And the last version mentioned in debian/changelog is 0.10.1
+ And Tails 0.10.1 has not been released yet
+ And I am working on the bugfix/disable_gdomap branch based on stable
+ And no frozen APT snapshot is encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see the 0.10 tagged snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see a time-based snapshot
+
+ Scenario: build from a bugfix branch with encoded time-based snapshots for a stable release
+ Given Tails 0.10 has been released
+ And the last version mentioned in debian/changelog is 0.10.1
+ And Tails 0.10.1 has not been released yet
+ And I am working on the bugfix/disable_gdomap branch based on stable
+ And frozen APT snapshots are encoded in config/APT_snapshots.d
+ When I successfully run "apt-snapshots-serials prepare-build"
+ And I successfully run "apt-mirror debian"
+ Then I should see a time-based snapshot
+ When I successfully run "apt-mirror torproject"
+ Then I should see a time-based snapshot
+ When I successfully run "apt-mirror debian-security"
+ Then I should see a time-based snapshot
+
Scenario: build from an untagged testing branch where the config/APT_overlays.d directory is empty
Given I am working on the testing base branch
And the last version mentioned in debian/changelog is 0.11
diff --git a/features/step_definitions/build.rb b/features/step_definitions/build.rb
index fd001ff..4b88324 100644
--- a/features/step_definitions/build.rb
+++ b/features/step_definitions/build.rb
@@ -42,6 +42,27 @@ Given /^the last version mentioned in debian\/changelog is ([[:alnum:]~.]+)$/ do
end
end
+Given /^the last versions mentioned in debian\/changelog are ([[:alnum:]~.]+) and ([[:alnum:]~.]+)$/ do |version_a, version_b|
+ step "the last version mentioned in debian/changelog is #{version_a}"
+ step "the last version mentioned in debian/changelog is #{version_b}"
+end
+
+Given(/^no frozen APT snapshot is encoded in config\/APT_snapshots\.d$/) do
+ ['debian', 'debian-security', 'torproject'].map do |origin|
+ File.open("config/APT_snapshots.d/#{origin}/serial", 'w+') do |serial|
+ serial.write("latest\n")
+ end
+ end
+end
+
+Given(/^frozen APT snapshots are encoded in config\/APT_snapshots\.d$/) do
+ ['debian', 'debian-security', 'torproject'].map do |origin|
+ File.open("config/APT_snapshots.d/#{origin}/serial", 'w+') do |serial|
+ serial.write("2016060602\n")
+ end
+ end
+end
+
Given %r{I am working on the ([[:alnum:]./_-]+) base branch$} do |branch|
create_git unless git_exists?
@@ -66,7 +87,7 @@ Given %r{I am working on the ([[:alnum:]./_-]+) branch based on ([[:alnum:]./_-]
end
end
-When /^I successfully run ([[:alnum:]-]+)$/ do |command|
+When /^I successfully run "?([[:alnum:] -]+)"?$/ do |command|
@output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}`
raise StandardError.new("#{command} failed. Exit code: #{$?}") if $? != 0
end
@@ -113,3 +134,11 @@ end
Given(/^the config\/base_branch file is empty$/) do
File.truncate('config/base_branch', 0)
end
+
+Then(/^I should see the ([[:alnum:].-]+) tagged snapshot$/) do |tag|
+ @output.should have_tagged_snapshot(tag)
+end
+
+Then(/^I should see a time\-based snapshot$/) do
+ @output.should have_time_based_snapshot()
+end
diff --git a/features/support/env.rb b/features/support/env.rb
index f70f6b4..e3f039b 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -23,6 +23,10 @@ def create_git
Dir.mkdir 'config'
FileUtils.touch('config/base_branch')
Dir.mkdir('config/APT_overlays.d')
+ Dir.mkdir('config/APT_snapshots.d')
+ ['debian', 'debian-security', 'torproject'].map do |origin|
+ Dir.mkdir("config/APT_snapshots.d/#{origin}")
+ end
Dir.mkdir 'debian'
File.open('debian/changelog', 'w') do |changelog|
changelog.write(<<END_OF_CHANGELOG)
@@ -88,3 +92,35 @@ RSpec::Matchers.define :have_suite do |suite|
"expected an output with #{suite}"
end
end
+
+RSpec::Matchers.define :have_tagged_snapshot do |tag|
+ match do |string|
+ # e.g.: `http://tagged.snapshots.deb.tails.boum.org/0.10`
+ %r{^http://tagged\.snapshots\.deb\.tails\.boum\.org/#{Regexp.escape(tag)}/[a-z-]+$}.match(string)
+ end
+ failure_message_for_should do |string|
+ "expected the mirror to be #{tag}\nCurrent mirror: #{string}"
+ end
+ failure_message_for_should_not do |string|
+ "expected the mirror not to be #{tag}\nCurrent mirror: #{string}"
+ end
+ description do
+ "expected an output with #{tag}"
+ end
+end
+
+RSpec::Matchers.define :have_time_based_snapshot do |tag|
+ match do |string|
+ # e.g.: `http://time-based.snapshots.deb.tails.boum.org/debian/2016060602`
+ %r{^http://time\-based\.snapshots\.deb\.tails\.boum\.org/[^/]+/\d+}.match(string)
+ end
+ failure_message_for_should do |string|
+ "expected the mirror to be a time-based snapshot\nCurrent mirror: #{string}"
+ end
+ failure_message_for_should_not do |string|
+ "expected the mirror not to be a time-based snapshot\nCurrent mirror: #{string}"
+ end
+ description do
+ "expected a time-based snapshot"
+ end
+end