This repository has been archived by the owner on Oct 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
nightlycompile.sh
executable file
·62 lines (43 loc) · 2.17 KB
/
nightlycompile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# This is a dummy script to be used with crontab for nighly compilations and so.
# Not recommended to use in a read/write development environment.
#
# Example of usage:
# FORCE="1" TARGETS="alix rspro" COMMUNITY="myNet" BRANCH="testing" ./nightlycompile.sh
#
# Mail to send alerts in case something goes wrong
MAIL="admin@libremesh.org"
# In the output directory, files older than this will be removed
DAYS_TO_PRESERVE="10"
COMMUNITY=${COMMUNITY:-LiMe}
BRANCH=${BRANCH:-develop}
# If target is not specified, compiling for all targets
TARGETS=${TARGETS:-$(make list_targets)}
# Targets which are not gonna be compiled
NOTARGETS=${NOTARGETS:-}
# Extra packages (separated by spaces)
EXTRA_PACKS=${EXTRA_PACKS:-}
# If $FORCE is not set, then not forced by default
FORCE=${FORCE:-0}
# If no "IMAGES" file is supossed there are no binary images compiled, then force to compile
[ ! -f "images/IMAGES" ] && FORCE=1
# Check if it is up to date
[ "$(make is_up_to_date LIME_GIT_BRANCH=$BRANCH)" != "0" ] && make LIME_GIT_BRANCH=$BRANCH update_all && FORCE=1
# Number of parallel procs
[ -z "$J" ] && J=$(cat /proc/cpuinfo | grep -c processor)
#(cd build/lime-packages && git pull && git checkout $BRANCH && git pull origin $BRANCH)
# Date of the last commit
LAST_COMMIT_DATE=$(cd build/lime-packages && git log -1 origin/${BRANCH} --format="%ct")
# If force is not 1 at this point it means we should not compile
[ $FORCE -eq 0 ] && exit 0
# Let's compile
for t in $TARGETS; do
[[ "$NOTARGETS" =~ "$t" ]] && echo "Ignoring target $t. Not compiling." && continue
# If not forced, check if there is already compiled an image for the target with the last commit
echo "Compiling target $t"
echo "nice -n 25 make T=$t build J=$J LIME_GIT_BRANCH=$BRANCH COMMUNITY=$COMMUNITY EXTRA_PACKS=$EXTRA_PACKS"
nice -n 25 make T=$t build J=$J LIME_GIT_BRANCH=$BRANCH COMMUNITY=$COMMUNITY EXTRA_PACKS=$EXTRA_PACKS
[ $? -ne 0 ] && [ ! -z "$MAIL" ] && echo "Error detected during LiMe compilation process (for target $t)" | mail -s "[LiMe] build system" $MAIL
done
[ $DAYS_TO_PRESERVE -gt 0 ] && find images/ -iname "*.bin" -type f -mtime +$DAYS_TO_PRESERVE -exec rm -f '{}' \;
(cd images && md5sum *.bin > IMAGES)