#!/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 " -u The manifest url to your AOSP mirror" echo " Default: ${MANIFEST_REPO}" 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:u:hty" optn; do case \${optn} in ${USAGE_OPTHANDLER} d ) DIR=\${OPTARG};; u ) MIRROR=\${OPTARG};; l ) LINARO_ANDROID_ACCESS_ID=\${OPTARG};; t ) EXACT=0;; y ) INTERACTIVE=0;; h ) usage; exit 1;; \? ) usage; exit 1;; esac done UBUNTU=\$(lsb_release -sc) HOST_ARCH=\$(uname -m) if [ \${HOST_ARCH} != "x86_64" ]; then echo "ERROR: Only 64bit Host(Build) machines are supported at the moment." exit 1 fi # Install basic dev package missing in chrooted environments echo echo "Setting up Ubuntu software repositories..." sudo apt-get update sudo apt-get install software-properties-common PKGS='git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip vim-common python-parted python-yaml wget uuid-dev python-mako u-boot-tools bc acpica-tools python-wand python-crypto mtools' if [[ \${UBUNTU} =~ "trusty" || \${UBUNTU} =~ "utopic" || \${UBUNTU} =~ "vivid" || \${UBUNTU} =~ "wily" || \${UBUNTU} =~ "xenial" ]]; then echo echo "Installing missing dependencies if any..." if [[ \${UBUNTU} =~ "trusty" ]]; then PKGS+=' openjdk-7-jdk openjdk-7-jre' else if [[ \${UBUNTU} =~ "utopic" || \${UBUNTU} =~ "vivid" ]]; then sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list fi sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update PKGS+=' openjdk-7-jdk openjdk-7-jre' fi if [ \${INTERACTIVE} -eq 1 ]; then sudo apt-get install \${PKGS} else sudo apt-get -y install \${PKGS} fi else echo "WARNING: Only Ubuntu 14.04 and above are supported. Press "y" to continue building AOSP without installing dependencies? " echo "Press any other key to continue with the existing JDK installation." read BUILD if [ "\${BUILD}" != y ]; then exit 1 fi fi EOF if [ -n "$SOURCE_OVERLAY" ]; then cat < repo chmod +x repo # Download the android code if [ -n "\${MIRROR}" ]; then MANIFEST_REPO="\${MIRROR}" fi ./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 if [[ -n \${LOCAL_MANIFEST} && ! -n \${MANIFEST} ]]; then sed -i 's/\/\/.*-bot@/\/\/'"\${LINARO_ANDROID_ACCESS_ID}"'@/' .repo/local_manifests/*.xml fi 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 "${PATCHSETS}" ]; then cat <&1 |tee build-${TARGET_PRODUCT}.log EOF } { header if [ -n "${BUILD_CONFIG_REPO}" ]; then git_configs_method else jenkins_configs_method fi sync_commands build_commands } > linaro_android_build_cmds.sh chmod +x linaro_android_build_cmds.sh