[e576789] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | #-------------------------------------------------------------------------
|
---|
| 4 | # generates an xsl stylesheet containing a template for special
|
---|
| 5 | # cases in the book:
|
---|
| 6 | # - If the version does not begin with a number, it is impossible to know
|
---|
| 7 | # where the package name ends and where the version begins. We therefore
|
---|
| 8 | # use the ENTITY at the beginning of the validated full-xml.
|
---|
| 9 | # - If a package is part of a group of xorg packages (proto, fonts, etc)
|
---|
| 10 | # there is no easy way to extract it from the xml. We use the ENTITY at
|
---|
| 11 | # the top of each file x7*.xml
|
---|
[5fb012d] | 12 | # - Some non-versioned packages are needed as dependencies of others: we
|
---|
| 13 | # attribute version 1.0.0 to them. It is just used to know if the package
|
---|
| 14 | # is installed, by checking inst-version.
|
---|
| 15 | # - If a package is versioned but the version is not mentioned in the book
|
---|
[e576789] | 16 | # (currently only udev), we retrieve the version by other means
|
---|
| 17 | #-------------------------------------------------------------------------
|
---|
| 18 | # Arguments:
|
---|
| 19 | # $1 contains the name of the validated xml book
|
---|
| 20 | # $2 contains the name of the ouput xsl file
|
---|
| 21 | # $3 contains the name of the book sources directory
|
---|
| 22 | #-------------------------------------------------------------------------
|
---|
| 23 |
|
---|
| 24 | BLFS_XML=$1
|
---|
| 25 | if ! test -f ${BLFS_XML}; then
|
---|
| 26 | echo File \`${BLFS_XML}\' does not exist
|
---|
| 27 | exit 1
|
---|
| 28 | fi
|
---|
| 29 | SPECIAL_FILE=$2
|
---|
| 30 | if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
|
---|
| 31 | BLFS_DIR=$3
|
---|
| 32 | if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi
|
---|
| 33 |
|
---|
| 34 | # Packages whose version does not begin with a number
|
---|
[4f3c433] | 35 | EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.ent |
|
---|
[e576789] | 36 | sed 's@^[^"]*"\([^"]*\)".*@\1@')
|
---|
| 37 |
|
---|
[5fb012d] | 38 | # Non-versioned packages:
|
---|
[625cb14] | 39 | NV_LIST="postlfs-config-profile postlfs-config-random postlfs-config-vimrc \
|
---|
[05f3977] | 40 | initramfs xorg-env kde-pre-install-config kf5-intro \
|
---|
[625cb14] | 41 | lxqt-pre-install lxqt-post-install ojdk-conf tex-path"
|
---|
[5fb012d] | 42 |
|
---|
[e576789] | 43 | cat >$SPECIAL_FILE << EOF
|
---|
| 44 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 45 |
|
---|
| 46 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
| 47 | version="1.0">
|
---|
| 48 |
|
---|
| 49 | <xsl:template match='*' mode="special">
|
---|
| 50 | <xsl:choose>
|
---|
[82bd7a6] | 51 | <!-- Although versioned, this page is not a package. But
|
---|
| 52 | the sect2 with id "xorg-env" is referred to at several
|
---|
| 53 | places in the book. We have added it to the list of non
|
---|
| 54 | versioned packages. -->
|
---|
| 55 | <xsl:when test="@id='xorg7'">
|
---|
| 56 | <xsl:apply-templates select="child::sect2" mode="special"/>
|
---|
| 57 | </xsl:when>
|
---|
[e576789] | 58 | EOF
|
---|
| 59 |
|
---|
[5fb012d] | 60 | # Non-versionned packages. Add to NV_LIST if you need more.
|
---|
| 61 | for nv_id in $NV_LIST; do
|
---|
[280cff6a] | 62 | # Actually, kf5-intro contains some version info, so should be
|
---|
| 63 | # versioned. For other packages, we define version to 1.0.0
|
---|
| 64 | # because the DTD needs a version tag.
|
---|
| 65 | DUM_VER=1.0.0
|
---|
| 66 | if [ $nv_id = kf5-intro ]; then
|
---|
| 67 | DUM_VER=$(grep kf5-version $BLFS_DIR/packages.ent | \
|
---|
[0f7a988] | 68 | sed 's/[^"]*"\([^"]*\).*/\1/')
|
---|
[280cff6a] | 69 | fi
|
---|
[5fb012d] | 70 | cat >>$SPECIAL_FILE << EOF
|
---|
| 71 | <xsl:when test="@id='$nv_id'">
|
---|
| 72 | <xsl:text> </xsl:text>
|
---|
| 73 | <package><xsl:text>
 </xsl:text>
|
---|
| 74 | <xsl:element name="name">$nv_id</xsl:element>
|
---|
| 75 | <xsl:text>
 </xsl:text>
|
---|
[280cff6a] | 76 | <xsl:element name="version">$DUM_VER</xsl:element>
|
---|
[5fb012d] | 77 | <xsl:if
|
---|
| 78 | test="document(\$installed-packages)//package[name=current()/@id]">
|
---|
| 79 | <xsl:text>
 </xsl:text>
|
---|
| 80 | <xsl:element name="inst-version">
|
---|
| 81 | <xsl:value-of
|
---|
| 82 | select="document(\$installed-packages
|
---|
| 83 | )//package[name=current()/@id]/version"/>
|
---|
| 84 | </xsl:element>
|
---|
| 85 | </xsl:if>
|
---|
| 86 | <!-- Dependencies -->
|
---|
| 87 | <xsl:apply-templates select=".//para[@role='required' or
|
---|
| 88 | @role='recommended' or
|
---|
| 89 | @role='optional']"
|
---|
| 90 | mode="dependency"/>
|
---|
| 91 | <!-- End dependencies -->
|
---|
| 92 | <xsl:text>
 </xsl:text>
|
---|
| 93 | </package><xsl:text>
</xsl:text>
|
---|
| 94 | </xsl:when>
|
---|
| 95 | EOF
|
---|
| 96 | done
|
---|
| 97 |
|
---|
[e6a1ec3] | 98 | # Taking packages contained in pages installing several packages (x7* except
|
---|
| 99 | # x7driver, kf5-frameworks, and plasma5-all), as versionned modules.
|
---|
[e576789] | 100 | # We also write a dependency expansion when a dep is of the form
|
---|
[e6a1ec3] | 101 | # xorg7-something or kf5-frameworks or plasma5-build. Since that is another
|
---|
| 102 | # template, we need a temporary file, which we shall concatenate at the end
|
---|
[e576789] | 103 | cat >tmpfile << EOF
|
---|
| 104 | <xsl:template name="expand-deps">
|
---|
| 105 | <xsl:param name="section"/>
|
---|
| 106 | <xsl:param name="status"/>
|
---|
[7a0c3d2] | 107 | <xsl:param name="build"/>
|
---|
[e576789] | 108 | <xsl:choose>
|
---|
| 109 | EOF
|
---|
[0cd09c6] | 110 | for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver) \
|
---|
| 111 | ${BLFS_DIR}/kde/kf5/kf5-frameworks.xml \
|
---|
| 112 | ${BLFS_DIR}/kde/plasma5/plasma-all.xml; do
|
---|
[e576789] | 113 | id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@')
|
---|
| 114 | cat >>$SPECIAL_FILE << EOF
|
---|
| 115 | <xsl:when test="@id='$id'">
|
---|
| 116 | <xsl:text> </xsl:text>
|
---|
| 117 | <package><xsl:text>
 </xsl:text>
|
---|
| 118 | <xsl:element name="name">$id</xsl:element>
|
---|
| 119 | <xsl:text>
 </xsl:text>
|
---|
| 120 | EOF
|
---|
| 121 | cat >> tmpfile << EOF
|
---|
| 122 | <xsl:when test="\$section='$id'">
|
---|
| 123 | EOF
|
---|
[e6a1ec3] | 124 | # We extract the list of packages for those pages from
|
---|
| 125 | # the "cat" command that creates the md5 file. We assume
|
---|
[e576789] | 126 | # that the preceding package is a dependency of the following,
|
---|
| 127 | # except the first.
|
---|
[e6a1ec3] | 128 | # note that some pages may have several "cat" command, so we have to
|
---|
| 129 | # make a complex regex for the first line to save. All those lines have
|
---|
| 130 | # .md5 in them except the one for x7legacy that has .dat.
|
---|
| 131 | # we need also to remove lines beginning with #.
|
---|
| 132 | # Note that only xorg pages have '&' in them. So for kde
|
---|
| 133 | # pages, what is extracted it the full tarball name.
|
---|
[3439ff6] | 134 | list_cat="$(sed -n '/>cat.*\.\(md5\|dat\)/,/EOF</p' $file | \
|
---|
| 135 | grep -v '>cat\|EOF<\|#' | \
|
---|
| 136 | awk '{ print $NF }' | sed 's/-&.*//')"
|
---|
[e576789] | 137 |
|
---|
[0cd09c6] | 138 | precpack=NONE
|
---|
| 139 | for pack in $list_cat; do
|
---|
| 140 | if grep -q x7 $file; then # this is an xorg package
|
---|
| 141 | packname=$pack
|
---|
[e6a1ec3] | 142 | # We extract the version from the ENTITY parts of the .xml file.
|
---|
[0cd09c6] | 143 | packversion=$(grep "ENTITY ${pack}-version" $file | \
|
---|
| 144 | sed 's@[^"]*"\([^"]*\).*@\1@')
|
---|
| 145 | else
|
---|
[e6a1ec3] | 146 | packname=${pack%-[[:digit:]]*}
|
---|
[0cd09c6] | 147 | packversion=$(echo $pack | sed 's/[^.]*-\([.[:digit:]]*\)\.tar.*/\1/')
|
---|
| 148 | fi
|
---|
[e576789] | 149 | cat >>$SPECIAL_FILE << EOF
|
---|
| 150 | <module><xsl:text>
 </xsl:text>
|
---|
| 151 | <xsl:element name="name">$packname</xsl:element>
|
---|
| 152 | <xsl:element name="version">$packversion</xsl:element>
|
---|
| 153 | <xsl:if test="document(\$installed-packages)//package[name='$packname']">
|
---|
| 154 | <xsl:element name="inst-version">
|
---|
| 155 | <xsl:value-of
|
---|
| 156 | select="document(\$installed-packages
|
---|
| 157 | )//package[name='$packname']/version"/>
|
---|
| 158 | </xsl:element>
|
---|
| 159 | </xsl:if>
|
---|
| 160 | <!-- Dependencies -->
|
---|
| 161 | EOF
|
---|
| 162 | if test $precpack != NONE; then
|
---|
| 163 | cat >>$SPECIAL_FILE << EOF
|
---|
| 164 | <xsl:element name="dependency">
|
---|
| 165 | <xsl:attribute name="status">required</xsl:attribute>
|
---|
[7a0c3d2] | 166 | <xsl:attribute name="build">before</xsl:attribute>
|
---|
[e576789] | 167 | <xsl:attribute name="name">$precpack</xsl:attribute>
|
---|
| 168 | <xsl:attribute name="type">ref</xsl:attribute>
|
---|
| 169 | </xsl:element>
|
---|
| 170 | EOF
|
---|
| 171 | else
|
---|
| 172 | cat >>$SPECIAL_FILE << EOF
|
---|
| 173 | <xsl:apply-templates select=".//para[@role='required' or
|
---|
| 174 | @role='recommended' or
|
---|
| 175 | @role='optional']"
|
---|
| 176 | mode="dependency"/>
|
---|
| 177 | EOF
|
---|
| 178 | fi
|
---|
| 179 | cat >>$SPECIAL_FILE << EOF
|
---|
| 180 | <!-- End dependencies -->
|
---|
| 181 | </module>
|
---|
| 182 | EOF
|
---|
[5ed69f8] | 183 | # cat >> tmpfile << EOF
|
---|
| 184 | # <xsl:element name="dependency">
|
---|
| 185 | # <xsl:attribute name="status">
|
---|
| 186 | # <xsl:value-of select="\$status"/>
|
---|
| 187 | # </xsl:attribute>
|
---|
| 188 | # <xsl:attribute name="build">
|
---|
| 189 | # <xsl:value-of select="\$build"/>
|
---|
| 190 | # </xsl:attribute>
|
---|
| 191 | # <xsl:attribute name="name">$packname</xsl:attribute>
|
---|
| 192 | # <xsl:attribute name="type">ref</xsl:attribute>
|
---|
| 193 | # </xsl:element>
|
---|
| 194 | #EOF
|
---|
| 195 | precpack=$packname
|
---|
| 196 | done
|
---|
[f6420b0] | 197 | # We need a dummy package for plasma post install instructions
|
---|
| 198 | if [ $(basename $file .xml) = plasma-all ]; then
|
---|
| 199 | cat >>$SPECIAL_FILE << EOF
|
---|
| 200 | <module><xsl:text>
 </xsl:text>
|
---|
| 201 | <xsl:element name="name">plasma-post-install</xsl:element>
|
---|
| 202 | <xsl:element name="version">1.0.0</xsl:element>
|
---|
[e6efe4c9] | 203 | <xsl:if test="document(\$installed-packages)//package[name='plasma-post-install']">
|
---|
[f6420b0] | 204 | <xsl:element name="inst-version">
|
---|
| 205 | <xsl:value-of
|
---|
| 206 | select="document(\$installed-packages
|
---|
[e6efe4c9] | 207 | )//package[name='plasma-post-install']/version"/>
|
---|
[f6420b0] | 208 | </xsl:element>
|
---|
| 209 | </xsl:if>
|
---|
| 210 | <!-- Dependencies -->
|
---|
| 211 | <xsl:element name="dependency">
|
---|
| 212 | <xsl:attribute name="status">required</xsl:attribute>
|
---|
| 213 | <xsl:attribute name="build">before</xsl:attribute>
|
---|
| 214 | <xsl:attribute name="name">$precpack</xsl:attribute>
|
---|
| 215 | <xsl:attribute name="type">ref</xsl:attribute>
|
---|
| 216 | </xsl:element>
|
---|
| 217 | <!-- End dependencies -->
|
---|
| 218 | </module>
|
---|
| 219 | EOF
|
---|
| 220 | fi
|
---|
| 221 |
|
---|
[5ed69f8] | 222 | cat >>$SPECIAL_FILE << EOF
|
---|
| 223 | </package>
|
---|
| 224 | </xsl:when>
|
---|
| 225 | EOF
|
---|
| 226 | cat >> tmpfile << EOF
|
---|
[e576789] | 227 | <xsl:element name="dependency">
|
---|
| 228 | <xsl:attribute name="status">
|
---|
| 229 | <xsl:value-of select="\$status"/>
|
---|
| 230 | </xsl:attribute>
|
---|
[7a0c3d2] | 231 | <xsl:attribute name="build">
|
---|
| 232 | <xsl:value-of select="\$build"/>
|
---|
| 233 | </xsl:attribute>
|
---|
[e576789] | 234 | <xsl:attribute name="name">$packname</xsl:attribute>
|
---|
| 235 | <xsl:attribute name="type">ref</xsl:attribute>
|
---|
| 236 | </xsl:element>
|
---|
| 237 | </xsl:when>
|
---|
| 238 | EOF
|
---|
| 239 | done
|
---|
| 240 |
|
---|
| 241 | for ver_ent in $EXCEPTIONS; do
|
---|
| 242 | id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
|
---|
| 243 | [[ -z $id ]] && continue
|
---|
| 244 | cat >>$SPECIAL_FILE << EOF
|
---|
| 245 | <xsl:when test="@id='$id'">
|
---|
[1646303] | 246 | <!-- if there is a sect1 ancestor, we have a module -->
|
---|
| 247 | <xsl:choose>
|
---|
| 248 | <xsl:when test="ancestor::sect1">
|
---|
| 249 | <xsl:text> </xsl:text>
|
---|
| 250 | <module><xsl:text>
 </xsl:text>
|
---|
| 251 | <xsl:element name="name">$id</xsl:element>
|
---|
| 252 | <xsl:text>
 </xsl:text>
|
---|
| 253 | <xsl:element name="version">$ver_ent</xsl:element>
|
---|
| 254 | <xsl:if
|
---|
| 255 | test="document(\$installed-packages)//package[name=current()/@id]">
|
---|
| 256 | <xsl:text>
 </xsl:text>
|
---|
| 257 | <xsl:element name="inst-version">
|
---|
| 258 | <xsl:value-of
|
---|
| 259 | select="document(\$installed-packages
|
---|
| 260 | )//package[name=current()/@id]/version"/>
|
---|
| 261 | </xsl:element>
|
---|
| 262 | </xsl:if>
|
---|
[e576789] | 263 | <!-- Dependencies -->
|
---|
[1646303] | 264 | <xsl:apply-templates select=".//para[@role='required' or
|
---|
| 265 | @role='recommended' or
|
---|
| 266 | @role='optional']"
|
---|
| 267 | mode="dependency"/>
|
---|
[e576789] | 268 | <!-- End dependencies -->
|
---|
[1646303] | 269 | <xsl:text>
 </xsl:text>
|
---|
| 270 | </module><xsl:text>
</xsl:text>
|
---|
| 271 | </xsl:when>
|
---|
| 272 | <xsl:otherwise>
|
---|
| 273 | <xsl:text> </xsl:text>
|
---|
| 274 | <package><xsl:text>
 </xsl:text>
|
---|
| 275 | <xsl:element name="name">$id</xsl:element>
|
---|
| 276 | <xsl:text>
 </xsl:text>
|
---|
| 277 | <xsl:element name="version">$ver_ent</xsl:element>
|
---|
| 278 | <xsl:if
|
---|
| 279 | test="document(\$installed-packages)//package[name=current()/@id]">
|
---|
| 280 | <xsl:text>
 </xsl:text>
|
---|
| 281 | <xsl:element name="inst-version">
|
---|
| 282 | <xsl:value-of
|
---|
| 283 | select="document(\$installed-packages
|
---|
| 284 | )//package[name=current()/@id]/version"/>
|
---|
| 285 | </xsl:element>
|
---|
| 286 | </xsl:if>
|
---|
| 287 | <!-- Dependencies -->
|
---|
| 288 | <xsl:apply-templates select=".//para[@role='required' or
|
---|
| 289 | @role='recommended' or
|
---|
| 290 | @role='optional']"
|
---|
| 291 | mode="dependency"/>
|
---|
| 292 | <!-- End dependencies -->
|
---|
| 293 | <xsl:text>
 </xsl:text>
|
---|
| 294 | </package><xsl:text>
</xsl:text>
|
---|
| 295 | </xsl:otherwise>
|
---|
| 296 | </xsl:choose>
|
---|
[e576789] | 297 | </xsl:when>
|
---|
| 298 | EOF
|
---|
| 299 | done
|
---|
| 300 |
|
---|
| 301 | cat >>$SPECIAL_FILE << EOF
|
---|
| 302 | <xsl:otherwise>
|
---|
| 303 | <xsl:apply-templates
|
---|
| 304 | select="self::node()[contains(translate(@xreflabel,
|
---|
| 305 | '123456789',
|
---|
| 306 | '000000000'),
|
---|
| 307 | '-0')
|
---|
| 308 | ]"
|
---|
| 309 | mode="normal"/>
|
---|
| 310 | </xsl:otherwise>
|
---|
| 311 | </xsl:choose>
|
---|
| 312 | </xsl:template>
|
---|
| 313 | EOF
|
---|
| 314 | cat $SPECIAL_FILE tmpfile > tmpfile1
|
---|
| 315 | mv tmpfile1 $SPECIAL_FILE
|
---|
| 316 | rm tmpfile
|
---|
| 317 | cat >> $SPECIAL_FILE << EOF
|
---|
| 318 | <xsl:otherwise>
|
---|
| 319 | <xsl:message>
|
---|
| 320 | <xsl:text>You should not be seeing this</xsl:text>
|
---|
| 321 | </xsl:message>
|
---|
| 322 | </xsl:otherwise>
|
---|
| 323 | </xsl:choose>
|
---|
| 324 | </xsl:template>
|
---|
| 325 | </xsl:stylesheet>
|
---|
| 326 | EOF
|
---|