source: BLFS/blfs-parser.sh@ 1d2f9d4

experimental
Last change on this file since 1d2f9d4 was 1d2f9d4, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Added prototipe files for new BLFS module.

  • Property mode set to 100755
File size: 6.1 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
7# Configuration file for alternatives
8source alternatives.conf
9[[ $? > 0 ]] && echo -e "\n\tWARNING: alternatives.conf did not load..\n" && exit
10
11# Dependencies module
12source func_dependencies
13[[ $? > 0 ]] && echo -e "\n\tWARNING: func_dependencies did not load..\n" && exit
14
15#======= MAIN ========
16
17if [[ ! -f packages ]] ; then
18 echo -e "\tNo packages file has been found.\n"
19 echo -e "\tExecution aborted.\n"
20 exit 1
21fi
22
23# ID of target package (as listed in packages file)
24if [[ -z "$1" ]] ; then
25 echo -e "\n\tYou must to provide a package ID."
26 echo -e "\tSee packages file for a list of available targets.\n"
27 exit 1
28elif ! grep "^$1[[:space:]]" packages > /dev/null ; then
29 echo -e "\n\t$1 is not a valid package ID."
30 echo -e "\tSee packages file for a list of available targets.\n"
31 exit 1
32else
33 case $1 in
34 xorg7 )
35 TARGET=xterm2
36 echo -e "\n\tUsing $TARGET as the target package"
37 echo -e "to build the Xorg7 meta-package."
38 ;;
39 * )
40 TARGET=$1
41 echo -e "\n\tUsing $TARGET as the target package."
42 ;;
43 esac
44fi
45
46# Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
47if [[ -z "$2" ]] ; then
48 DEP_LEVEL=2
49 echo -e "\n\tNo dependencies level has been defined."
50 echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
51else
52 case $2 in
53 1 | 2 )
54 DEP_LEVEL=$2
55 echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
56 ;;
57 # Prevent circular dependencies when level 3
58 # cracklib-->python-->tk-->X-->linux-pam-->cracklib
59 # docbook-utils--> Optional dependencies are runtime only
60 # libxml2-->libxslt-->libxml2
61 # cyrus-sasl-->openldap-->cyrus-sasl
62 # alsa-lib-->doxygen-->graphviz-->jdk-->alsa-lib
63 # unixodbc-->qt-->unixodbc
64 # cups-->php-->sendmail-->espgs-->cups
65 # libexif-->graphviz-->php-->libexif
66 # esound-->aRts-->esound
67 # gimp-->imagemagick-->gimp
68 3 )
69 case $TARGET in
70 cracklib | docbook-utils | libxml2 | cyrus-sasl | alsa-lib | \
71 unixodbc | cups | libexif | esound | gimp )
72 DEP_LEVEL=2
73 echo -e "\n\t$TARGET have circular dependencies at level $2"
74 echo -e "\tUsing $DEP_LEVEL as dependencies level.\n"
75 ;;
76 * )
77 DEP_LEVEL=$2
78 echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
79 ;;
80 esac
81 ;;
82 * )
83 DEP_LEVEL=2
84 echo -e "\n\t$2 is not a valid dependencies level."
85 echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
86 ;;
87 esac
88fi
89
90# Create the working directory and cd into it
91mkdir $TARGET && cd $TARGET
92
93# XML file of the target package
94PKGXML=`grep "^$TARGET[[:space:]]" ../packages | cut -f2`
95
96# The BLFS sources directory.
97BLFS_XML=`echo $PKGXML | sed -e 's,/.*,,'`
98
99if [[ ! -d ../$BLFS_XML ]] ; then
100 echo -e "\tThe BLFS book sources directory is missing.\n"
101 echo -e "\tExecution aborted.\n"
102 cd .. && rmdir $TARGET
103 exit 1
104fi
105
106# XInclude stuff
107ENTRY_START="<xi:include xmlns:xi=\"http://www.w3.org/2003/XInclude\" href=\"../"
108ENTRY_END="\"/>"
109
110echo -en "\tGenerating $TARGET dependencies tree ..."
111
112# Create target package dependencies list
113case $TARGET in
114 # Meta-packages at target level
115 # KDE and Gnome-{core,full} could be made via packages.sh, but not sure yet how.
116 alsa ) # When target "alsa", use all alsa-* packages
117 echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n \
118 alsa-plugins\nalsa-lib" > dependencies/$TARGET.dep
119 ;;
120 * ) # Default
121 xsltproc --stringparam dependencies $DEP_LEVEL -o dependencies/$TARGET.dep \
122 ../dependencies.xsl ../$PKGXML
123 ;;
124esac
125
126# Start with a clean $TARGET-index.xml.tmp file
127> $TARGET-index.xml.tmp
128
129# Write the XInclude
130echo -e " $ENTRY_START$PKGXML$ENTRY_END" >> $TARGET-index.xml.tmp
131
132# Start with a clean depure.txt file
133> depure.txt
134
135# If have dependencies, write its XInclude and find sub-dependencies
136[[ -f dependencies/$TARGET.dep ]] && \
137echo -e "Start loop for PKG $TARGET\n" >> depure.txt && \
138mkdir xincludes && do_dependencies $TARGET
139
140echo "done"
141
142echo -en "\tGenerating $TARGET-index.xml ..."
143
144# Header to $TARGET-index.xml
145{
146cat << EOF
147<?xml version="1.0" encoding="ISO-8859-1"?>
148<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
149 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" >
150
151<book>
152
153 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/book/bookinfo.xml"/>
154
155 <preface>
156 <?dbhtml filename="preface.html" dir="preface"?>
157
158 <title>Preface</title>
159
160 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/locale-issues.xml"/>
161 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/bootscripts.xml"/>
162
163 </preface>
164
165 <chapter>
166 <?dbhtml filename="chapter.html" dir="installing"?>
167
168 <title>Installing $TARGET in Dependencies Build Order</title>
169
170EOF
171} > $TARGET-index.xml
172
173# Dump $TARGET-index.xml.tmp in reverse order.
174tac $TARGET-index.xml.tmp >> $TARGET-index.xml
175rm $TARGET-index.xml.tmp
176
177# Footer of $TARGET-index.xml
178{
179cat << EOF
180
181 </chapter>
182
183 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/creat-comm.xml"/>
184 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/ac-free-lic.xml"/>
185
186 <index/>
187
188</book>
189
190EOF
191} >> $TARGET-index.xml
192
193echo "done"
194
195echo -en "\tGenerating the HTML book ..."
196
197xsltproc --xinclude --nonet --stringparam base.dir HTML/ \
198 --stringparam chunk.quietly 1 \
199 ../$BLFS_XML/stylesheets/blfs-chunked.xsl \
200 $TARGET-index.xml > xsltproc.log 2>&1
201mkdir HTML/{stylesheets,images}
202cp ../$BLFS_XML/stylesheets/*.css HTML/stylesheets
203cp ../$BLFS_XML/images/*.png HTML/images
204cd HTML
205sed -i -e "s@../stylesheets@stylesheets@g" *.html
206sed -i -e "s@../images@images@g" *.html
207for filename in `find . -name "*.html"` ; do
208 tidy -config ../../$BLFS_XML/tidy.conf $filename || true
209 sh ../../$BLFS_XML/obfuscate.sh $filename
210 sed -i -e "s@text/html@application/xhtml+xml@g" $filename
211done
212
213echo "done"
214
215echo -en "\tGenerating the build scripts ... not implemented yet, sorry\n"
Note: See TracBrowser for help on using the repository browser.