aboutsummaryrefslogtreecommitdiff
path: root/bless-good.sh
blob: b6aa0391223dd43064f1fec51246cb65fce005f1 (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
#!/bin/bash

DIRPATH=imgs
MANIFEST=pinned-manifest.xml
BUILD_URL_FILE=build-url.txt
BOARD=$1

if [ $# -eq 0 ]; then
   echo "Error: No arguments"
   echo "Usage: ./bless-good.sh <valid board name>"
   exit -1
fi

echo "Blessing $BOARD"

if [ ! -d "$DIRPATH/$BOARD" ]; then
  echo "ERROR: No such path: $DIRPATH/$BOARD"
  exit -1
fi

pushd $DIRPATH/$BOARD > /dev/null

rm -f pinned-manifest.xml

URL=`cat $BUILD_URL_FILE`
wget $URL/$MANIFEST 2> /dev/null

RAW_DATE=`stat -c "%y" $MANIFEST`
DATE_HEADER=`date -u --date="$RAW_DATE" +%F_%T`

NEW_MANIFEST=$DATE_HEADER-$MANIFEST
echo $NEW_MANIFEST
mv $MANIFEST $NEW_MANIFEST

NEW_BUILD_URL_FILE="$DATE_HEADER-$BUILD_URL_FILE"
echo $NEW_BUILD_URL_FILE
cp $BUILD_URL_FILE $NEW_BUILD_URL_FILE

popd >/dev/null

mkdir -p known-good/$BOARD
cp $DIRPATH/$BOARD/$NEW_MANIFEST known-good/$BOARD/
cp $DIRPATH/$BOARD/$NEW_BUILD_URL_FILE known-good/$BOARD/

rm -f $BOARD.xml
ln -s known-good/$BOARD/$NEW_MANIFEST $BOARD.xml

echo "No don't forget to commit the files!"