# Set REPO_MIRROR to non-empty value to get around upstream downtimes #REPO_MIRROR="--repo-url=http://android.git.linaro.org/git-ro/tools/repo" REPO_MIRROR="--repo-url=git://android.git.linaro.org/tools/repo" setup-repo-vars () { EABI="${EABI-arm-eabi}" MANIFEST_REPO="${MANIFEST_REPO-git://android.git.kernel.org/platform/manifest.git}" MANIFEST_BRANCH="${MANIFEST_BRANCH-master}" MANIFEST_FILENAME="${MANIFEST_FILENAME-default.xml}" REPO_GROUPS=${REPO_GROUPS-"all,-notdefault,-eclipse"} REPO_QUIET=${REPO_QUIET-false} if [ "$REPO_QUIET" == "0" -o "$REPO_QUIET" == "false" ]; then REPO_QUIET="" else REPO_QUIET="--quiet" fi if [ -n "$REPO_SEED_URL" ]; then # If we use seeded builds, use higher value of repo sync -j, # as large share of repository content will be local and thus # only disk i/o bound. SYNC_JOBS=${SYNC_JOBS-5} #SYNC_JOBS=5 else SYNC_JOBS=${SYNC_JOBS-3} #SYNC_JOBS=3 fi } repo-sync-stubborn () { for i in 1 2; do time repo sync $REPO_QUIET -j$SYNC_JOBS -f || true done time repo sync $REPO_QUIET -j$SYNC_JOBS } repo-sync-from-mirror () { setup-repo-vars if [ -d "$REPO_SEED_DIR" ]; then repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" $REPO_MIRROR -g $REPO_GROUPS --reference=$REPO_SEED_DIR else repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" $REPO_MIRROR -g $REPO_GROUPS --depth=1 fi # Save input manifest as build artifact for reference mkdir -p out cp .repo/manifest.xml out/source-manifest.xml if [ -n "$LOCAL_MANIFEST" ]; then if [ ! -n "$LOCAL_MANIFEST_BRANCH" ]; then LOCAL_MANIFEST_BRANCH="master" fi cd .repo/ rm -rf local_manifests git clone $LOCAL_MANIFEST -b $LOCAL_MANIFEST_BRANCH local_manifests cd - fi if [ "$REWRITE_MANIFEST" != "0" ]; then echo Replace Linaro git URLs with lightweight http git URLs. ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml -o processed-manifest.xml -u "${MANIFEST_REPO}" cp processed-manifest.xml .repo/manifest.xml fi echo ---------------------------- repo-sync-stubborn # Restore source manifest temporarily to create pinned manifest cp out/source-manifest.xml .repo/manifest.xml repo manifest -r -o out/pinned-manifest.xml } repo-sync-from-seed () { setup-repo-vars local seed_name=$(basename $REPO_SEED_URL .tar.gz) mkdir -p $seed_name export TIMEFORMAT="TIME: Seed download and uncompress: %lR" time curl --silent --show-error "$REPO_SEED_URL" | gzip -d -c | tar --strip-components=1 -C $seed_name -x unset TIMEFORMAT # # Handle old seed format # if [ -d $seed_name/$seed_name ]; then # mv $seed_name ${seed_name}_ # mv ${seed_name}_/$seed_name . # rmdir ${seed_name}_ # fi repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" \ $REPO_MIRROR --reference=$PWD/$seed_name -g $REPO_GROUPS mkdir -p out cp .repo/manifest.xml out/source-manifest.xml echo Replace Linaro git URLs with lightweight http git URLs. ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml -o processed-manifest.xml -u "${MANIFEST_REPO}" cp processed-manifest.xml .repo/manifest.xml export TIMEFORMAT="TIME: Repo sync (using seed as reference): %lR" repo-sync-stubborn unset TIMEFORMAT # Restore source manifest temporarily to create pinned manifest cp out/source-manifest.xml .repo/manifest.xml repo manifest -r -o out/pinned-manifest.xml } calc_make_jobs () { if [ -z "$MAKE_JOBS" ]; then cpuc=`cat /proc/cpuinfo | grep processor | wc -l` MAKE_JOBS=$(($cpuc * 4)) fi } function get_url_basename { echo "$1" | sed -e 's/^.*\/\([^/]*\)$/\1/' } function get_tarball_version { # echo "$1" | sed -e 's/^.*-//' -e 's/\.tar.*$//' echo "$1" | sed -r -e 's/\.tar.*$//' -e 's/^[a-z0-9]+-(.*)/\1/' } #echo `get_version gcc-linaro-4.5-2011.04-0.tar.bz2` # linaro-4.5-2011.04-0 #echo `get_version binutils-2.20.1.tar.bz2` # 2.20.1 # # Download another builds's artifacts, as if they were # produced by this build. Used for testing, trigger by BUILD_COPYCAT # build config setting. # download_another_build () { local baseurl if ! echo "$1" | grep '://' >/dev/null; then baseurl="http://snapshots.linaro.org/android/$1" else baseurl=$1 fi local dir=out/target/product/$TARGET_OUT_DIR mkdir -p $dir pushd $dir wget -nv --no-check-certificate "$baseurl/boot.tar.bz2" || true wget -nv --no-check-certificate "$baseurl/boot.img" || true wget -nv --no-check-certificate "$baseurl/system.tar.bz2" || true wget -nv --no-check-certificate "$baseurl/system.img" || true wget -nv --no-check-certificate "$baseurl/userdata.tar.bz2" || true wget -nv --no-check-certificate "$baseurl/userdata.img" || true popd pushd out wget -nv --no-check-certificate "$baseurl/source-manifest.xml" || true wget -nv --no-check-certificate "$baseurl/pinned-manifest.xml" || true popd cat >out/BUILD-INFO.txt < $(basename $p) done IFS="$ifs_save" } unpack_overlays () { local ifs_save="$IFS" IFS=";" for p in $1; do tar -x -a -f $(basename $p) -C . done IFS="$ifs_save" } unpack_external_tarball () { ext_tarball_dir=$BUILD_SCRIPT_ROOT/../../build/external_tarballs # Always start clean if [[ -d $ext_tarball_dir ]]; then rm -rf $ext_tarball_dir fi mkdir -p $ext_tarball_dir pushd $ext_tarball_dir local ifs_save="$IFS" IFS=";" for p in $1; do regex_is_http="^https?://" regex_file=".*/(.*?)$" if [[ $p =~ $regex_is_http ]]; then # File is on a remote web server, wget it wget -nv --no-check-certificate $p fi if [[ $p =~ $regex_file ]]; then filename=${BASH_REMATCH[1]} tar -x -a -f "$filename" -C $ext_tarball_dir else echo "Fatal Error: $p - file name can not be determined" exit 1 fi done IFS="$ifs_save" popd } # Error handler for infrastructure setup (vs compiple) errors # Wrap infra-setup code in: # trap infrastructure_error ERR # trap - ERR infrastructure_error () { echo "Caught infrastructure error - finishing build with 'Not Built' status" # Interpreted as NOT_BUILT by Shell Status plugin exit 123 } # Convert Android's TARGET_PRODUCT to linaro-android-media-create --dev option value product2lamc_dev () { # Inventory: vexpress,snowball_emmc,mx6qsabrelite,vexpress-a9,panda,iMX53,smdkv310,snowball_sd,beagle,origen,mx53loco case "$1" in "pandaboard") echo -n "panda";; "juno") echo -n "vexpress";; "snowball") echo -n "snowball_sd";; "full_arndale") echo -n "arndale";; *) echo -n "$1";; esac } #Check if we are building on VPS is_on_ec2() { [ -e "/etc/cloud/cloud.cfg" ] } get_build_config() { if is_on_ec2; then echo "/var/run/" else echo "/tmp/" fi }