summaryrefslogtreecommitdiff
path: root/hikey-hikey960-optee-chgrev-common
blob: 23c972fbaae53d651d13bfe3af31e5b5adeac185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash

### HiKey{,960} OPTEE "patch" for pull-requests coming from Github
###
### This patches the local manifest to adhere to what the SWG
### recommends as the starting point for OPTEE on HiKey{,960}, but
### changes the Git revision of either OPTEE OS or Client to
### instead use a pull-request from Github, whichever
### triggered this build job.
###
### If a pull-request doesn't exist, and OPTEE_VER is set to a
### value that's not 'master, this changes the revision of optee_*
### repos in the local manifest from master (default value) to
### a tagged version defined by OPTEE_VER. OPTEE_VER is a string
### param in configs.git which can be changed prior to starting a
### Jenkins build manually. This is used for testing releases.

sync_regen_man() {
        repo sync optee/optee_os external/optee_client \
		external/optee_test external/optee_examples \
		device/linaro/kmgk

        #echo "Sync HiKey960 bootloader repos"
        #repo sync optee/arm-trusted-firmware optee/edk2 \
		#optee/OpenPlatformPkg optee/l-loader \
		#optee/tools-images-hikey960 optee/uefi-tools

        echo "Regenerate manifest"
        repo manifest -r -o pinned-manifest.xml
}

if [ "${ghprbPullId}" ]; then
    echo "Applying Github pull-request #${ghprbPullId} from ${ghprbGhRepository}"

    lm=.repo/local_manifests
    if [ -d ${lm} ]; then
        # Disable this since we've moved swg-<ver>-hikey{,960.xml} to manifest.git/optee.xml
        #echo "Get SWG's local manifest for OPTEE HiKey{,960} AOSP <ver>"
        #wget -O ${lm}/swg.xml \
        #    https://raw.githubusercontent.com/linaro-swg/optee_android_manifest/lcr-ref-hikey/swg-<ver>-hikey{,960}.xml

        # Patch SWG's local manifest with pull-request
        project=${ghprbGhRepository#linaro-swg/*}
        if [ "${project}" = "optee_examples" ] || [ "${project}" = "kmgk" ]; then
            sed -i -e "s|name=\"linaro-swg/${project}\".*revision=\"master\"|name=\"linaro-swg/${project}\" revision=\"refs/pull/${ghprbPullId}/head\"|" ${lm}/optee.xml
         else
            project=${ghprbGhRepository#OP-TEE/*}
            sed -i -e "s|name=\"OP-TEE/${project}\".*revision=\"master\"|name=\"OP-TEE/${project}\" revision=\"refs/pull/${ghprbPullId}/head\"|" ${lm}/optee.xml
	fi

        # "Patch" OP-TEE to SWG + pull-request
        echo "Resync ${project} to PR ${ghprbPullId}"
        # Should really only sync ${project} rather than optee_*
        # but that will require more messy if-else's
        sync_regen_man
    else
        exit 1
    fi
elif [ "${OPTEE_VER}" != "master" ]; then
    echo "Changing revision for optee_* repos to refs/tags/${OPTEE_VER} for release testing"

    lm=.repo/local_manifests
    if [ -d ${lm} ]; then
        echo "First clean ${lm} up of previous changes if any"
        echo ""
        cd ${lm} && git status && echo "" && git checkout -- optee.xml && git status && echo -n "cd " && cd -
        echo ""

        # Change SWG's local manifest with release tag
        for i in optee_test optee_client optee_os
        do
            sed -i -e "s|name=\"OP-TEE/${i}\".*revision=\"master\"|name=\"OP-TEE/${i}\" revision=\"refs/tags/${OPTEE_VER}\"|" ${lm}/optee.xml
        done
        for i in optee_examples kmgk
        do
            sed -i -e "s|name=\"linaro-swg/${i}\".*revision=\"master\"|name=\"linaro-swg/${i}\" revision=\"refs/tags/${OPTEE_VER}\"|" ${lm}/optee.xml
        done

        # Change OP-TEE to release tag
        echo "Resync optee_* repos to ${OPTEE_VER}"
        sync_regen_man
    else
        exit 1
    fi
else
    echo "WARNING: No Github pull-request or version change request was identified."
fi