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