1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id$
|
---|
4 |
|
---|
5 | # Fills the tracking file with versions of LFS packages taken from an
|
---|
6 | # SVN repository, at either a given date or a given tag (argument $1).
|
---|
7 | #------
|
---|
8 | # Argument $1:
|
---|
9 | # $1 contains a tag or a date, to indicate which version of the LFS book
|
---|
10 | # to use. It may be empty, meaning to use whatever version is presently in
|
---|
11 | # lfs-xml.
|
---|
12 | #
|
---|
13 | # It is recognized as a tag if it begins with x.y, where 'x' is one or more
|
---|
14 | # digit(s), the '.' (dot) is mandatory, an 'y' is one or more digits. Anything
|
---|
15 | # after y is allowed (for example 7.6-systemd or 8.1-rc1).
|
---|
16 | #
|
---|
17 | # It is recognized as a date if it is exactly 8 digits. Then it is assumed that
|
---|
18 | # the format is YYYYMMDD.
|
---|
19 | #
|
---|
20 | # Note that there is no check that the tag or the date are valid. Svn errors
|
---|
21 | # out if the tag is not valid, and if the date is impossible (that is MM>12
|
---|
22 | # or DD>31), but it happily accepts YYYY=3018 (and updates to HEAD).
|
---|
23 | #------
|
---|
24 | # The tracking file is taken from Makefile in the same directory.
|
---|
25 |
|
---|
26 | MYDIR=$( cd $(dirname $0); pwd )
|
---|
27 | LFS_XML=${MYDIR}/lfs-xml
|
---|
28 |
|
---|
29 | if [ -z "$1" ]; then # use lfs-xml as is
|
---|
30 | DO_COMMANDS=n
|
---|
31 | elif [ "$(echo $1 | sed 's/^[[:digit:]]\+\.[[:digit:]]\+//')" != "$1" ]
|
---|
32 | then # tag
|
---|
33 | DO_COMMANDS=y
|
---|
34 | CURR_SVN=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Relative URL: //p')
|
---|
35 | CURR_REV=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Revision: //p')
|
---|
36 | BEG_COMMAND="(cd $LFS_XML; svn switch ^/tags/$1)"
|
---|
37 | END_COMMAND="(cd $LFS_XML; svn switch $CURR_SVN@$CURR_REV)"
|
---|
38 | elif [ "$(echo $1 | sed 's/^[[:digit:]]\{8\}$//')" != "$1" ]; then # date
|
---|
39 | DO_COMMANDS=y
|
---|
40 | CURR_REV=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Revision: //p')
|
---|
41 | BEG_COMMAND="(cd $LFS_XML; svn update -r\\{$1\\})"
|
---|
42 | END_COMMAND="(cd $LFS_XML; svn update -r$CURR_REV)"
|
---|
43 | else
|
---|
44 | echo Bad format in $1: must be a x.y[-aaa] tag or a YYYYMMDD date
|
---|
45 | exit 1
|
---|
46 | fi
|
---|
47 |
|
---|
48 | if [ -f $MYDIR/Makefile ]; then
|
---|
49 | TRACKING_DIR=$(sed -n 's/TRACKING_DIR[ ]*=[ ]*//p' $MYDIR/Makefile)
|
---|
50 | TRACKFILE=${TRACKING_DIR}/instpkg.xml
|
---|
51 | else
|
---|
52 | echo The directory where $0 resides does not contain a Makefile
|
---|
53 | exit 1
|
---|
54 | fi
|
---|
55 |
|
---|
56 | # We need to know the revision to generate the correct lfs-full...
|
---|
57 | if [ ! -r $MYDIR/revision ]; then
|
---|
58 | echo $MYDIR/revision is not available
|
---|
59 | exit 1
|
---|
60 | fi
|
---|
61 | REVISION=$(cat $MYDIR/revision)
|
---|
62 | #Debug
|
---|
63 | #echo BEG_COMMAND = $BEG_COMMAND
|
---|
64 | #echo Before BEG_COMMAND
|
---|
65 | #( cd $LFS_XML; LANG=C svn info )
|
---|
66 | #End debug
|
---|
67 |
|
---|
68 | if [ "$DO_COMMANDS"=y ]; then
|
---|
69 | echo Running: $BEG_COMMAND
|
---|
70 | eval $BEG_COMMAND
|
---|
71 | fi
|
---|
72 |
|
---|
73 | # Update code
|
---|
74 | LFS_FULL=/tmp/lfs-full.xml
|
---|
75 | echo Creating $LFS_FULL with information from $LFS_XML
|
---|
76 | echo "Processing LFS bootscripts..."
|
---|
77 | ( cd $LFS_XML && bash process-scripts.sh )
|
---|
78 | echo "Adjusting LFS for revision $REVISION..."
|
---|
79 | xsltproc --nonet --xinclude \
|
---|
80 | --stringparam profile.revision $REVISION \
|
---|
81 | --output /tmp/lfs-prof.xml \
|
---|
82 | $LFS_XML/stylesheets/lfs-xsl/profile.xsl \
|
---|
83 | $LFS_XML/index.xml
|
---|
84 | echo "Validating the LFS book..."
|
---|
85 | xmllint --nonet --noent --postvalid \
|
---|
86 | -o $LFS_FULL /tmp/lfs-prof.xml
|
---|
87 | rm -f $LFS_XML/appendices/*.script
|
---|
88 | ( cd $LFS_XML && ./aux-file-data.sh $LFS_FULL )
|
---|
89 |
|
---|
90 | echo Updating ${TRACKFILE} with information taken from $LFS_FULL
|
---|
91 | echo -n "Is it OK? yes/no (no): "
|
---|
92 | read ANSWER
|
---|
93 | #Debug
|
---|
94 | echo You answered $ANSWER
|
---|
95 | #End debug
|
---|
96 |
|
---|
97 | if [ x$ANSWER = "xyes" ] ; then
|
---|
98 | for pack in $(grep '<productname' $LFS_FULL |
|
---|
99 | sed 's/.*>\([^<]*\)<.*/\1/' |
|
---|
100 | sort | uniq); do
|
---|
101 | if [ "$pack" = "libstdc++" ]; then continue; fi
|
---|
102 | VERSION=$(grep -A1 ">$pack</product" $LFS_FULL |
|
---|
103 | head -n2 |
|
---|
104 | sed -n '2s/.*>\([^<]*\)<.*/\1/p')
|
---|
105 | #Debug
|
---|
106 | echo $pack: $VERSION
|
---|
107 | #End debug
|
---|
108 | xsltproc --stringparam packages $MYDIR/packages.xml \
|
---|
109 | --stringparam package $pack \
|
---|
110 | --stringparam version $VERSION \
|
---|
111 | -o track.tmp \
|
---|
112 | $MYDIR/xsl/bump.xsl ${TRACKFILE}
|
---|
113 | sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
|
---|
114 | xmllint --format --postvalid track.tmp > ${TRACKFILE}
|
---|
115 | rm track.tmp
|
---|
116 | done
|
---|
117 | fi
|
---|
118 | #Debug
|
---|
119 | #echo After BEG_COMMAND\; before END_COMMAND
|
---|
120 | #( cd $LFS_XML; LANG=C svn info )
|
---|
121 | #End debug
|
---|
122 |
|
---|
123 |
|
---|
124 | if [ "$DO_COMMANDS"=y ]; then
|
---|
125 | echo Running: $END_COMMAND
|
---|
126 | eval $END_COMMAND
|
---|
127 | fi
|
---|
128 |
|
---|
129 | #Debug
|
---|
130 | #echo After END_COMMAND
|
---|
131 | #( cd $LFS_XML; LANG=C svn info )
|
---|
132 | #End debug
|
---|