summaryrefslogtreecommitdiffstats
path: root/doc/initbuildboot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'doc/initbuildboot.sh')
-rw-r--r--doc/initbuildboot.sh115
1 files changed, 115 insertions, 0 deletions
diff --git a/doc/initbuildboot.sh b/doc/initbuildboot.sh
new file mode 100644
index 0000000..52999de
--- /dev/null
+++ b/doc/initbuildboot.sh
@@ -0,0 +1,115 @@
1#!/bin/sh
2VER="R0.08"
3# R0.08/mrpa 2017-04-13 Created the first version of this profile
4
5BBTEMPLATE=
6BBXML=
7BB_TARGETREADME_BASE=
8
9USAGE="`basename $0` -xml buildbootxml-to-create -template templatexml-file -readmebasedir targetreadmebase ($VER)
10 Currently only supports sequence types Build-command: and Boot-command:
11 Both files should have path book-*release-info/doc/
12 Creates the XML file from the template, inserting build/boot commands
13 from the various s_manifests/el_manifest-XXX/XXXtargetXXX/README files
14 at the place in template with >SCRIPT_INCLUDES_BUILD_BOOT_SECTIONS_HERE<
15 ignoring rest of template
16 The code tries to fold too long lines, but this is not perfect. Best would
17 be if the command lines already in README are short enough, e.g. by
18 using short variables, which work both on shell and uboot command lines"
19
20while echo "x$1" | egrep '^x-' >/dev/null 2>&1
21do
22 OPT="$1" ; shift
23 if [ "$OPT" = "--help" -o "$OPT" = "-h" -o "$OPT" = "-help" ] ; then echo "$USAGE" ; exit ; fi
24 if [ "$OPT" = "-xml" ] ; then BBXML="$1" ; shift; fi
25 if [ "$OPT" = "-template" ] ; then BBTEMPLATE="$1" ; shift; fi
26 if [ "$OPT" = "-readmebasedir" ] ; then BB_TARGETREADME_BASE="$1" ; shift; fi
27done
28if [ "$BBTEMPLATE" = "" ]; then echo "ERROR: Missing option -template templatefile"; exit ; fi
29if [ "$BBXML" = "" ]; then echo "ERROR: Missing option -xml buildbootxml-to-create"; exit ; fi
30if [ ! -f "$BBTEMPLATE" ]; then echo "ERROR: Missing templatefile '$BBTEMPLATE'"; exit; fi
31if [ ! -d "`dirname \"$BBXML\"`" ]; then echo "ERROR: Missing parent directory for '$BBXML'"; exit ; fi
32if [ ! -d "$BB_TARGETREADME_BASE" ]; then echo "ERROR: Missing basedir for README files '$BB_TARGETREADME_BASE'"; exit; fi
33
34echo "`basename $0` Creating $BBXML from"
35TARGETREADMES=`cd $BB_TARGETREADME_BASE ; ls -d */README | tr '\n' ' '`
36echo " $TARGETREADMES"
37
38# README file formats:
39# a) Sequence starts: ___ XXXX:yyyy or ___ XXXX:yyyy conffile
40# where XXXX is a type, yyyy is text to be in title
41# b) Inside sequence: ___ END ends the sequence (ignore rest of line)
42# c) Inside sequence: # Documentation line
43# d) Inside sequence: Anything else is command or config lines
44# Conv.to XML: ">" "<" "&" and put all inside <programlisting>
45# *) Anywhere ____xxxx Leading 4 underlines or more, always ignored
46# unless one of the recognized XXXX
47# *) Anywhere outside sequence, ignore all
48# *) There can be multiple of each type of sequence in each README file
49# with different yyyy
50
51
52cat $BBTEMPLATE | awk '
53 />SCRIPT_INCLUDES_BUILD_BOOT_SECTIONS_HERE</ {exit 0; }
54 { print $0; }
55' >$BBXML
56
57
58# Long command lines: The awk code below breaks too long lines, but this is not perfect.
59extractcmds_filter() {
60 echo " <programlisting>" | tr -d '\n'
61 sed '/^___/d;s/\&/\&amp;/g' | sed 's/</\&lt;/g;s/>/\&gt;/g;/^$/d' | \
62 awk 'BEGIN { MAX=90; }
63 ( length($0) > MAX ) {
64 LINE=$0;
65 while (length(LINE) > MAX) {
66 if (index(LINE," ") == 0 ) {
67 print "ERROR: PROBLEM: No space in too long line:" LINE > "/dev/stderr";
68 print $LINE;
69 next;
70 }
71 i=MAX; while ( substr(LINE,i,1) != " " ) { i=i-1; if (i==0) {break;} }
72 print substr(LINE,0,i) "\\";
73 REST=substr(LINE,i+1);
74 if ( length(REST) == 0 ) { next ; }
75 LINE=" " REST;
76 }
77 if ( length(LINE) > 0 ) { print LINE; next ; }
78 }
79 { print;}'
80 echo "</programlisting>"
81}
82
83extractcmds_for_type() { # target/README BOOTorBUILD
84 README=$BB_TARGETREADME_BASE/"$1"
85 CMDTYPE="$2"
86 COMMANDSFOR=`egrep "___$CMDTYPE:" $README`
87 for CMDS in $COMMANDSFOR
88 do
89 cmdsfor=`echo "$CMDS" | sed 's/[^:]*://'`
90#-- echo " <para>$CMDTYPE for $cmdsfor</para>"
91 cat "$README" | sed -n "/$COMMANDSFOR/,/___END/p" | extractcmds_filter
92 done
93}
94
95for targetreadme in $TARGETREADMES
96do
97 TARGET=`dirname $targetreadme`
98 echo "" >>$BBXML
99 echo " <section id=\"target_$TARGET\">" >>$BBXML
100 echo " <title>Target $TARGET</title>" >>$BBXML
101 echo " <remark>NOTE: DO NOT EDIT THIS GENERATED FILE! Only edit the template file.</remark>" >>$BBXML
102 echo " <section>" >>$BBXML
103 echo " <title>Build Instructions for $TARGET</title>" >>$BBXML
104 extractcmds_for_type $targetreadme Build-command >>$BBXML
105 echo " </section>" >>$BBXML
106 echo "" >>$BBXML
107 echo " <section>" >>$BBXML
108 echo " <title>Boot Instructions for $TARGET</title>" >>$BBXML
109 extractcmds_for_type $targetreadme Boot-command >>$BBXML
110 echo " </section>" >>$BBXML
111 echo " </section>" >>$BBXML
112done
113
114echo "</chapter>" >>$BBXML
115echo "Ready created $BBXML"