source: BLFS/update-lfs.sh@ 875366f

ablfs-more trunk
Last change on this file since 875366f was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100755
File size: 4.8 KB
Line 
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
24MYDIR=$( cd $(dirname $0); pwd )
25LFS_XML=${MYDIR}/lfs-xml
26
27if [ -z "$1" ]; then # use lfs-xml as is
28 DO_COMMANDS=n
29elif [ "$(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)"
36elif [ "$(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)"
41else
42 echo Bad format in $1: must be a x.y[-aaa] tag or a YYYYMMDD date
43 exit 1
44fi
45
46if [ -f $MYDIR/Makefile ]; then
47 TRACKING_DIR=$(sed -n 's/TRACKING_DIR[ ]*=[ ]*//p' $MYDIR/Makefile)
48 TRACKFILE=${TRACKING_DIR}/instpkg.xml
49else
50 echo The directory where $0 resides does not contain a Makefile
51 exit 1
52fi
53
54# We need to know the revision to generate the correct lfs-full...
55if [ ! -r $MYDIR/revision ]; then
56 echo $MYDIR/revision is not available
57 exit 1
58fi
59REVISION=$(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
66if [ "$DO_COMMANDS"=y ]; then
67 echo Running: $BEG_COMMAND
68 eval $BEG_COMMAND
69fi
70
71# Update code
72LFS_FULL=/tmp/lfs-full.xml
73echo Creating $LFS_FULL with information from $LFS_XML
74echo "Processing LFS bootscripts..."
75( cd $LFS_XML && bash process-scripts.sh )
76echo "Adjusting LFS for revision $REVISION..."
77xsltproc --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
82echo "Validating the LFS book..."
83xmllint --nonet --noent --postvalid \
84 -o $LFS_FULL /tmp/lfs-prof.xml
85rm -f $LFS_XML/appendices/*.script
86( cd $LFS_XML && ./aux-file-data.sh $LFS_FULL )
87
88echo Updating ${TRACKFILE} with information taken from $LFS_FULL
89echo -n "Is it OK? yes/no (no): "
90read ANSWER
91#Debug
92echo You answered $ANSWER
93#End debug
94
95if [ x$ANSWER = "xyes" ] ; then
96 for pack in $(grep '<productname' $LFS_FULL |
97 sed 's/.*>\([^<]*\)<.*/\1/' |
98 sort | uniq); do
99 case "x$pack" in
100 xgcc* | *pass[12] | xvim | \
101 xshadow | xPython | xlinux-headers | xdbus | xsystemd )
102 continue ;;
103 esac
104
105 VERSION=$(grep -A1 ">$pack</product" $LFS_FULL |
106 head -n2 |
107 sed -n '2s/.*>\([^<]*\)<.*/\1/p')
108#Debug
109echo $pack: $VERSION
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
123echo LFS-Release: $VERSION
124#End debug
125 xsltproc --stringparam packages $MYDIR/packages.xml \
126 --stringparam package LFS-Release \
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
133fi
134#Debug
135#echo After BEG_COMMAND\; before END_COMMAND
136#( cd $LFS_XML; LANG=C svn info )
137#End debug
138
139
140if [ "$DO_COMMANDS"=y ]; then
141 echo Running: $END_COMMAND
142 eval $END_COMMAND
143fi
144
145#Debug
146#echo After END_COMMAND
147#( cd $LFS_XML; LANG=C svn info )
148#End debug
Note: See TracBrowser for help on using the repository browser.