1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id:$
|
---|
4 | #
|
---|
5 |
|
---|
6 | export outFile=aConfig.in # file for reading and writing to.
|
---|
7 | export inFile=packages.sorted # 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 | 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 | sort packages -b --key=2 --field-separator=/ --output=packages.sorted
|
---|
32 |
|
---|
33 | > $outFile
|
---|
34 |
|
---|
35 | #---------------------#
|
---|
36 | # MAIN #
|
---|
37 | #---------------------#
|
---|
38 | : <<enddoc
|
---|
39 | This script will create a Config.in file from the contents
|
---|
40 | of the file <packages>.
|
---|
41 | Packages previously installed will not be included.
|
---|
42 | enddoc
|
---|
43 |
|
---|
44 | while [ 0 ]
|
---|
45 | do
|
---|
46 |
|
---|
47 | # read -r || break 1
|
---|
48 | read || break 1
|
---|
49 | if [[ "${REPLY}" = "" ]] || \
|
---|
50 | [[ "${REPLY:0:1}" = "=" ]] || \
|
---|
51 | [[ "${REPLY:0:1}" = "#" ]]; then
|
---|
52 | continue
|
---|
53 | fi
|
---|
54 |
|
---|
55 | set -- $REPLY
|
---|
56 | PKG_NAME=$1
|
---|
57 | PKG_XML_FILE=$(basename $2)
|
---|
58 | PKG_DIR=$(dirname $2)
|
---|
59 | if [ $PKG_DIR = "." ]; then
|
---|
60 | if [ -e $TRACKING_DIR/${PKG_NAME} ]; then continue; fi
|
---|
61 | PKG_NAME=$(echo ${PKG_NAME} | tr [a-z] [A-Z])
|
---|
62 | echo -e "config CONFIG_$PKG_NAME" >> $outFile
|
---|
63 | echo -e "\tbool \"$PKG_NAME\"" >> $outFile
|
---|
64 | echo -e "\tdefault n" >> $outFile
|
---|
65 | continue
|
---|
66 | fi
|
---|
67 |
|
---|
68 | # Deal with a few unusable chapter names
|
---|
69 | case ${PKG_NAME} in
|
---|
70 | other-* | others-* ) continue
|
---|
71 | ;;
|
---|
72 | xorg7-* ) # Deal with sub-elements of Xorg7, mandatory for build.
|
---|
73 | # No need to (even possible?) to build separately
|
---|
74 | continue
|
---|
75 | ;;
|
---|
76 | esac
|
---|
77 |
|
---|
78 | # IF this package name-version exists in the tracking dir
|
---|
79 | # do not add this package to the list of installable pkgs.
|
---|
80 | get_pkg_ver "${PKG_NAME}"
|
---|
81 | if [ -e $TRACKING_DIR/${PKG_NAME}-${PKG_VER} ]; then continue; fi
|
---|
82 |
|
---|
83 | IFS="/"
|
---|
84 | DIR_TREE=(${PKG_DIR})
|
---|
85 | IFS="$SAVE_IFS"
|
---|
86 |
|
---|
87 | # Define a top level menu
|
---|
88 | if [ "$PREV_DIR1" != "${DIR_TREE[1]}" ]; then
|
---|
89 | if [ $MENU_SET1 = "y" ]; then
|
---|
90 | # Close out any open secondary menu
|
---|
91 | if [ $MENU_SET2 = "y" ]; then
|
---|
92 | echo -e "\tendmenu" >> $outFile
|
---|
93 | # Reset 'menu open' flag
|
---|
94 | MENU_SET2="n"
|
---|
95 | fi
|
---|
96 | # Close the current top level menu
|
---|
97 | echo -e "endmenu\n" >> $outFile
|
---|
98 | fi
|
---|
99 | # Open a new top level menu
|
---|
100 | echo -e "menu "$(echo ${DIR_TREE[1]:0:1} | tr [a-z] [A-Z])${DIR_TREE[1]:1}"" >> $outFile
|
---|
101 | MENU_SET1="y"
|
---|
102 | fi
|
---|
103 |
|
---|
104 | # Define a secondary menu
|
---|
105 | if [ "$PREV_DIR2" != "${DIR_TREE[2]}" ]; then
|
---|
106 | # Close out the previous open menu structure
|
---|
107 | if [ $MENU_SET2 = "y" ]; then
|
---|
108 | echo -e "\tendmenu\n" >> $outFile
|
---|
109 | fi
|
---|
110 | # Initialize a new 2nd level menu structure.
|
---|
111 | echo -e "\tmenu "$(echo ${DIR_TREE[2]:0:1} | tr [a-z] [A-Z])${DIR_TREE[2]:1}"" >> $outFile
|
---|
112 | MENU_SET2="y"
|
---|
113 | fi
|
---|
114 | (
|
---|
115 | cat << EOF
|
---|
116 | config CONFIG_$PKG_NAME
|
---|
117 | bool "$PKG_NAME ${PKG_VER}"
|
---|
118 | default n
|
---|
119 | EOF
|
---|
120 | ) >> $outFile
|
---|
121 |
|
---|
122 | PREV_DIR1=${DIR_TREE[1]}
|
---|
123 | PREV_DIR2=${DIR_TREE[2]}
|
---|
124 | done <"$inFile"
|
---|
125 |
|
---|
126 | if [ $MENU_SET2 = "y" ]; then echo -e "\tendmenu" >> $outFile; fi
|
---|
127 | if [ $MENU_SET1 = "y" ]; then echo "endmenu" >> $outFile; fi
|
---|
128 |
|
---|
129 | (
|
---|
130 | cat << EOF
|
---|
131 | comment "Default packages for resolving dependencies"
|
---|
132 |
|
---|
133 | choice
|
---|
134 | prompt "Default print server"
|
---|
135 | config PS_cups
|
---|
136 | bool "cups"
|
---|
137 | config PS_LPRng
|
---|
138 | bool "LPRng"
|
---|
139 | endchoice
|
---|
140 | config PRINT_SERVER
|
---|
141 | string
|
---|
142 | default cups if PS_cups
|
---|
143 | default LPRng if PS_LPRng
|
---|
144 | choice
|
---|
145 | prompt "Mail server"
|
---|
146 | config MS_sendmail
|
---|
147 | bool "sendmail'
|
---|
148 | config MS_postfix
|
---|
149 | bool "postfix"
|
---|
150 | config MS_exim"
|
---|
151 | bool "exim"
|
---|
152 | endchoice
|
---|
153 | config MAIL_SERVER
|
---|
154 | string
|
---|
155 | default sendmail if MS_sendmail
|
---|
156 | default postfix if MS_postfix
|
---|
157 | default exim if MS_exim
|
---|
158 |
|
---|
159 | choice
|
---|
160 | prompt "Postscript package"
|
---|
161 | config GS_espgs
|
---|
162 | bool "espgs"
|
---|
163 | config GS_ghostscript
|
---|
164 | bool "ghostscript"
|
---|
165 | endchoice
|
---|
166 | config GHOSTSCRIPT
|
---|
167 | string
|
---|
168 | default espgs if GS_espgs
|
---|
169 | default ghostscript if GS_ghostscript
|
---|
170 |
|
---|
171 | choice
|
---|
172 | prompt "Kerberos 5"
|
---|
173 | config KER_mitkrv
|
---|
174 | bool "mitkrb"
|
---|
175 | config KER_heimdal
|
---|
176 | bool "heimdal"
|
---|
177 | endchoice
|
---|
178 | config KBR5
|
---|
179 | string
|
---|
180 | default heimdal if KER_heimdal
|
---|
181 | default mitkrb if KER_mitkrb
|
---|
182 |
|
---|
183 | choice
|
---|
184 | prompt "Window package
|
---|
185 | config WIN_xorg7
|
---|
186 | bool "Xorg7"
|
---|
187 | config WIN_xorg
|
---|
188 | bool "Xorg"
|
---|
189 | config WIN_xfree86
|
---|
190 | bool "xfree86"
|
---|
191 | endchoice
|
---|
192 | config X11
|
---|
193 | string
|
---|
194 | default xorg7 if WIN_xorg7
|
---|
195 | default xorg if WIN_xorg
|
---|
196 | default xfree86 if WIN_xfree86
|
---|
197 |
|
---|
198 | comment "--"
|
---|
199 |
|
---|
200 | choice
|
---|
201 | prompt "Select dependency level"
|
---|
202 | default DEP_2
|
---|
203 |
|
---|
204 | config DEP_1
|
---|
205 | bool "Required dependencies only"
|
---|
206 |
|
---|
207 | config DEP_2
|
---|
208 | bool "Required and recommended dependencies"
|
---|
209 |
|
---|
210 | config DEP_3
|
---|
211 | bool "Required, recommended and optional dependencies"
|
---|
212 |
|
---|
213 | endchoice
|
---|
214 |
|
---|
215 | config optDependency
|
---|
216 | int
|
---|
217 | default 1 if DEP_1
|
---|
218 | default 2 if DEP_2
|
---|
219 | default 3 if DEP_3
|
---|
220 |
|
---|
221 |
|
---|
222 | config SUDO
|
---|
223 | bool "Build as User"
|
---|
224 | default y
|
---|
225 | help
|
---|
226 | Select if sudo will be used (you want build as a normal user)
|
---|
227 | otherwise sudo is not needed (you want build as root)
|
---|
228 |
|
---|
229 | EOF
|
---|
230 | ) >> $outFile
|
---|
231 |
|
---|
232 |
|
---|
233 |
|
---|