summaryrefslogtreecommitdiffstats
path: root/vagrant/provision/assets/build-tails
diff options
context:
space:
mode:
Diffstat (limited to 'vagrant/provision/assets/build-tails')
-rwxr-xr-xvagrant/provision/assets/build-tails75
1 files changed, 19 insertions, 56 deletions
diff --git a/vagrant/provision/assets/build-tails b/vagrant/provision/assets/build-tails
index 23da292..4ff955e 100755
--- a/vagrant/provision/assets/build-tails
+++ b/vagrant/provision/assets/build-tails
@@ -3,6 +3,7 @@
# This script is used by both our Vagrant and Jenkins -based build environments.
set -e
+set -x
as_root_do() {
sudo \
@@ -11,15 +12,10 @@ as_root_do() {
${https_proxy:+https_proxy="$https_proxy"} \
${ftp_proxy:+ftp_proxy="$ftp_proxy"} \
${no_proxy:+no_proxy="$no_proxy"} \
- ${JENKINS_URL:+JENKINS_URL="$JENKINS_URL"} \
${MKSQUASHFS_OPTIONS:+MKSQUASHFS_OPTIONS="$MKSQUASHFS_OPTIONS"} \
"$@"
}
-usable_memory() {
- free -b | awk '/cache:/ { print $4 }'
-}
-
cleanup() {
[ -n "$BUILD_DIR" ] || return 0
cd /
@@ -41,47 +37,30 @@ old_build_dirs() {
trap cleanup EXIT
-if [ -n "$JENKINS_URL" ]; then
- if [ -z "$WORKSPACE" ]; then
- echo "WORKSPACE environment variable is not set. Aborting." >&2
- exit 2
- fi
- if [ -z "$GIT_BRANCH" ]; then
- echo "GIT_BRANCH environment variable is not set. Aborting." >&2
- exit 4
- fi
- if [ -z "$GIT_COMMIT" ]; then
- echo "GIT_COMMIT environment variable is not set. Aborting." >&2
- exit 5
- fi
- REV="${GIT_BRANCH##origin/}"
- COMMIT="$GIT_COMMIT"
- ARTIFACTS_DIR="$WORKSPACE/build-artifacts"
+WORKSPACE=/home/vagrant/amnesia
+
+sudo rsync -a --exclude 'vagrant/.vagrant' "/amnesia.git/" "${WORKSPACE}"
+sudo chown -R vagrant:vagrant "${WORKSPACE}"
+
+cd "$WORKSPACE"
+
+COMMIT="$(git rev-parse --verify HEAD)"
+
+if git symbolic-ref HEAD >/dev/null 2>&1; then
+ # We are building from a branch
+ REV="${1:-$(git name-rev --name-only HEAD)}"
else
- # Build triggered by Vagrant
- WORKSPACE=/home/vagrant/amnesia
- ARTIFACTS_DIR=/home/vagrant
- COMMIT="$(git --git-dir=/amnesia.git rev-parse --verify HEAD)"
- if git --git-dir=/amnesia.git symbolic-ref HEAD >/dev/null 2>&1; then
- # We are building from a branch
- REV="${1:-$(git --git-dir=/amnesia.git name-rev --name-only HEAD)}"
- else
- # We are (hopefully) building from a tag
- if ! REV="${1:-$(git --git-dir=/amnesia.git describe --tags --exact-match ${COMMIT})}"; then
- echo "It seems we are building from an untagged detached HEAD. Aborting." >&2
- exit 1
- fi
+ # We are (hopefully) building from a tag
+ if ! REV="${1:-$(git describe --tags --exact-match ${COMMIT})}"; then
+ echo "It seems we are building from an untagged detached HEAD. Aborting." >&2
+ exit 1
fi
- test -d "$WORKSPACE" || git clone /amnesia.git "$WORKSPACE"
- cd "$WORKSPACE"
- git fetch --tags origin
fi
if [ "$TAILS_RAM_BUILD" ]; then
remove_build_dirs
fi
-cd "$WORKSPACE"
git checkout --force "$REV"
git reset --hard "$COMMIT"
git submodule update --init
@@ -91,21 +70,11 @@ if as_root_do systemctl --quiet is-active apt-cacher-ng.service ; then
as_root_do systemctl restart apt-cacher-ng.service
fi
-if [ -n "$JENKINS_URL" ]; then
- git clean --force -d -x
-fi
-
if [ "$TAILS_CLEAN_BUILD" ]; then
as_root_do lb clean --all
git clean -fdx
fi
-install -m 0755 -d "$ARTIFACTS_DIR"
-
-if [ -z "$JENKINS_URL" ]; then
- ./build-website
-fi
-
BUILD_DIR=$(mktemp -d /tmp/tails-build.XXXXXXXX)
if [ "$TAILS_RAM_BUILD" ]; then
as_root_do mount -t tmpfs -o "noatime,size=100%,mode=0770,uid=root,gid=${USER}" tmpfs "${BUILD_DIR}"
@@ -117,12 +86,6 @@ as_root_do lb config --cache false
as_root_do lb build
-if [ -n "$JENKINS_URL" ]; then
- ISO=$(ls *.iso)
- for file in tails-*; do
- sha512sum "$file" >> "$ISO.shasum"
- done
- gpg --batch --detach-sign --armor "$ISO.shasum"
+if [ "$TAILS_RAM_BUILD" ]; then
+ mv -f tails-* "$WORKSPACE/"
fi
-
-mv -f tails-* "$ARTIFACTS_DIR"