Joakim Bech | 9940fb4 | 2018-04-04 14:58:15 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | VERSION= |
| 4 | OVERWRITE=false |
| 5 | |
| 6 | function help() { |
| 7 | echo " -r <revision> new revision for OP-TEE and linaro-swg gits" |
| 8 | echo " -o overwrite existing xml-files" |
| 9 | echo " -h help" |
| 10 | exit |
| 11 | } |
| 12 | |
| 13 | while getopts "or:h" opt; do |
| 14 | case $opt in |
| 15 | o) |
| 16 | OVERWRITE=true |
| 17 | ;; |
| 18 | r) |
| 19 | VERSION=${OPTARG} |
| 20 | ;; |
| 21 | h) |
| 22 | help |
| 23 | ;; |
| 24 | \?) |
| 25 | echo "Invalid option: -${OPTARG}" >&2 |
| 26 | exit 1 |
| 27 | ;; |
| 28 | :) |
| 29 | echo "Option -${OPTARG} requires an argument." >&2 |
| 30 | exit 1 |
| 31 | ;; |
| 32 | esac |
| 33 | done |
| 34 | |
| 35 | if [ -z "${VERSION}" ]; then |
| 36 | echo "No version provided, not doing any changes!" |
| 37 | exit |
| 38 | fi |
| 39 | |
| 40 | for xml in *.xml |
| 41 | do |
| 42 | FILE=$xml.${VERSION} |
| 43 | if [ ${OVERWRITE} == true ]; then |
| 44 | FILE=$xml |
| 45 | fi |
| 46 | |
| 47 | cat $xml | |
| 48 | sed "s/\(OP-TEE\/.*\)revision.*/\1\/>/" | # Removes old revision |
| 49 | sed "s/\(OP-TEE.*\"\)/\1 revision=\"refs\/tags\/${VERSION}\" clone-depth=\"1\"/" | |
| 50 | sed "s/\(OP-TEE\/build.git.*\) \/>/\1>/" | # Strip away a forward slash from build.git only |
| 51 | |
| 52 | sed "s/\(linaro-swg\/optee_examples.git\)revision.*/\1\/>/" | # Removes old revision |
| 53 | sed "s/\(linaro-swg\/optee_examples.git\"\)/\1 revision=\"refs\/tags\/${VERSION}\" clone-depth=\"1\"/" | |
| 54 | sed "s/\(linaro-swg\/optee_benchmark.git\)revision.*/\1\/>/" | # Removes old revision |
| 55 | sed "s/\(linaro-swg\/optee_benchmark.git\"\)/\1 revision=\"refs\/tags\/${VERSION}\" clone-depth=\"1\"/" | |
| 56 | tee ${FILE} 2>&1 > /dev/null |
| 57 | done |