3 BASEDIR
="/build/nightly"
4 LOCKFILE
="/tmp/.nightly-builds.lock"
6 UPLOAD_DIR
="${BASEDIR}/upload"
7 UPLOAD_TO
="pakfire@fs01.haj.ipfire.org:/pub/nightly"
8 RSYNC_ARGS
=( "--delay-updates" )
10 extract_installer_from_iso
() {
13 local tmpdir
="$(mktemp -d)"
14 mkdir
-p "${dir}/images"
17 for file in ${dir}/*.iso
; do
18 if mount
-o loop
,ro
"${file}" "${tmpdir}"; then
20 for f
in vmlinuz instroot
; do
21 cp -f "${tmpdir}/boot/isolinux/${f}" "${dir}/images"
26 for ext
in "" ".md5"; do
27 ln -s --relative "${file}${ext}" \
28 "${dir}/images/installer.iso${ext}"
76 From: IPFire Nightly Builder <nightly-builds@ipfire.org>
77 To: Nightly Builds List <nightly-builds@lists.ipfire.org>
78 Subject: [${status^^}] Nightly Build of ${branch} (${commit:0:7}) for ${target} on ${HOSTNAME}
79 Date: $(date --rfc-2822)
81 Content-Type: text/plain; charset="us-ascii"
82 Content-Transfer-Encoding: 7bit
84 https://nightly.ipfire.org$(uriencode "${build:${#UPLOAD_DIR}}")
86 $(git log -1 "${commit}")
88 https://git.ipfire.org/?p=ipfire-2.x.git;a=shortlog;h=${commit}
90 $(<"${build}/build.log")
98 # Check if this actually source of IPFire 2
99 [ -x "${dir}/make.sh" ] ||
return 1
103 local branch
="$(git config build.branch)"
104 [ -z "${branch}" ] && branch
="master"
106 local commit_old
="$(git rev-parse HEAD)"
109 # Search for the latest core branch
110 if [ "${branch}" = "core" ]; then
111 branch
=$
(git branch
-r |
awk -F/ '{ print $NF }' |
grep ^core |
sort --version-sort |
tail -n1)
114 # If the branch was not updated, we won't build
115 local commit_new
="$(git rev-parse origin/${branch})"
116 [ "${commit_old}" = "${commit_new}" ] && return 2
118 local current_branch
="$(git rev-parse --abbrev-ref HEAD)"
119 if [ "${current_branch}" != "${branch}" ]; then
120 git checkout
-b "${branch}" "${commit_new}"
123 # Checkout the latest commit
124 git
reset --hard "${commit_new}"
126 local now
="$(git log --format="%ci
" -1 "${commit_new}")"
128 local targets
="$(git config build.targets)"
129 [ -z "${targets}" ] && targets
="i586"
132 for target
in ${targets}; do
133 local build_path
="${UPLOAD_DIR}/${branch}/${now}-${commit_new:0:8}"
134 local build
="${build_path}/${target}"
135 local status
="failed"
138 .
/make.sh
--target="${target}" clean
140 # Download the toolchain if required
141 .
/make.sh
--target="${target}" gettoolchain ||
continue
143 # Download all sources
144 .
/make.sh
--target="${target}" downloadsrc ||
continue
148 .
/make.sh
--target="${target}" build |
tee "${build}/build.log"
149 local ret
=${PIPESTATUS[0]}
152 git log
-50 > "${build}/changelog.txt"
155 if [ "${ret}" = "0" ]; then
157 touch "${build}/.success"
160 mv -v *.iso
*.img.gz
*.img.xz
*.
tar.bz2
*.md5 packages
/ "${build}"
161 extract_installer_from_iso
"${build}"
163 mv -v log
/ "${build}"
165 # Send an email notification
166 send_email
"${status}" "${target}" "${branch}" "${commit_new}" "${build}"
168 # Cleanup the build environment
169 .
/make.sh
--target="${target}" clean
172 # If that failed, we will keep the result and it will
173 # be retried with the next build. If that succeeded, the
174 # build will be removed from disk.
176 rm -rf "${UPLOAD_DIR}"
184 mkdir
-p "${UPLOAD_DIR}"
186 # Acquire a Kerberos ticket for authentication
187 kinit
-k -t /etc
/krb5.keytab
"host/${HOSTNAME}"
189 rsync
-avH --progress "${RSYNC_ARGS[@]}" \
190 "${UPLOAD_DIR}/" "${UPLOAD_TO}"
205 # Don't start again if the script is already running
206 # or if an other build script is running
207 if is_locked || pgrep
make.sh
>/dev
/null
; then
215 for repo
in $
(find ${BASEDIR} -maxdepth 3 -type d
-name ".git"); do
216 [ -d "${repo}" ] ||
continue
218 build
"$(dirname ${repo})"
221 # Try to sync even nothing was built for retrying failed uploads