From 70b68b5555fec6a6ecc792a31fc1d900337f7d43 Mon Sep 17 00:00:00 2001 From: Yong-iL Joh Date: Tue, 25 Oct 2016 14:57:19 +0900 Subject: scripts/checkout: added for convenience Signed-off-by: Yong-iL Joh --- scripts/checkout | 9 ++++ scripts/checkout_layer_hash.sh | 38 +++++++++++++++ scripts/get_layer_info_from_README.sh | 90 +++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100755 scripts/checkout create mode 100755 scripts/checkout_layer_hash.sh create mode 100755 scripts/get_layer_info_from_README.sh (limited to 'scripts') diff --git a/scripts/checkout b/scripts/checkout new file mode 100755 index 0000000..ec892b3 --- /dev/null +++ b/scripts/checkout @@ -0,0 +1,9 @@ +#!/bin/sh +# (C) 2016-10-25 Yong-iL Joh +# License: MPLv2 + +export LANG=C +MYDIR=$(dirname "$0") + +$MYDIR/checkout_layer_hash.sh poky +$MYDIR/checkout_layer_hash.sh meta-openembedded diff --git a/scripts/checkout_layer_hash.sh b/scripts/checkout_layer_hash.sh new file mode 100755 index 0000000..a00dda4 --- /dev/null +++ b/scripts/checkout_layer_hash.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# (C) 2015-12-12 Gunnar Andersson +# (C) 2016-10-25 Yong-iL Joh +# License: MPLv2 + +fail() { + echo "FAILED." + [ -n "$1" ] && echo "Message: " $@ + exit 1 +} + +# Store the location of these scripts +_DIR=$(dirname "$0") +META_IVI=$(readlink -f $_DIR/..) +MYDIR=$(readlink -f $_DIR) + +layer=$1 +[ -z "$layer" ] && fail "No layer name given" + +# Extract revision from README in meta-ivi +cd "$META_IVI" || fail "Can't cd to meta-ivi directory" +revision=$($MYDIR/get_layer_info_from_README.sh $layer revision) +uri=$($MYDIR/get_layer_info_from_README.sh $layer URI) + +# Fail if we could not fetch revision +[ -z "$revision" ] && fail "Revision extracted from README was empty" + +# Checkout the right revision in this layer +if [ ! -d "$META_IVI/../$layer/.git" ]; then + if [ -e "$META_IVI/../$layer" ]; then + rm -rf "$META_IVI/../$layer" + else + cd "$META_IVI/.." + git clone $uri + fi +fi +cd "$META_IVI/../$layer" || fail "Can't cd to layer directory ($layer)" +git checkout $revision diff --git a/scripts/get_layer_info_from_README.sh b/scripts/get_layer_info_from_README.sh new file mode 100755 index 0000000..25bc9b2 --- /dev/null +++ b/scripts/get_layer_info_from_README.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# (C) Gunnar Andersson 2015-12-12 +# License: MPLv2 + +# This fetches information about layer dependencies +# as documented in meta-ivi README. +# revision, branch name, or sub layer name can be extracted + +README=README.md +DEBUG=false + +layer=$1 +what=$2 + +[ -z "$layer" -o -z "$what" ] && { echo "Usage: $0 " ; exit 1 ; } + +fail() { + echo "*** FAILED ***" + [ -n "$1" ] && echo "Message: " $@ + exit 1 +} + +sanity_check_num_lines() { + what=$1 ; min=$2 ; max=$3 + + numlines="$(wc -l)" # < Reads from stdin + + if [ $numlines -lt $min ] ; then + fail "Sanity check: It looks like section $what has $numlines lines, and that is not enough. Please check what is wrong." + fi + + if [ $numlines -gt $max ] ; then + fail "Sanity check: It looks like section $what has $numlines lines, and that is more than expected. Please check what is wrong." + fi +} + +[ -f ./$README ] || fail "Cannot find README.md. (Current directory is $PWD)" + +# Extract relevant section of the README +dependency_section=$( <$README \ + sed -n '/Layer Dependencies/,/known to work/p' |\ + egrep 'URI:|branch:|layer:|revision:') + +# Debug printouts... +$DEBUG && echo "OK, found the following layer info in dependency section:" +$DEBUG && cat < //' | head -4 +$dependency_section +EOT +) + +# Get value for item "what" +value=$( +cat < branch: fido +#> revision: eb4a134a60e3ac26a48379675ad6346a44010339 +# +#URI: git://git.openembedded.org/meta-openembedded +#> layer: meta-oe +#> branch: fido +#> revision: 5b0305d9efa4b5692cd942586fb7aa92dba42d59 + -- cgit v1.2.2-1-g5e49