Commit cb1882f0 authored by intrigeri's avatar intrigeri
Browse files

Merge branch 'feature/12557-rake-prepare-build' into 'stable'

Merge base branch earlier

Closes #12557

See merge request tails/tails!381
parents ab995d56 6731d0e6
......@@ -38,7 +38,6 @@ EXPORTED_VARIABLES = [
'TAILS_ACNG_PROXY',
'TAILS_BUILD_FAILURE_RESCUE',
'TAILS_DATE_OFFSET',
'TAILS_MERGE_BASE_BRANCH',
'TAILS_OFFLINE_MODE',
'TAILS_PROXY',
'TAILS_PROXY_TYPE',
......@@ -298,9 +297,16 @@ task :parse_build_options do
$keep_running = true
ENV['TAILS_BUILD_FAILURE_RESCUE'] = '1'
# Jenkins
when 'mergebasebranch'
ENV['TAILS_MERGE_BASE_BRANCH'] = '1'
when 'nomergebasebranch'
$skip_mergebasebranch = true
else
# Handle jenkins passing the now obsolete mergebasebranch.
# XXX: the commit adding this comment should be reverted
# once jenkins stops passing the mergebasebranch option.
if opt == 'mergebasebranch' && on_jenkins?
warn "The 'mergebasebranch' option is obsolete!"
next
end
raise "Unknown Tails build option '#{opt}'"
end
end
......@@ -409,6 +415,38 @@ task setup_environment: ['validate_git_state'] do
end
end
task merge_base_branch: ['parse_build_options', 'setup_environment'] do
next if $skip_mergebasebranch
branch = git_helper('git_current_branch')
base_branch = git_helper('base_branch')
source_date_faketime = `date --utc --date="$(dpkg-parsechangelog --show-field=Date)" '+%Y-%m-%d %H:%M:%S'`.chomp
next if releasing? || branch == base_branch
commit_before_merge = git_helper('git_current_commit')
warn "Merging base branch '#{base_branch}' (at commit " \
"#{ENV['BASE_BRANCH_GIT_COMMIT']}) ..."
begin
run_command('faketime', '-f', source_date_faketime, \
'git', 'merge', '--no-edit', ENV['BASE_BRANCH_GIT_COMMIT'])
rescue CommandError
run_command('git', 'merge', '--abort')
raise <<-END_OF_MESSAGE.gsub(/^ /, '')
There were conflicts when merging the base branch; either
merge it yourself and resolve conflicts, or skip this merge
by rebuilding with the 'nomergebasebranch' option.
END_OF_MESSAGE
end
run_command('git', 'submodule', 'update', '--init')
# If we actually merged anything we'll re-run rake in the new Git
# state in order to avoid subtle build errors due to mixed state.
next if commit_before_merge == git_helper('git_current_commit')
ENV['TAILS_BUILD_OPTIONS'] = (ENV['TAILS_BUILD_OPTIONS'] || '') + \
' nomergebasebranch'
Kernel.exec('rake', *ARGV)
end
task :maybe_clean_up_builder_vms do
clean_up_builder_vms if $force_cleanup
end
......@@ -447,6 +485,7 @@ task build: [
'maybe_clean_up_builder_vms',
'validate_git_state',
'setup_environment',
'merge_base_branch',
'validate_http_proxy',
'ensure_correct_permissions',
'vm:up',
......
......@@ -21,14 +21,18 @@ else
fatal "SOURCE_DATE_EPOCH is not set. Exiting."
fi
# get git branch or tag so we can set the basename appropriately, i.e.:
# * if we build from a tag: tails-$ARCH-$TAG.iso
# * otherwise: tails-$ARCH-$BRANCH-$VERSION-$TIME-$COMMIT.iso
# get git branch or tag so we can set the basename appropriately.
GIT_BRANCH="$(git_current_branch)"
if [ -n "${GIT_BRANCH}" ]; then
CLEAN_GIT_BRANCH=$(echo "$GIT_BRANCH" | sed 's,/,_,g')
GIT_SHORT_ID="$(git_current_commit --short)"
BUILD_BASENAME="tails-amd64-${CLEAN_GIT_BRANCH}-${AMNESIA_VERSION}-${AMNESIA_NOW}-${GIT_SHORT_ID}"
BASE_BRANCH_PART=''
if [ "${GIT_BRANCH}" != "$(base_branch)" ]; then
CLEAN_GIT_BASE_BRANCH=$(base_branch | sed 's,/,_,g')
GIT_BASE_BRANCH_SHORT_ID="$(git rev-parse --verify --short $(git_base_branch_head))"
BASE_BRANCH_PART="+${CLEAN_GIT_BASE_BRANCH}@${GIT_BASE_BRANCH_SHORT_ID}"
fi
BUILD_BASENAME="tails-amd64-${CLEAN_GIT_BRANCH}@${GIT_SHORT_ID}${BASE_BRANCH_PART}-${AMNESIA_NOW}"
else
if git_on_a_tag; then
CLEAN_GIT_TAG=$(git_current_tag | tr '/-' '_~')
......@@ -40,30 +44,6 @@ else
fi
fi
GIT_BASE_BRANCH=$(base_branch) \
|| fatal "GIT_BASE_BRANCH could not be guessed."
if [ "${TAILS_MERGE_BASE_BRANCH:-}" = 1 ] && \
! git_on_a_tag && [ "$GIT_BRANCH" != "$GIT_BASE_BRANCH" ] ; then
[ -n "${BASE_BRANCH_GIT_COMMIT}" ] \
|| fatal "Base branch's top commit is not set."
echo "I: Merging base branch ${GIT_BASE_BRANCH}" \
"(at commit ${BASE_BRANCH_GIT_COMMIT})..."
faketime -f "${SOURCE_DATE_FAKETIME}" \
git merge --no-edit "${BASE_BRANCH_GIT_COMMIT}" \
|| fatal "Failed to merge base branch."
git submodule update --init
# Adjust BUILD_BASENAME to embed the base branch name and its top commit
CLEAN_GIT_BASE_BRANCH=$(echo "$GIT_BASE_BRANCH" | sed 's,/,_,g')
GIT_BASE_BRANCH_SHORT_ID=$(git rev-parse --verify --short "${BASE_BRANCH_GIT_COMMIT}")
[ -n "${GIT_BASE_BRANCH_SHORT_ID}" ] \
|| fatal "Base branch's top commit short ID could not be guessed."
BUILD_BASENAME="${BUILD_BASENAME}+${CLEAN_GIT_BASE_BRANCH}"
BUILD_BASENAME="${BUILD_BASENAME}@${GIT_BASE_BRANCH_SHORT_ID}"
fi
# save variables that lb build needs
mkdir -p tmp
echo "BUILD_BASENAME='${BUILD_BASENAME}'" > tmp/build_environment
......
......@@ -12,7 +12,6 @@
export SOURCE_DATE_EPOCH="$(date --utc --date="$(dpkg-parsechangelog --show-field=Date)" +%s)"
export SOURCE_DATE_YYYYMMDD="$(date --utc --date="$(dpkg-parsechangelog --show-field=Date)" +%Y%m%d)"
export SOURCE_DATE_FAKETIME="$(date --utc --date="$(dpkg-parsechangelog --show-field=Date)" '+%Y-%m-%d %H:%M:%S')"
# Base for the string that will be passed to "lb config --bootappend-live"
AMNESIA_APPEND="live-media=removable nopersistence noprompt timezone=Etc/UTC splash noautologin module=Tails slab_nomerge slub_debug=FZP mce=0 vsyscall=none page_poison=1 init_on_free=1 mds=full,nosmt"
......
......@@ -84,7 +84,6 @@ apt-get -y install \
debootstrap \
dosfstools \
dpkg-dev \
faketime \
gdisk \
gettext \
gir1.2-udisks-2.0 \
......
......@@ -23,7 +23,6 @@ as_root_do() {
${APT_SNAPSHOTS_SERIALS:+APT_SNAPSHOTS_SERIALS="${APT_SNAPSHOTS_SERIALS}"} \
${TAILS_WEBSITE_CACHE:+TAILS_WEBSITE_CACHE="${TAILS_WEBSITE_CACHE}"} \
${WEBSITE_CACHE_BASEDIR:+WEBSITE_CACHE_BASEDIR="${WEBSITE_CACHE_BASEDIR}"} \
${TAILS_MERGE_BASE_BRANCH:+TAILS_MERGE_BASE_BRANCH="${TAILS_MERGE_BASE_BRANCH}"} \
${GIT_COMMIT:+GIT_COMMIT="${GIT_COMMIT}"} \
${GIT_REF:+GIT_REF="${GIT_REF}"} \
${BASE_BRANCH_GIT_COMMIT:+BASE_BRANCH_GIT_COMMIT="${BASE_BRANCH_GIT_COMMIT}"} \
......
......@@ -49,6 +49,7 @@ Then:
libvirt-daemon-system \
dnsmasq-base \
ebtables \
faketime \
pigz \
qemu-system-x86 \
qemu-utils \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment