blob: 25bc9b23b6b5f15e267657cd5ff35d2c7aba522d (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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 <layername> <branch|revision>" ; 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 <<EOT
$dependency_section
EOT
cat <<EOT | sanity_check_num_lines "Layer Dependencies Section" 6 20
$dependency_section
EOT
# Get only this layer's information
layer_info=$(
cat <<EOT | sed -n "/URI:.*$layer/,/URI:/p" | sed 's/> //' | head -4
$dependency_section
EOT
)
# Get value for item "what"
value=$(
cat <<EOT | grep "$what" | awk '{print $2}'
$layer_info
EOT
)
# Check again - now only one line expected...
cat <<EOT | sanity_check_num_lines "$what information for $layer" 1 1
$value
EOT
# OK, this should be it:
echo $value
# Example README format:
#
#Layer Dependencies
#------------------
#
#URI: git://git.yoctoproject.org/poky
#> branch: fido
#> revision: eb4a134a60e3ac26a48379675ad6346a44010339
#
#URI: git://git.openembedded.org/meta-openembedded
#> layer: meta-oe
#> branch: fido
#> revision: 5b0305d9efa4b5692cd942586fb7aa92dba42d59
|