- job:
    name: jdk-cache-files2
    project-type: matrix
    defaults: global
    description: |
        Download and unpack boot jdks.
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            openjdk-members:
                - job-build
                - job-cancel
        - build-discarder:
            num-to-keep: 10
            artifact-num-to-keep: 1
    disabled: true
    node: master
    concurrent: false
    display-name: 'DELETE ME'
    wrappers:
        - timestamps
    axes:
        - axis:
            type: slave
            name: node
            values:
                - aarch64-06
                - j12-qrep-01
    execution-strategy:
        sequential: false
    builders:
        - copyartifact:
            project: openjdk8-hadoop-LCA14
            filter: 'out/openjdk8-hadoop-LCA14.tar.gz'
            flatten: true
        - copyartifact:
            project: archive-specjbb2015-product-tarball
            filter: 'out/SPECjbb2015.tgz'
            flatten: true
        - copyartifact:
            project: jdk-build-specjbb2015-jdk11
            filter: 'out/SPECjbb2015-jdk11.tar.gz'
            flatten: true
        - shell: |
            #!/bin/bash
            set -eu
            PERSIST=$HOME/srv/jdk-cache
            NEW_PERSIST=$PERSIST-new
            OLD_PERSIST=$PERSIST-old

            # Creating all maintains idempotency.
            mkdir -v -p $NEW_PERSIST $OLD_PERSIST $PERSIST

            JDK8u=jdk8u-server-release-1804
            JDK10=jdk10-server-release-1804
            JDK11=jdk11-server-release-1811
            JDK12=jdk12-release-1903
            JDK13=OpenJDK13U-jdk_aarch64_linux_hotspot_13_33.tar.gz
            JDK14=jdk14.tar.gz

            rm -vrf jdk*
            wget -N \
                 http://openjdk.linaro.org/releases/${JDK8u}.tar.xz \
                 http://openjdk.linaro.org/releases/${JDK10}.tar.xz \
                 http://openjdk.linaro.org/releases/${JDK11}.tar.xz \
                 http://openjdk.linaro.org/releases/${JDK12}.tar.xz \
                 http://openjdk.linaro.org/releases/${JDK13} \
                 http://openjdk.linaro.org/releases/${JDK14}

            tar -vJxf ${JDK8u}.tar.xz
            tar -vJxf ${JDK10}.tar.xz
            tar -vJxf ${JDK11}.tar.xz
            tar -vJxf ${JDK12}.tar.xz
            tar -vxzf ${JDK13}
            tar -vxzf ${JDK14}

            mv -v ${JDK8u} $NEW_PERSIST/jdk8u
            mv -v ${JDK10} $NEW_PERSIST/jdk10
            mv -v ${JDK11} $NEW_PERSIST/jdk11
            mv -v ${JDK12} $NEW_PERSIST/jdk12
            mv -v jdk-13+33 $NEW_PERSIST/jdk13
            mv -v jdk14 $NEW_PERSIST/jdk14

            mv openjdk8-hadoop-LCA14.tar.gz $NEW_PERSIST
            mv SPECjbb2015.tgz $NEW_PERSIST
            mv SPECjbb2015-jdk11.tar.gz $NEW_PERSIST

            # Remove the old persist, make the current one the old, and the
            # new one the current one.
            rm -vrf $OLD_PERSIST
            mv -v $PERSIST $OLD_PERSIST
            mv -v $NEW_PERSIST $PERSIST
    publishers:
        - email:
            recipients: 'stuart.monteith@linaro.org'
