From ad60a889a02425f884c31c96151a51ffbb60c112 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Sat, 28 May 2016 17:40:45 +0200 Subject: [PATCH] Replace fetch_u-boot.sh with checkout_repo.sh This allows checking out Git repositories besides U-Boot. Co-Authored-By: Benjamin Dauphin Co-Authored-By: Gilles Henaux --- releasetools/arm_sdimage.sh | 2 +- releasetools/checkout_repo.sh | 69 +++++++++++++++++++++++++++++++++++ releasetools/fetch_u-boot.sh | 59 ------------------------------ releasetools/image.defaults | 7 ++++ 4 files changed, 77 insertions(+), 60 deletions(-) create mode 100755 releasetools/checkout_repo.sh delete mode 100755 releasetools/fetch_u-boot.sh diff --git a/releasetools/arm_sdimage.sh b/releasetools/arm_sdimage.sh index 51578628e..e9a941edd 100755 --- a/releasetools/arm_sdimage.sh +++ b/releasetools/arm_sdimage.sh @@ -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}/ diff --git a/releasetools/checkout_repo.sh b/releasetools/checkout_repo.sh new file mode 100755 index 000000000..f745232fa --- /dev/null +++ b/releasetools/checkout_repo.sh @@ -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 +) diff --git a/releasetools/fetch_u-boot.sh b/releasetools/fetch_u-boot.sh deleted file mode 100755 index 5531cd5b8..000000000 --- a/releasetools/fetch_u-boot.sh +++ /dev/null @@ -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 -) diff --git a/releasetools/image.defaults b/releasetools/image.defaults index e2a5f617a..a37e023b7 100644 --- a/releasetools/image.defaults +++ b/releasetools/image.defaults @@ -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}