Replace fetch_u-boot.sh with checkout_repo.sh

This allows checking out Git repositories besides U-Boot.

Co-Authored-By: Benjamin Dauphin <benjamin.dauphin@live.fr>
Co-Authored-By: Gilles Henaux <gill.henaux@gmail.com>
This commit is contained in:
Jean-Baptiste Boric
2016-05-28 17:40:45 +02:00
parent a7a79fa1f5
commit ad60a889a0
4 changed files with 77 additions and 60 deletions

View File

@@ -144,7 +144,7 @@ ${MKFS_VFAT_CMD} ${MKFS_VFAT_OPTS} ${WORK_DIR}/fat.img
#
# Download the stage 1 bootloader and u-boot
#
${RELEASETOOLSDIR}/fetch_u-boot.sh -o ${RELEASETOOLSDIR}/u-boot -n $U_BOOT_GIT_VERSION
${RELEASETOOLSDIR}/checkout_repo.sh -o ${RELEASETOOLSDIR}/u-boot -b ${U_BOOT_BRANCH} -n ${U_BOOT_REVISION} ${U_BOOT_URL}
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/MLO ${WORK_DIR}/
cp ${RELEASETOOLSDIR}/u-boot/${U_BOOT_BIN_DIR}/u-boot.img ${WORK_DIR}/

69
releasetools/checkout_repo.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/sh
#
# Perform a checkout / update of git repo if needed
#
OUTPUT_DIR=""
GIT_REVISION=""
REPO_URL=""
BRANCH="master"
while getopts "o:n:b:?" c
do
case "$c" in
\?)
echo "Usage: $0 [-b branch] [-o output_dir] -n revision repo_url" >&2
exit 1
;;
o)
OUTPUT_DIR=$OPTARG
;;
n)
GIT_REVISION=$OPTARG
;;
b)
BRANCH=$OPTARG
;;
esac
done
shift $(($OPTIND - 1))
REPO_URL=$1
#
# check arguments
#
if [ -z "$GIT_REVISION" -o -z "$REPO_URL" -o -z "$OUTPUT_DIR" ]
then
echo "Usage: $0 [-b branch] -o output_dir -n revision repo_url" >&2
exit 1
fi
#
# if the file doesn't exist it's easy , to a checkout
#
if [ ! -e "$OUTPUT_DIR" ]
then
git clone ${REPO_URL} -b $BRANCH $OUTPUT_DIR
fi
(
cd "$OUTPUT_DIR"
#
# perform an update
#
CURRENT_VERSION=$(git rev-parse HEAD)
echo "Checking out $REPO_URL..."
echo " * Current revision: $CURRENT_VERSION"
echo " * Wanted revision: $GIT_REVISION"
if [ "$CURRENT_VERSION" != "$GIT_REVISION" ]
then
echo " * Performing update and checkout..."
git fetch -v
git checkout $GIT_REVISION
fi
)

View File

@@ -1,59 +0,0 @@
#!/bin/sh
#
# Perform a checkout / update the MINIX u-boot git repo if needed
#
: ${UBOOT_REPO_URL=git://git.minix3.org/u-boot}
# -o output dir
OUTPUT_DIR=""
GIT_VERSION=""
while getopts "o:n:?" c
do
case "$c" in
\?)
echo "Usage: $0 -o output dir -n version " >&2
exit 1
;;
o)
OUTPUT_DIR=$OPTARG
;;
n)
GIT_VERSION=$OPTARG
;;
esac
done
#
# check arguments
#
if [ -z "$OUTPUT_DIR" -o -z "$GIT_VERSION" ]
then
echo "Missing required parameters OUTPUT_DIR=$OUTPUT_DIR GIT_VERSION=$GIT_VERSION"
echo "Usage: $0 -o output dir -n version " >&2
exit 1
fi
#
# if the file doesn't exist it's easy , to a checkout
#
if [ ! -e "$OUTPUT_DIR" ]
then
git clone ${UBOOT_REPO_URL} -b minix $OUTPUT_DIR
fi
(
cd "$OUTPUT_DIR"
#
# perform an update
#
CURRENT_VERSION=`git rev-parse HEAD`
if [ "$CURRENT_VERSION" != "$GIT_VERSION" ]
then
echo "Current version $CURRENT_VERSION does not match wanted $GIT_VERSION performing update and checkout"
git fetch -v
git checkout $GIT_VERSION
fi
)

View File

@@ -23,3 +23,10 @@
# where the kernel & boot modules will be
MODDIR=${DESTDIR}/boot/minix/.temp
#
# 3rd-party repositories
#
: ${U_BOOT_URL=git://git.minix3.org/u-boot}
: ${U_BOOT_BRANCH=minix}
: ${U_BOOT_REVISION=cb5178f12787c690cb1c888d88733137e5a47b15}