#!/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=\$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}" exit 1 } while getopts "${USAGE_OPTOVERLAY}d:l:ht" optn; do case \$optn in $USAGE_OPTHANDLER d ) DIR=\$OPTARG;; l ) LINARO_ANDROID_ACCESS_ID=\$OPTARG;; t ) EXACT=0;; h ) 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 uboot-mkimage openjdk-6-jdk openjdk-6-jre vim-common python-parted python-yaml wget' else echo "ERROR: Only 64bit Host(Build) machines are supported at the moment." exit 1 fi echo if [[ \${UBUNTU} =~ "13." || \${UBUNTU} =~ "12.10" ]]; then if [ \`dpkg-query -W -f='\${Status}\n' software-properties-common 2>&1 | grep '^install ok' | wc -l\` -eq 0 ]; then echo "Installing missing base dependency: software-properties-common" sudo apt-get install software-properties-common fi sudo dpkg --add-architecture i386 PKGS+=' libstdc++6:i386 git-core' elif [[ \${UBUNTU} =~ "12.04" || \${UBUNTU} =~ "10.04" ]] ; then if [ \`dpkg-query -W -f='\${Status}\n' python-software-properties 2>&1 | grep '^install ok' | wc -l\` -eq 0 ] ; then echo "Installing missing base dependency: python-software-properties" sudo apt-get install python-software-properties fi 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 "Checking missing dependencies if any..." MISSING=\`dpkg-query -W -f='\${Status} \${PACKAGE}\n' \${PKGS} 2>&1 | grep -v '^install ok' | awk '{print \$NF}'\` if [ -n "\$MISSING" ] ; then echo -n "Missing required packages: " for m in \$MISSING ; do echo -n "\${m} " done 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 apt-get update echo echo "Installing missing dependencies..." sudo apt-get install \`echo \${MISSING} | sed 's/\.//g'\` # 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 else echo "No missing package dependencies. Good to Go! " fi echo 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 ] ; 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 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