1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id:$
|
---|
4 | #
|
---|
5 |
|
---|
6 | export outFile=aConfig.in # file for reading and writing to.
|
---|
7 | export inFile=packages # file for reading and writing to.
|
---|
8 |
|
---|
9 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
10 |
|
---|
11 | declare PKG_NAME
|
---|
12 | declare PKG_XML_FILE
|
---|
13 | declare PKG_DIR
|
---|
14 | declare SAVE_IFS=${IFS}
|
---|
15 | declare -a DIR_TREE
|
---|
16 | declare PREV_DIR1="none"
|
---|
17 | declare PREV_DIR2="none"
|
---|
18 | declare MENU_SET1="n"
|
---|
19 | declare MENU_SET2="n"
|
---|
20 |
|
---|
21 | declare PKG_VER
|
---|
22 |
|
---|
23 | get_pkg_ver() {
|
---|
24 | local this_script=$1
|
---|
25 |
|
---|
26 | # ALSA packages version
|
---|
27 | [[ ${this_script:0:4} = "alsa" ]] && this_script=alsa
|
---|
28 | # KDE packages version
|
---|
29 | [[ ${this_script:0:3} = "kde" ]] && [[ ! ${this_script} = "kdevelop" ]] && \
|
---|
30 | [[ ! ${this_script: -6} = "config" ]] && this_script=kde
|
---|
31 | # Xorg7 packages version
|
---|
32 | [[ ${this_script} = "xorg7-server" ]] && this_script=xorg-server
|
---|
33 | [[ ${this_script} = "xterm2" ]] && this_script=xterm
|
---|
34 | [[ ${this_script:0:5} = "xorg7" ]] && this_script=xorg7
|
---|
35 |
|
---|
36 | PKG_VER=$(xmllint --noent ./blfs-xml/book/bookinfo.xml 2>/dev/null | \
|
---|
37 | grep -i " ${this_script}-version " | cut -d "\"" -f2 )
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 | > $outFile
|
---|
42 |
|
---|
43 | #---------------------#
|
---|
44 | # MAIN #
|
---|
45 | #---------------------#
|
---|
46 | : <<enddoc
|
---|
47 | This script will create a Config.in file from the contents
|
---|
48 | of the file <packages>.
|
---|
49 | Packages previously installed will not be included.
|
---|
50 | enddoc
|
---|
51 |
|
---|
52 | echo -en "\tGenerating Config.in from package data ..."
|
---|
53 | while [ 0 ]
|
---|
54 | do
|
---|
55 |
|
---|
56 | # read -r || break 1
|
---|
57 | read || break 1
|
---|
58 | if [[ "${REPLY}" = "" ]] || \
|
---|
59 | [[ "${REPLY:0:1}" = "=" ]] || \
|
---|
60 | [[ "${REPLY:0:1}" = "#" ]]; then
|
---|
61 | continue
|
---|
62 | fi
|
---|
63 |
|
---|
64 | set -- $REPLY
|
---|
65 | PKG_NAME=$1
|
---|
66 | PKG_XML_FILE=$(basename $2)
|
---|
67 | PKG_DIR=$(dirname $2)
|
---|
68 | # These are the META packages. for gnome and kde (soon ALSA and Xorg7)
|
---|
69 | if [ $PKG_DIR = "." ]; then
|
---|
70 | SET_COMMENT=y
|
---|
71 | # Do not include previously installed packages....
|
---|
72 | if [ -e $TRACKING_DIR/${PKG_NAME} ]; then continue; fi
|
---|
73 |
|
---|
74 | META_PKG=$(echo ${PKG_NAME} | tr [a-z] [A-Z])
|
---|
75 | echo -e "config CONFIG_$META_PKG" >> $outFile
|
---|
76 | echo -e "\tbool \"$META_PKG\"" >> $outFile
|
---|
77 | echo -e "\tdefault n" >> $outFile
|
---|
78 |
|
---|
79 | echo -e "menu \"$(echo ${PKG_NAME} | tr [a-z] [A-Z]) components\"" >> $outFile
|
---|
80 | echo -e "\tdepends\tCONFIG_$META_PKG" >> $outFile
|
---|
81 | # Include the dependency data for this meta package
|
---|
82 | while [ 0 ]; do
|
---|
83 | read || break 1
|
---|
84 | PKG_NAME=${REPLY}
|
---|
85 | get_pkg_ver "${PKG_NAME}"
|
---|
86 | (
|
---|
87 | cat << EOF
|
---|
88 | config DEP_${META_PKG}_${PKG_NAME}
|
---|
89 | bool "$PKG_NAME ${PKG_VER}"
|
---|
90 | default y
|
---|
91 |
|
---|
92 | EOF
|
---|
93 | ) >> $outFile
|
---|
94 | done <./libs/${PKG_NAME}.dep
|
---|
95 | echo -e "endmenu" >> $outFile
|
---|
96 | continue
|
---|
97 | fi
|
---|
98 | [[ "${SET_COMMENT}" = "y" ]] && echo "comment \"\"" >>$outFile; unset SET_COMMENT
|
---|
99 |
|
---|
100 | # Deal with a few unusable chapter names
|
---|
101 | case ${PKG_NAME} in
|
---|
102 | xorg7-* ) # Deal with sub-elements of Xorg7, mandatory for build.
|
---|
103 | # No need to (even possible?) to build separately
|
---|
104 | continue
|
---|
105 | ;;
|
---|
106 | alsa-* ) continue ;;
|
---|
107 | esac
|
---|
108 |
|
---|
109 | # IF this package name-version exists in the tracking dir
|
---|
110 | # do not add this package to the list of installable pkgs.
|
---|
111 | get_pkg_ver "${PKG_NAME}"
|
---|
112 | if [ -e $TRACKING_DIR/${PKG_NAME}-${PKG_VER} ]; then continue; fi
|
---|
113 |
|
---|
114 | IFS="/"
|
---|
115 | DIR_TREE=(${PKG_DIR})
|
---|
116 | IFS="$SAVE_IFS"
|
---|
117 |
|
---|
118 | # Define a top level menu
|
---|
119 | if [ "$PREV_DIR1" != "${DIR_TREE[1]}" ]; then
|
---|
120 | [[ "${DIR_TREE[1]}" = "kde" ]] && continue
|
---|
121 | [[ "${DIR_TREE[1]}" = "gnome" ]] && continue
|
---|
122 |
|
---|
123 | if [ $MENU_SET1 = "y" ]; then
|
---|
124 | # Close out any open secondary menu
|
---|
125 | if [ $MENU_SET2 = "y" ]; then
|
---|
126 | echo -e "\tendmenu" >> $outFile
|
---|
127 | # Reset 'menu open' flag
|
---|
128 | MENU_SET2="n"
|
---|
129 | fi
|
---|
130 | # Close the current top level menu
|
---|
131 | echo -e "endmenu\n" >> $outFile
|
---|
132 | fi
|
---|
133 | # Open a new top level menu
|
---|
134 | echo -e "menu "$(echo ${DIR_TREE[1]:0:1} | tr [a-z] [A-Z])${DIR_TREE[1]:1}"" >> $outFile
|
---|
135 | MENU_SET1="y"
|
---|
136 | fi
|
---|
137 |
|
---|
138 | # Define a secondary menu
|
---|
139 | if [ "$PREV_DIR2" != "${DIR_TREE[2]}" ]; then
|
---|
140 | # Close out the previous open menu structure
|
---|
141 | if [ $MENU_SET2 = "y" ]; then
|
---|
142 | echo -e "\tendmenu\n" >> $outFile
|
---|
143 | fi
|
---|
144 | # Initialize a new 2nd level menu structure.
|
---|
145 | echo -e "\tmenu "$(echo ${DIR_TREE[2]:0:1} | tr [a-z] [A-Z])${DIR_TREE[2]:1}"" >> $outFile
|
---|
146 | MENU_SET2="y"
|
---|
147 | fi
|
---|
148 | (
|
---|
149 | cat << EOF
|
---|
150 | config CONFIG_$PKG_NAME
|
---|
151 | bool "$PKG_NAME ${PKG_VER}"
|
---|
152 | default n
|
---|
153 | EOF
|
---|
154 | ) >> $outFile
|
---|
155 |
|
---|
156 | PREV_DIR1=${DIR_TREE[1]}
|
---|
157 | PREV_DIR2=${DIR_TREE[2]}
|
---|
158 | done <"$inFile"
|
---|
159 |
|
---|
160 | if [ $MENU_SET2 = "y" ]; then echo -e "\tendmenu" >> $outFile; fi
|
---|
161 | if [ $MENU_SET1 = "y" ]; then echo "endmenu" >> $outFile; fi
|
---|
162 |
|
---|
163 | (
|
---|
164 | cat << EOF
|
---|
165 |
|
---|
166 | comment ""
|
---|
167 |
|
---|
168 | menu "Default packages for resolving dependencies"
|
---|
169 |
|
---|
170 | choice
|
---|
171 | prompt "Default print server"
|
---|
172 | config PS_cups
|
---|
173 | bool "cups"
|
---|
174 | config PS_LPRng
|
---|
175 | bool "LPRng"
|
---|
176 | endchoice
|
---|
177 | config PRINT_SERVER
|
---|
178 | string
|
---|
179 | default cups if PS_cups
|
---|
180 | default LPRng if PS_LPRng
|
---|
181 |
|
---|
182 | choice
|
---|
183 | prompt "Mail server"
|
---|
184 | config MS_sendmail
|
---|
185 | bool "sendmail"
|
---|
186 | config MS_postfix
|
---|
187 | bool "postfix"
|
---|
188 | config MS_exim
|
---|
189 | bool "exim"
|
---|
190 | endchoice
|
---|
191 | config MAIL_SERVER
|
---|
192 | string
|
---|
193 | default sendmail if MS_sendmail
|
---|
194 | default postfix if MS_postfix
|
---|
195 | default exim if MS_exim
|
---|
196 |
|
---|
197 | choice
|
---|
198 | prompt "Postscript package"
|
---|
199 | config GS_espgs
|
---|
200 | bool "espgs"
|
---|
201 | config GS_ghostscript
|
---|
202 | bool "ghostscript"
|
---|
203 | endchoice
|
---|
204 | config GHOSTSCRIPT
|
---|
205 | string
|
---|
206 | default espgs if GS_espgs
|
---|
207 | default ghostscript if GS_ghostscript
|
---|
208 |
|
---|
209 | choice
|
---|
210 | prompt "Kerberos 5"
|
---|
211 | config KER_mitkrb
|
---|
212 | bool "mitkrb"
|
---|
213 | config KER_heimdal
|
---|
214 | bool "heimdal"
|
---|
215 | endchoice
|
---|
216 | config KBR5
|
---|
217 | string
|
---|
218 | default heimdal if KER_heimdal
|
---|
219 | default mitkrb if KER_mitkrb
|
---|
220 |
|
---|
221 | choice
|
---|
222 | prompt "Window package"
|
---|
223 | config WIN_xorg7
|
---|
224 | bool "Xorg7"
|
---|
225 | config WIN_xorg
|
---|
226 | bool "Xorg"
|
---|
227 | config WIN_xfree86
|
---|
228 | bool "xfree86"
|
---|
229 | endchoice
|
---|
230 | config X11
|
---|
231 | string
|
---|
232 | default xorg7 if WIN_xorg7
|
---|
233 | default xorg if WIN_xorg
|
---|
234 | default xfree86 if WIN_xfree86
|
---|
235 | endmenu
|
---|
236 |
|
---|
237 | choice
|
---|
238 | prompt "Dependency level"
|
---|
239 | default DEPLVL_2
|
---|
240 |
|
---|
241 | config DEPLVL_1
|
---|
242 | bool "Required dependencies only"
|
---|
243 |
|
---|
244 | config DEPLVL_2
|
---|
245 | bool "Required and recommended dependencies"
|
---|
246 |
|
---|
247 | config DEPLVL_3
|
---|
248 | bool "Required, recommended and optional dependencies"
|
---|
249 |
|
---|
250 | endchoice
|
---|
251 | config optDependency
|
---|
252 | int
|
---|
253 | default 1 if DEPLVL_1
|
---|
254 | default 2 if DEPLVL_2
|
---|
255 | default 3 if DEPLVL_3
|
---|
256 |
|
---|
257 |
|
---|
258 | config SUDO
|
---|
259 | bool "Build as User"
|
---|
260 | default y
|
---|
261 | help
|
---|
262 | Select if sudo will be used (you want build as a normal user)
|
---|
263 | otherwise sudo is not needed (you want build as root)
|
---|
264 |
|
---|
265 | EOF
|
---|
266 | ) >> $outFile
|
---|
267 | echo "done"
|
---|
268 |
|
---|
269 |
|
---|