summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertagaz <bertagaz@ptitcanardnoir.org>2017-12-27 14:09:53 +0100
committerbertagaz <bertagaz@ptitcanardnoir.org>2018-01-01 15:48:39 +0100
commit59a5749be04e2a07e7e5d51df009b04e7cd8faea (patch)
tree6207c1ea2c76036958dc2b449328492f48c9cd02
parent99fcfed91a942f1cf34592c2a04d806a3e13f153 (diff)
Add a script to deduplicate ISOs in the reproducible build jobs artifacts.bugfix/14944-deduplicate-reproducible-jobs-ISOs
It replaces the downloaded upstream build job ISOs in the reproducible build jobs directories by a symlink to the original one. Refs: #14944
-rw-r--r--files/jenkins/master/deduplicate_reproducible_build_jobs_upstream_ISOs55
-rw-r--r--manifests/jenkins/master.pp15
2 files changed, 70 insertions, 0 deletions
diff --git a/files/jenkins/master/deduplicate_reproducible_build_jobs_upstream_ISOs b/files/jenkins/master/deduplicate_reproducible_build_jobs_upstream_ISOs
new file mode 100644
index 0000000..155beeb
--- /dev/null
+++ b/files/jenkins/master/deduplicate_reproducible_build_jobs_upstream_ISOs
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+set -u
+#set -x
+
+JOBS_DIR="${1}"
+
+[ "${JOBS_DIR}" ] || exit 2
+[ -d "${JOBS_DIR}" ] || exit 3
+
+hashsum () {
+ local file="${1}"
+ md5sum "${file}" | awk '{ print $1 }'
+}
+
+# Scan all reproducible build jobs directories
+for reproducible_build_job_dir in $(find "${JOBS_DIR}" \
+ -mindepth 1 \
+ -maxdepth 1 \
+ -type d \
+ -name 'reproducibly_build_Tails_ISO_*'); do
+
+ reproducible_job_name=$(basename "${reproducible_build_job_dir}")
+ build_job_name=$(echo "${reproducible_job_name}" | sed -e 's/reproducibly_//g')
+
+ # Get all the ISOs that were downloaded from a upstream build job
+ for build_job_iso in \
+ $(find "${reproducible_build_job_dir}" \
+ -path '*/archive/build-artifacts/1/*.iso'); do
+
+ # If the ISO file is not already a symlink
+ if [ ! -h "${build_job_iso}" ]; then
+
+ # Find an ISO with the same name in the related upstream build job directory
+ build_job_iso_filename=$(basename "${build_job_iso}")
+ original_build_job_iso=$(find "/var/lib/jenkins/jobs/${build_job_name}/" \
+ -name "${build_job_iso_filename}")
+
+ # If there's one and its hash is the same, link it in place
+ if [ "${original_build_job_iso}" ] && \
+ [ "$(hashsum ${original_build_job_iso})" = "$(hashsum ${build_job_iso})" ]; then
+
+ original_build_job_iso_relative_link=$(echo "${original_build_job_iso}" | \
+ sed -e 's/\/var\/lib\/jenkins\/jobs\//..\/..\/..\/..\/..\/..\//g')
+ rm -f "${build_job_iso}"
+ ln -s "${original_build_job_iso_relative_link}" "${build_job_iso}"
+
+ fi
+
+ fi
+
+ done
+
+done
diff --git a/manifests/jenkins/master.pp b/manifests/jenkins/master.pp
index ec0477e..18b3a56 100644
--- a/manifests/jenkins/master.pp
+++ b/manifests/jenkins/master.pp
@@ -336,6 +336,21 @@ class tails::jenkins::master (
Package['jenkins']],
}
+ file { '/usr/local/bin/deduplicate_reproducible_build_jobs_upstream_ISOs':
+ owner => root,
+ group => root,
+ mode => '0755',
+ source => 'puppet:///modules/tails/jenkins/master/deduplicate_reproducible_build_jobs_upstream_ISOs',
+ require => Package['jenkins'],
+ }
+
+ cron { 'deduplicate_reproducible_build_jobs_upstream_ISOs':
+ command => '/usr/local/bin/deduplicate_reproducible_build_jobs_upstream_ISOs /var/lib/jenkins/jobs',
+ user => 'jenkins',
+ minute => '*/6',
+ require => File['/usr/local/bin/deduplicate_reproducible_build_jobs_upstream_ISOs'],
+ }
+
file { '/usr/local/bin/manage_latest_iso_symlinks':
owner => root,
group => root,