[ce244f6] | 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
|
---|
[e3f4b9a4] | 98 | for pack in $(grep '<productname' $LFS_FULL |
|
---|
| 99 | sed 's/.*>\([^<]*\)<.*/\1/' |
|
---|
| 100 | sort | uniq); do
|
---|
[a1795f0] | 101 | case "x$pack" in
|
---|
[a26389a] | 102 | xtcl | xexpect | xdejagnu | xgcc* | *pass[12] | xvim | \
|
---|
[a1795f0] | 103 | xshadow | xPython | xlinux-headers | xdbus | xsystemd )
|
---|
| 104 | continue ;;
|
---|
| 105 | esac
|
---|
| 106 |
|
---|
[e3f4b9a4] | 107 | VERSION=$(grep -A1 ">$pack</product" $LFS_FULL |
|
---|
| 108 | head -n2 |
|
---|
| 109 | sed -n '2s/.*>\([^<]*\)<.*/\1/p')
|
---|
[ce244f6] | 110 | #Debug
|
---|
| 111 | echo $pack: $VERSION
|
---|
[e3f4b9a4] | 112 | #End debug
|
---|
| 113 | xsltproc --stringparam packages $MYDIR/packages.xml \
|
---|
| 114 | --stringparam package $pack \
|
---|
| 115 | --stringparam version $VERSION \
|
---|
| 116 | -o track.tmp \
|
---|
| 117 | $MYDIR/xsl/bump.xsl ${TRACKFILE}
|
---|
| 118 | sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
|
---|
| 119 | xmllint --format --postvalid track.tmp > ${TRACKFILE}
|
---|
| 120 | rm track.tmp
|
---|
| 121 | done
|
---|
| 122 | VERSION=$(grep 'echo.*lfs-release' $LFS_FULL |
|
---|
| 123 | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
---|
| 124 | #Debug
|
---|
| 125 | echo LFS-Release: $VERSION
|
---|
[ce244f6] | 126 | #End debug
|
---|
| 127 | xsltproc --stringparam packages $MYDIR/packages.xml \
|
---|
[e3f4b9a4] | 128 | --stringparam package LFS-Release \
|
---|
[ce244f6] | 129 | --stringparam version $VERSION \
|
---|
| 130 | -o track.tmp \
|
---|
| 131 | $MYDIR/xsl/bump.xsl ${TRACKFILE}
|
---|
| 132 | sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
|
---|
| 133 | xmllint --format --postvalid track.tmp > ${TRACKFILE}
|
---|
| 134 | rm track.tmp
|
---|
| 135 | fi
|
---|
| 136 | #Debug
|
---|
| 137 | #echo After BEG_COMMAND\; before END_COMMAND
|
---|
| 138 | #( cd $LFS_XML; LANG=C svn info )
|
---|
| 139 | #End debug
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | if [ "$DO_COMMANDS"=y ]; then
|
---|
| 143 | echo Running: $END_COMMAND
|
---|
| 144 | eval $END_COMMAND
|
---|
| 145 | fi
|
---|
| 146 |
|
---|
| 147 | #Debug
|
---|
| 148 | #echo After END_COMMAND
|
---|
| 149 | #( cd $LFS_XML; LANG=C svn info )
|
---|
| 150 | #End debug
|
---|