- job:
    name: android-imx8m
    project-type: freestyle
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            everyone-flat:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 60
            num-to-keep: 60
    parameters:
    disabled: true
    node: docker-xenial-aosp
    display-name: 'DELETE ME'
    concurrent: true
    wrappers:
        - timestamps
        - timeout:
            timeout: 500
    builders:
        - shell: |
            #!/bin/bash

            export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
            export JENKINS_WORKSPACE=${WORKSPACE}

            java -version

            sudo apt-get -q=2 update
            sudo apt-get -q=2 install -y gcc-4.9-multilib bison git gperf libxml2-utils python-mako zip time python-requests genisoimage patch mtools python-pip pxz zlib1g-dev

            wget -q http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jre-headless_8u45-b14-1_amd64.deb \
              http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jre_8u45-b14-1_amd64.deb \
              http://mirrors.kernel.org/ubuntu/pool/universe/o/openjdk-8/openjdk-8-jdk_8u45-b14-1_amd64.deb
            sudo dpkg -i --force-all *.deb

            mkdir -p ${HOME}/bin ${WORKSPACE}/build/out
            curl https://storage.googleapis.com/git-repo-downloads/repo > ${HOME}/bin/repo
            chmod a+x ${HOME}/bin/*
            export PATH=${HOME}/bin:${PATH}

            wget -q http://snapshots.linaro.org/android/binaries/imx8m/imx-o8.1.0_1.3.0_8m.tar.gz
            tar -xvf imx-o8.1.0_1.3.0_8m.tar.gz
            cd imx-o8.1.0_1.3.0_8m
            source imx_android_setup.sh
            source build/envsetup.sh
            lunch evk_8mq
            set -e
            make -j$(nproc)

            cp device/fsl/common/tools/fsl-sdcard-partition.sh out/target/product/evk_8mq/
            export WORKSPACE=${JENKINS_WORKSPACE}

            wget -q https://git.linaro.org/ci/job/configs.git/blob_plain/HEAD:/android-imx8m/template.txt -O out/target/product/evk_8mq/BUILD-INFO.txt

            # Publish parameters
            cat << EOF > ${WORKSPACE}/publish_parameters
            PUB_DEST=android/imx8m/${BUILD_NUMBER}
            PUB_SRC=${PWD}/out/target/product/evk_8mq/
            PUB_EXTRA_INC=^[^/]+imx
            EOF
        - inject:
            properties-file: publish_parameters
        - linaro-publish-token
        - shell:
            !include-raw:
                - android/linaro-publisher.sh
    publishers:
        - logparser:
            parse-rules: '/var/jenkins_home/userContent/android.parse'
            unstable-on-warning: false
            fail-on-error: false
        - fingerprint:
            files: 'build/fingerprints/*'
        - email:
            recipients: 'vishal.bhoj@linaro.org fathi.boudra@linaro.org'
