aboutsummaryrefslogtreecommitdiff
path: root/erp-playbook/local_scripts/check-for-changes.sh
blob: b223fb274d857e6ae61aae0544ca62bb2014abb6 (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
#!/bin/sh

BUILD_ENV=$1

if [ "${BUILD_ENV}" != "staging" -a "${BUILD_ENV}" != "stable" ]; then
    echo "Usage: $0 [staging|stable]"
    exit 1
fi

if [ "${BUILD_ENV}" = "staging" ]; then
    URLs=$(cat <<EOF
        http://repo.linaro.org/debian/erp-17.08-stable/dists/jessie/main/binary-arm64/Packages.bz2
        http://repo.linaro.org/debian/erp-17.08-staging/dists/jessie/main/binary-arm64/Packages.bz2
        http://repo.linaro.org/debian/erp-17.08-staging/dists/jessie/main/debian-installer/binary-arm64/Packages.gz
EOF
    )
elif [ "${BUILD_ENV}" = "stable" ]; then
    URLs=$(cat <<EOF
        http://repo.linaro.org/debian/erp-17.08-stable/dists/jessie/main/binary-arm64/Packages.bz2
        http://repo.linaro.org/debian/erp-17.08-stable/dists/jessie/main/debian-installer/binary-arm64/Packages.gz
EOF
    )
else
    echo "ERROR: Unknown value ${BUILD_ENV}"
    exit 1
fi

RESULT=""
for url in $URLs; do

    LAST_CHANGE="$(curl --silent -I ${url} | grep ^Last-Modified | sed 's/Last-Modified: //')"
    # Convert to a sortable datetime
    LAST_CHANGE=$(date -d "${LAST_CHANGE}" --iso-8601=seconds --utc)

    if [ -n "${RESULT}" ]; then
        RESULT="${RESULT}"$'\n'
    fi
    RESULT="${RESULT}${LAST_CHANGE}"

done

#echo "${RESULT}"
#echo ""
echo "Last Change: $(echo "${RESULT}" | sort -n | tail -1)"