]> git.ipfire.org Git - people/ms/nightly-builds.git/commitdiff
Initial import
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 28 Sep 2015 13:38:26 +0000 (15:38 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 28 Sep 2015 13:38:26 +0000 (15:38 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore [new file with mode: 0644]
build.sh [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..7e5eb6a
--- /dev/null
@@ -0,0 +1,2 @@
+/ipfire-2.x
+/upload
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..f8dd6e5
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,105 @@
+#!/bin/bash -l
+
+BASEDIR="/build/nightly"
+
+UPLOAD_DIR="${BASEDIR}/upload"
+UPLOAD_TO="pakfire@git.ipfire.org:/pub/nightly"
+RSYNC_ARGS="--bwlimit=1M"
+
+export MAKETUNING="-j2"
+
+extract_installer_from_iso() {
+       local dir="${1}"
+
+       local tmpdir="$(mktemp -d)"
+       mkdir -p "${dir}/images"
+
+       local file
+       for file in ${dir}/*.iso; do
+               if mount -o loop,ro "${file}" "${tmpdir}"; then
+                       local f
+                       for f in vmlinuz instroot; do
+                               cp -f "${tmpdir}/boot/isolinux/${f}" "${dir}/images"
+                       done
+                       umount "${tmpdir}"
+                       break
+               fi
+       done 2>/dev/null
+
+       rm -rf "${tmpdir}"
+}
+
+build() {
+       local dir="${1}"
+       shift
+
+       pushd "${dir}"
+
+       local branch="$(git config build.branch)"
+       [ -z "${branch}" ] && branch="master"
+
+       local commit_old="$(git rev-parse HEAD)"
+       git fetch
+
+       # If the branch was not updated, we won't build
+       local commit_new="$(git rev-parse origin/${branch})"
+       [ "${commit_old}" = "${commit_new}" ] && return 2
+
+       # Checkout the latest commit
+       git reset --hard "${commit_new}"
+
+       #local now="$(date -u +"%Y-%m-%d-%H:%M")"
+       local now="$(git log --format="%cI" -1 "${commit_new}")"
+
+       local targets="$(git config build.targets)"
+       [ -z "${targets}" ] && targets="i586"
+
+       local target
+       for target in ${targets}; do
+               local build="${UPLOAD_DIR}/${branch}/${now}-${commit_new:0:8}/${target}"
+
+               # Ready for build
+               ./make.sh --target="${target}" clean
+
+               # Download the toolchain if required
+               ./make.sh --target="${target}" gettoolchain || continue
+
+               # Download all sources
+               ./make.sh --target="${target}" downloadsrc || continue
+
+               # Execute the build
+               mkdir -p "${build}"
+               ./make.sh --target="${target}" build | tee "${build}/build.log"
+               local ret=${PIPESTATUS[0]}
+
+               # Save the result
+               if [ "${ret}" = "0" ]; then
+                       mv -v *.iso *.img.gz *.tar.bz2 *.md5 packages/ "${build}"
+                       extract_installer_from_iso "${build}"
+                       touch "${build}/.success"
+               fi
+               mv -v log/ "${build}"
+
+               # Upload the result
+               sync
+
+               # Cleanup in the end
+               ./make.sh --target="${target}" clean
+               rm -rf "$(dirname "${build}")"
+       done
+
+       popd
+}
+
+sync() {
+       mkdir -p "${UPLOAD_DIR}"
+
+       rsync -avHz --progress ${RSYNC_ARGS} \
+               "${UPLOAD_DIR}/" "${UPLOAD_TO}"
+}
+
+for repo in $(find ${BASEDIR} -maxdepth 2 -type d -name ".git"); do
+       [ -d "${repo}" ] || continue
+
+       build "$(dirname ${repo})"
+done