rm -rf "${tmpdir}"
}
+uriencode() {
+ local path="${1}"
+
+ local IFS="/"
+
+ local s
+ local segments=()
+ for s in ${path}; do
+ s="${s//'%'/%25}"
+ s="${s//' '/%20}"
+ s="${s//'"'/%22}"
+ s="${s//'#'/%23}"
+ s="${s//'$'/%24}"
+ s="${s//'&'/%26}"
+ s="${s//'+'/%2B}"
+ s="${s//','/%2C}"
+ s="${s//'/'/%2F}"
+ s="${s//':'/%3A}"
+ s="${s//';'/%3B}"
+ s="${s//'='/%3D}"
+ s="${s//'?'/%3F}"
+ s="${s//'@'/%40}"
+ s="${s//'['/%5B}"
+ s="${s//']'/%5D}"
+
+ segments+=( "${s}" )
+ done
+
+ echo "${segments[*]}"
+}
+
+send_email() {
+ local status="${1}"
+ local target="${2}"
+ local branch="${3}"
+ local commit="${4}"
+ local build="${5}"
+
+ sendmail -ti <<END
+From: IPFire Nightly Builder <nightly-builds@ipfire.org>
+To: Nightly Builds List <nightly-builds@lists.ipfire.org>
+Subject: [${status^^}] Nightly Build of ${branch} (${commit:0:7}) for ${target} on ${HOSTNAME}
+Date: $(date --rfc-2822)
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+https://nightly.ipfire.org$(uriencode "${build:${#UPLOAD_DIR}}")
+
+$(git log -1 "${commit}")
+
+https://git.ipfire.org/?p=ipfire-2.x.git;a=shortlog;h=${commit}
+
+$(<"${build}/build.log")
+END
+}
+
build() {
local dir="${1}"
shift
for target in ${targets}; do
local build_path="${UPLOAD_DIR}/${branch}/${now}-${commit_new:0:8}"
local build="${build_path}/${target}"
+ local status="failed"
# Ready for build
./make.sh --target="${target}" clean
# Save the result
if [ "${ret}" = "0" ]; then
+ status="success"
+ touch "${build}/.success"
+
+ # Copy images
mv -v *.iso *.img.gz *.img.xz *.tar.bz2 *.md5 packages/ "${build}"
extract_installer_from_iso "${build}"
- touch "${build}/.success"
fi
mv -v log/ "${build}"
+ # Send an email notification
+ send_email "${status}" "${target}" "${branch}" "${commit_new}" "${build}"
+
# Cleanup the build environment
./make.sh --target="${target}" clean