From fd9f9810fdb6da81c04b9257d29ac08428bf9e5d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 28 Sep 2015 15:38:26 +0200 Subject: [PATCH] Initial import Signed-off-by: Michael Tremer --- .gitignore | 2 + build.sh | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 .gitignore create mode 100755 build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e5eb6a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/ipfire-2.x +/upload diff --git a/build.sh b/build.sh new file mode 100755 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 -- 2.39.2