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}"
41 # Check if this actually source of IPFire 2
42 [ -x "${dir}/make.sh" ] ||
return 1
46 local branch
="$(git config build.branch)"
47 [ -z "${branch}" ] && branch
="master"
49 local commit_old
="$(git rev-parse HEAD)"
52 # Search for the latest core branch
53 if [ "${branch}" = "core" ]; then
54 branch
=$
(git branch
-r |
awk -F/ '{ print $NF }' |
grep ^core |
sort --version-sort |
tail -n1)
57 # If the branch was not updated, we won't build
58 local commit_new
="$(git rev-parse origin/${branch})"
59 [ "${commit_old}" = "${commit_new}" ] && return 2
61 local current_branch
="$(git rev-parse --abbrev-ref HEAD)"
62 if [ "${current_branch}" != "${branch}" ]; then
63 git checkout
-b "${branch}" "${commit_new}"
66 # Checkout the latest commit
67 git
reset --hard "${commit_new}"
69 local now
="$(git log --format="%ci
" -1 "${commit_new}")"
71 local targets
="$(git config build.targets)"
72 [ -z "${targets}" ] && targets
="i586"
75 for target
in ${targets}; do
76 local build_path
="${UPLOAD_DIR}/${branch}/${now}-${commit_new:0:8}"
77 local build
="${build_path}/${target}"
80 .
/make.sh
--target="${target}" clean
82 # Download the toolchain if required
83 .
/make.sh
--target="${target}" gettoolchain ||
continue
85 # Download all sources
86 .
/make.sh
--target="${target}" downloadsrc ||
continue
90 .
/make.sh
--target="${target}" build |
tee "${build}/build.log"
91 local ret
=${PIPESTATUS[0]}
94 git log
-50 > "${build}/changelog.txt"
97 if [ "${ret}" = "0" ]; then
98 mv -v *.iso
*.img.gz
*.img.xz
*.
tar.bz2
*.md5 packages
/ "${build}"
99 extract_installer_from_iso
"${build}"
100 touch "${build}/.success"
102 mv -v log
/ "${build}"
104 # Cleanup the build environment
105 .
/make.sh
--target="${target}" clean
108 # If that failed, we will keep the result and it will
109 # be retried with the next build. If that succeeded, the
110 # build will be removed from disk.
112 rm -rf "${UPLOAD_DIR}"
120 mkdir
-p "${UPLOAD_DIR}"
122 # Acquire a Kerberos ticket for authentication
123 if ! klist
&>/dev
/null
; then
124 kinit
-k -t /etc
/krb5.keytab
"host/${HOSTNAME}"
127 rsync
-avH --progress "${RSYNC_ARGS[@]}" \
128 "${UPLOAD_DIR}/" "${UPLOAD_TO}"
143 # Don't start again if the script is already running
144 # or if an other build script is running
145 if is_locked || pgrep
make.sh
>/dev
/null
; then
153 for repo
in $
(find ${BASEDIR} -maxdepth 3 -type d
-name ".git"); do
154 [ -d "${repo}" ] ||
continue
156 build
"$(dirname ${repo})"
159 # Try to sync even nothing was built for retrying failed uploads