#!/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\`; EXACT=1;;" 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" echo " -h Will show this message." 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;; \? ) usage; exit 1;; esac done 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 vim-common python-parted python-yaml wget uuid-dev python-mako' else echo "ERROR: Only 64bit Host(Build) machines are supported at the moment." exit 1 fi if [[ \${UBUNTU} =~ "14.04" || \${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' if [[ \${UBUNTU} =~ "14.04" ]]; then PKGS+=' u-boot-tools bc acpica-tools' elif [[ \${UBUNTU} =~ "13.10" ]]; then PKGS+=' u-boot-tools bc iasl' else PKGS+=' uboot-mkimage acpica-tools' fi 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.*, 13.* and 14.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 "Install OpenJDK v1.7?" echo "*** If you are building AOSP master based builds then you should install OpenJDK v1.7. ***" echo "*** But if you are building Android 4.4.4 or earlier Android releases then OpenJDK v1.6 is OK to use. ***" echo "Press "y" to install OpenJDK v1.7, OR" echo "Press "n" to install OpenJDK v1.6, OR" echo "Press any other key to continue with the existing JDK installation." read JDK if [ \${JDK} == y ] ; then PKGS+=' openjdk-7-jdk openjdk-7-jre' elif [ \${JDK} == n ] ; then PKGS+=' openjdk-6-jdk openjdk-6-jre' else echo "Continue with the existing JDK installation .." fi 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 rm -rf .repo/local_manifests if [[ -n \${LOCAL_MANIFEST} && ! -n \${MANIFEST} ]]; then cd .repo/ git clone \${LOCAL_MANIFEST} -b \${LOCAL_MANIFEST_BRANCH} local_manifests cd - fi # check for linaro private git repositories PRI=\`grep -i "linaro-private" .repo/manifest.xml | wc -l\` if [ \${PRI} -gt 0 -a \${INTERACTIVE} -eq 1 ] ; then if [ "\${LINARO_ANDROID_ACCESS_ID}" == "\${USER}" ] ; then echo "You must specify valid login/access-id to clone from linaro-private git repositories." echo "Press "y" to continue with login: \${USER}, OR" echo "Press "n" to enter new 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/manifest.xml sed -i 's/\/\/.*-bot@/\/\/'"\${LINARO_ANDROID_ACCESS_ID}"'@/' .repo/local_manifests/*.xml 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