source: BLFS/gen_config.sh@ ee8dc26

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

Sort BLFS packages file by XML filename.

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