3 BASEDIR
="/build/nightly"
4 LOCKFILE
="/tmp/.nightly-builds.lock"
6 UPLOAD_DIR
="${BASEDIR}/upload"
7 UPLOAD_TO
="pakfire@git.ipfire.org:/pub/nightly"
8 RSYNC_ARGS
="--bwlimit=1M"
10 export MAKETUNING
="-j2"
12 extract_installer_from_iso
() {
15 local tmpdir
="$(mktemp -d)"
16 mkdir
-p "${dir}/images"
19 for file in ${dir}/*.iso
; do
20 if mount
-o loop
,ro
"${file}" "${tmpdir}"; then
22 for f
in vmlinuz instroot
; do
23 cp -f "${tmpdir}/boot/isolinux/${f}" "${dir}/images"
28 for ext
in "" ".md5"; do
29 ln -s --relative "${file}${ext}" \
30 "${dir}/images/installer.iso${ext}"
43 # Check if this actually source of IPFire 2
44 [ -x "${dir}/make.sh" ] ||
return 1
48 local branch
="$(git config build.branch)"
49 [ -z "${branch}" ] && branch
="master"
51 local commit_old
="$(git rev-parse HEAD)"
54 # If the branch was not updated, we won't build
55 local commit_new
="$(git rev-parse origin/${branch})"
56 [ "${commit_old}" = "${commit_new}" ] && return 2
58 # Checkout the latest commit
59 git
reset --hard "${commit_new}"
61 #local now="$(date -u +"%Y-%m-%d-%H:%M")"
62 local now
="$(git log --format="%cI
" -1 "${commit_new}")"
64 local targets
="$(git config build.targets)"
65 [ -z "${targets}" ] && targets
="i586"
68 for target
in ${targets}; do
69 local build_path
="${UPLOAD_DIR}/${branch}/${now}-${commit_new:0:8}"
70 local build
="${build_path}/${target}"
73 .
/make.sh
--target="${target}" clean
75 # Download the toolchain if required
76 .
/make.sh
--target="${target}" gettoolchain ||
continue
78 # Download all sources
79 .
/make.sh
--target="${target}" downloadsrc ||
continue
83 .
/make.sh
--target="${target}" build |
tee "${build}/build.log"
84 local ret
=${PIPESTATUS[0]}
87 if [ "${ret}" = "0" ]; then
88 mv -v *.iso
*.img.gz
*.
tar.bz2
*.md5 packages
/ "${build}"
89 extract_installer_from_iso
"${build}"
90 touch "${build}/.success"
98 .
/make.sh
--target="${target}" clean
99 rm -rf "${build_path}"
106 mkdir
-p "${UPLOAD_DIR}"
108 rsync
-avHz --progress ${RSYNC_ARGS} \
109 "${UPLOAD_DIR}/" "${UPLOAD_TO}"
125 # Don't start again if the script is already running
126 # or if an other build script is running
127 if is_locked || pgrep
make.sh
>/dev
/null
; then
135 for repo
in $
(find ${BASEDIR} -maxdepth 3 -type d
-name ".git"); do
136 [ -d "${repo}" ] ||
continue
138 build
"$(dirname ${repo})"