xref: /minix/releasetools/fetch_u-boot.sh (revision e3b78ef1)
1#!/bin/sh
2#
3# Perform a checkout / update the MINIX u-boot git repo if needed
4#
5: ${UBOOT_REPO_URL=git://git.minix3.org/u-boot}
6
7# -o output dir
8OUTPUT_DIR=""
9GIT_VERSION=""
10while getopts "o:n:?" c
11do
12        case "$c" in
13        \?)
14                echo "Usage: $0 -o output dir -n version " >&2
15                exit 1
16        	;;
17        o)
18                OUTPUT_DIR=$OPTARG
19		;;
20        n)
21                GIT_VERSION=$OPTARG
22		;;
23	esac
24done
25
26
27#
28# check arguments
29#
30if [ -z "$OUTPUT_DIR" -o -z "$GIT_VERSION" ]
31then
32		echo "Missing required parameters OUTPUT_DIR=$OUTPUT_DIR GIT_VERSION=$GIT_VERSION"
33                echo "Usage: $0 -o output dir -n version " >&2
34                exit 1
35fi
36
37
38#
39# if the file doesn't exist it's easy , to a checkout
40#
41if  [ ! -e "$OUTPUT_DIR" ]
42then
43	git clone ${UBOOT_REPO_URL} -b minix $OUTPUT_DIR
44fi
45
46(
47	cd  "$OUTPUT_DIR"
48
49	#
50	# perform an update
51	#
52	CURRENT_VERSION=`git rev-parse HEAD`
53	if [ "$CURRENT_VERSION" !=  "$GIT_VERSION" ]
54	then
55		echo "Current version $CURRENT_VERSION does not match wanted $GIT_VERSION performing update and checkout"
56		git fetch -v
57		git checkout $GIT_VERSION
58	fi
59)
60