Projecte

General

Perfil

Baixar (2.51 KB) Estadístiques
| Branca: | Etiqueta: | Revisió:
9f0b2d87 p4u
#!/bin/bash

b2e7591a Jorge L. Florit
# 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.
9f0b2d87 p4u
#
# Example of usage:
283e5fbb Roger Pueyo Centelles
# FORCE="1" TARGETS="alix rspro" COMMUNITY="myNet" BRANCH="master" ./nightlycompile.sh
ccdce10a Roger Pueyo Centelles
#
9f0b2d87 p4u
# Mail to send alerts in case something goes wrong
MAIL="admin@qmp.cat"

# In the output directory, files older than this will be removed
DAYS_TO_PRESERVE="10"

e5818914 p4u
COMMUNITY=${COMMUNITY:-qMp}
283e5fbb Roger Pueyo Centelles
BRANCH=${BRANCH:-master}
9f0b2d87 p4u
# If target is not specified, compiling for all targets
e5818914 p4u
TARGETS=${TARGETS:-$(make list_targets)}

# Targets which are not gonna be compiled
73e6edce Roger Pueyo Centelles
NOTARGETS=${NOTARGETS:-ar71xx-ib ath25-ib mpc85xx-ib ramips-ib x86-ib}
9f0b2d87 p4u
ee446b02 Jorge L. Florit
# Extra packages (separated by spaces)
EXTRA_PACKS=${EXTRA_PACKS:-}

b2e7591a Jorge L. Florit
# If $FORCE is not set, then not forced by default
9f0b2d87 p4u
[ -z "$FORCE" ] && FORCE=0

b2e7591a Jorge L. Florit
# 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 QMP_GIT_BRANCH=$BRANCH >& /dev/null
[ $? -ne 0 ] && make update_all

# Date of the last commit
LAST_COMMIT_DATE=$(cd build/qmp && git log -1 origin/${BRANCH} --format="%ct")
9f0b2d87 p4u
56e7bcfe Pau Escrich
# Number of parallel procs
[ -z "$J" ] && J=$(cat /proc/cpuinfo | grep -c processor)
2c54aea6 p4u
293b74f1 p4u
(cd build/qmp && git checkout $BRANCH)
f1639b88 p4u
9f0b2d87 p4u
for t in $TARGETS; do
b2e7591a Jorge L. Florit
[[ "$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
[ $FORCE -ne 1 ] && [ -f "images/IMAGES" ] && {
TARGET_NAME=$(make target_name T=$t)
[ -z "$TARGET_NAME" ] && echo "Target $t unavailable. Not compiling." && continue
IMAGE_DATE=$(cat images/IMAGES | egrep "${TARGET_NAME}.*${COMMUNITY}_" | awk '{print $2}' | awk -F\- '{print $NF}' | sort -n -r | awk NR==1 | cut -d "." -f1 | sed s/_/\ /)
[ ! -z "$IMAGE_DATE" ] && {
IMAGE_DATE=$(date -d "${IMAGE_DATE}" +%s)
[ $IMAGE_DATE -ge $LAST_COMMIT_DATE ] && echo "qMp for target $t in last version." && continue
}
}

9f0b2d87 p4u
echo "Compiling target $t"
56e7bcfe Pau Escrich
nice -n 25 make T=$t build J=$J QMP_GIT_BRANCH=$BRANCH COMMUNITY=$COMMUNITY EXTRA_PACKS=$EXTRA_PACKS
b2e7591a Jorge L. Florit
[ $? -ne 0 ] && [ ! -z "$MAIL" ] && echo "Error detected during QMP compilation process (for target $t)" | mail -s "[qMp] build system" $MAIL && ./scripts/extra-packages.script POST_BUILD "ar71xx" $t $EXTRA_PACKS
9f0b2d87 p4u
done

ccdce10a Roger Pueyo Centelles
[ $DAYS_TO_PRESERVE -gt 0 ] && find images/ -iname $COMMUNITY*.* -type f -mtime +$DAYS_TO_PRESERVE -exec rm -f '{}' \;
9f0b2d87 p4u
ccdce10a Roger Pueyo Centelles
(cd images && md5sum $COMMUNITY*.* > IMAGES)