#!/bin/bash set -e source "${BUILD_SCRIPT_ROOT}"/helpers setup-repo-vars #Translate # https://android-build.linaro.org/jenkins/job/doanac_build-script-generation/6/ # into # http://snapshots.linaro.org/android/~doanac/build-script-generation/6/ PINNED_MANIFEST_URL=${BUILD_URL/http*jenkins\/job\//http://snapshots.linaro.org/android/~} # change the dash in doanac_build... to doanac/build... PINNED_MANIFEST_URL=${PINNED_MANIFEST_URL/_/\/} if [ -n "$SOURCE_OVERLAY" ]; then USAGE_SUM="'Usage: \$0 -m -o [ -t -d directory -l login ]'" USAGE_OVERLAY="'\\n -m If -t is not used, then using a browser with cookies you\\n must download the pinned manifest from:\\n $PINNED_MANIFEST_URL\\n -o The path to the vendor required overlay.\\n Can be downloaded from http://snapshots.linaro.org/android/binaries/$SOURCE_OVERLAY\\n'" USAGE_OPTOVERLAY="m:o:" USAGE_OPTHANDLER="o ) SOURCE_OVERLAY=\$OPTARG; SOURCE_OVERLAY_OPTIONAL=0;; m ) MANIFEST=\`readlink -f \$OPTARG\`;;" else USAGE_SUM="'Usage: \$0 [ -t -d directory -l login ]'" fi header() { cat < The directory to download code and build from" echo " Default: \${DIR}" echo " -l login-id to clone from linaro-private git repositories" echo " If in doubt, please contact Linaro Android mailing list for details" echo " Default: \${LINARO_ANDROID_ACCESS_ID}" echo " -y Assume answer 'YES' for all questions. Non-interactive mode. Requires -l" exit 1 } while getopts "${USAGE_OPTOVERLAY}d:l:hty" optn; do case \$optn in $USAGE_OPTHANDLER d ) DIR=\$OPTARG;; l ) LINARO_ANDROID_ACCESS_ID=\$OPTARG;; t ) EXACT=0;; y ) INTERACTIVE=0;; h ) usage; exit 1;; esac done if [ "\${LINARO_ANDROID_ACCESS_ID}" == "default-bot" -a \${INTERACTIVE} -eq 0 ] ; then usage fi UBUNTU=\`cat /etc/issue.net | cut -d' ' -f2\` HOST_ARCH=\`uname -m\` if [ \${HOST_ARCH} == "x86_64" ] ; then PKGS='gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc uboot-mkimage openjdk-6-jdk openjdk-6-jre vim-common python-parted python-yaml wget uuid-dev acpica-tools' else echo "ERROR: Only 64bit Host(Build) machines are supported at the moment." exit 1 fi if [[ \${UBUNTU} =~ "13." || \${UBUNTU} =~ "12.10" ]]; then #Install basic dev package missing in chrooted environments sudo apt-get install software-properties-common sudo dpkg --add-architecture i386 PKGS+=' libstdc++6:i386 git-core' elif [[ \${UBUNTU} =~ "12.04" || \${UBUNTU} =~ "10.04" ]] ; then #Install basic dev package missing in chrooted environments sudo apt-get install python-software-properties if [[ \${UBUNTU} =~ "12.04" ]]; then PKGS+=' libstdc++6:i386 git-core' else PKGS+=' ia32-libs libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext' fi else echo "ERROR: Only Ubuntu 10.04, 12.* and 13.04 versions are supported." exit 1 fi echo echo "Setting up Ubuntu software repositories..." sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu \$(lsb_release -sc) main universe restricted multiverse" sudo add-apt-repository ppa:linaro-maintainers/tools sudo apt-get update echo echo "Installing missing dependencies if any..." if [ \$INTERACTIVE -eq 1 ] ; then sudo apt-get install \${PKGS} else sudo apt-get -y install \${PKGS} fi # Obsolete git version 1.7.04 in lucid official repositories # repo need at least git v1.7.2 if [[ \${UBUNTU} =~ "10.04" ]]; then echo echo "repo tool complains of obsolete git version 1.7.04 in lucid official repositories" echo "Building git for lucid from precise sources .." wget http://archive.ubuntu.com/ubuntu/pool/main/g/git/git_1.7.9.5.orig.tar.gz tar xzf git_1.7.9.5.orig.tar.gz cd git-1.7.9.5/ make prefix=/usr sudo make prefix=/usr install fi EOF if [ -n "$SOURCE_OVERLAY" ]; then cat < repo chmod +x repo # download the android code ./repo init -u \${MANIFEST_REPO} -b \${MANIFEST_BRANCH} -m \${MANIFEST_FILENAME} ${REPO_MIRROR} $REPO_GROUPS_OPTION if [ \${EXACT} -eq 1 ] ; then rm .repo/manifest.xml $CP_CMD fi # check for linaro private git repositories PRI=\`grep -i "linaro-private" .repo/manifests/\${MANIFEST_FILENAME} | wc -l\` if [ \${PRI} -gt 0 -a \${INTERACTIVE} -eq 1 ] ; then if [ "\${LINARO_ANDROID_ACCESS_ID}" == "default-bot" ] ; then echo "You must specify valid login/access-id to clone from linaro-private git repositories." echo "Press "y" to continue (which may result in incomplete build), OR" echo "Press "n" to enter login details, OR" echo "Press "h" for help." read NEXT if [ \${NEXT} == n ] ; then echo "Enter login/access-id:" read LINARO_ANDROID_ACCESS_ID elif [ \${NEXT} == h ] ; then usage fi fi sed -i 's/\/\/.*-bot@/\/\/'"\${LINARO_ANDROID_ACCESS_ID}"'@/' .repo/manifests/\${MANIFEST_FILENAME} fi ./repo sync -f -j1 EOF if [ -n "$TOOLCHAIN_URL" ] ; then cat < toolchain.tar.bz2 tar -jxf toolchain.tar.bz2 rm toolchain.tar.bz2 EOF fi if [ -n "$SOURCE_OVERLAY" ]; then cat < linaro_android_build_cmds.sh chmod +x linaro_android_build_cmds.sh