source: BLFS/update-lfs.sh@ 5c69841

ablfs-more legacy trunk
Last change on this file since 5c69841 was ee68aee, checked in by Pierre Labastie <pierre@…>, 7 years ago

Make BLFS/update-lfs.sh executable

  • Property mode set to 100755
File size: 4.7 KB
Line 
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
26MYDIR=$( cd $(dirname $0); pwd )
27LFS_XML=${MYDIR}/lfs-xml
28
29if [ -z "$1" ]; then # use lfs-xml as is
30 DO_COMMANDS=n
31elif [ "$(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)"
38elif [ "$(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)"
43else
44 echo Bad format in $1: must be a x.y[-aaa] tag or a YYYYMMDD date
45 exit 1
46fi
47
48if [ -f $MYDIR/Makefile ]; then
49 TRACKING_DIR=$(sed -n 's/TRACKING_DIR[ ]*=[ ]*//p' $MYDIR/Makefile)
50 TRACKFILE=${TRACKING_DIR}/instpkg.xml
51else
52 echo The directory where $0 resides does not contain a Makefile
53 exit 1
54fi
55
56# We need to know the revision to generate the correct lfs-full...
57if [ ! -r $MYDIR/revision ]; then
58 echo $MYDIR/revision is not available
59 exit 1
60fi
61REVISION=$(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
68if [ "$DO_COMMANDS"=y ]; then
69 echo Running: $BEG_COMMAND
70 eval $BEG_COMMAND
71fi
72
73# Update code
74LFS_FULL=/tmp/lfs-full.xml
75echo Creating $LFS_FULL with information from $LFS_XML
76echo "Processing LFS bootscripts..."
77( cd $LFS_XML && bash process-scripts.sh )
78echo "Adjusting LFS for revision $REVISION..."
79xsltproc --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
84echo "Validating the LFS book..."
85xmllint --nonet --noent --postvalid \
86 -o $LFS_FULL /tmp/lfs-prof.xml
87rm -f $LFS_XML/appendices/*.script
88( cd $LFS_XML && ./aux-file-data.sh $LFS_FULL )
89
90echo Updating ${TRACKFILE} with information taken from $LFS_FULL
91echo -n "Is it OK? yes/no (no): "
92read ANSWER
93#Debug
94echo You answered $ANSWER
95#End debug
96
97if [ 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
106echo $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 VERSION=$(grep 'echo.*lfs-release' $LFS_FULL |
118 sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
119#Debug
120echo LFS-Release: $VERSION
121#End debug
122 xsltproc --stringparam packages $MYDIR/packages.xml \
123 --stringparam package LFS-Release \
124 --stringparam version $VERSION \
125 -o track.tmp \
126 $MYDIR/xsl/bump.xsl ${TRACKFILE}
127 sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
128 xmllint --format --postvalid track.tmp > ${TRACKFILE}
129 rm track.tmp
130fi
131#Debug
132#echo After BEG_COMMAND\; before END_COMMAND
133#( cd $LFS_XML; LANG=C svn info )
134#End debug
135
136
137if [ "$DO_COMMANDS"=y ]; then
138 echo Running: $END_COMMAND
139 eval $END_COMMAND
140fi
141
142#Debug
143#echo After END_COMMAND
144#( cd $LFS_XML; LANG=C svn info )
145#End debug
Note: See TracBrowser for help on using the repository browser.