source: BLFS/gen_pkg_book.sh@ fb6913a

experimental
Last change on this file since fb6913a was fb6913a, checked in by George Boudreau <georgeb@…>, 18 years ago

Repackage internal code into functions. (readability). Made cntr a local var as it was interfering with a trace

  • Property mode set to 100755
File size: 3.4 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
9declare -r ConfigFile="configuration"
10declare TARGET
11declare DEP_LEVEL
12declare SUDO
13declare PKGXML
14declare BLFS_XML
15declare VERBOSITY=1
16
17#--------------------------#
18parse_configuration() { #
19#--------------------------#
20 local cntr
21 local optTARGET
22
23 while [ 0 ]; do
24 read || break 1
25
26 # Garbage collection
27 case ${REPLY} in
28 \#* | '') continue ;;
29 esac
30
31 case "${REPLY}" in
32 CONFIG_ALSA=* | \
33 CONFIG_GNOME-CORE=* | \
34 CONFIG_GNOME-FULL=* | \
35 CONFIG_KDE-CORE=* | \
36 CONFIG_KDE-FULL=* | \
37 CONFIG_KDE-KOFFICE=* | \
38 CONFIG_XORG7=* ) REPLY=${REPLY%=*} # Strip the trailing '=y' test.. unecessary
39 echo -n "${REPLY}"
40 if [[ $((++cntr)) > 1 ]]; then
41 echo " <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
42 else
43 echo ""
44 optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
45 fi
46 continue ;;
47
48 # Create global variables for these parameters.
49 optDependency=* | \
50 PRINT_SERVER=* | \
51 MAIL_SERVER=* | \
52 GHOSTSCRIPT=* | \
53 KBR5=* | \
54 X11=* | \
55 SUDO=* ) eval ${REPLY} # Define/set a global variable..
56 continue ;;
57 esac
58
59 if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
60 echo -n "$REPLY"
61 if [[ $((++cntr)) > 1 ]]; then
62 echo " <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
63 else
64 echo ""
65 optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
66 fi
67 fi
68 done <$ConfigFile
69
70 if [[ $optTARGET = "" ]]; then
71 echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
72 echo -e " Run <make> again and select a package to build\n"
73 exit 0
74 fi
75
76 TARGET=$optTARGET
77 DEP_LEVEL=$optDependency
78 SUDO=${SUDO:-y}
79}
80
81
82#
83# Regenerate the META-package dependencies from the configuration file
84#
85#--------------------------#
86regenerate_deps() { #
87#--------------------------#
88
89 rm -f libs/*.dep-MOD
90 while [ 0 ]; do
91 read || break 1
92 case ${REPLY} in
93 \#* | '') continue ;;
94 esac
95
96 # Drop the "=y"
97 REPLY=${REPLY%=*}
98 if [[ "${REPLY}" =~ "^DEP_" ]]; then
99 META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
100 DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
101 echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
102 fi
103
104 done <$ConfigFile
105 #
106 # Replace to 'old' dependency file with a new one.
107 #
108 for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
109 cp -vf $dst ${dst%-MOD}
110 done
111}
112
113
114#---------------------
115# Constants
116source libs/constants.inc
117[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
118
119#---------------------
120# Dependencies module
121source libs/func_dependencies
122[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
123
124#---------------------
125# parser module
126source libs/func_parser
127[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
128
129
130#------- MAIN --------
131if [[ ! -f packages ]] ; then
132 echo -e "\tNo packages file has been found.\n"
133 echo -e "\tExecution aborted.\n"
134 exit 1
135fi
136
137
138parse_configuration
139regenerate_deps
140generate_dependency_tree
141generate_TARGET_xml
142generate_target_book
143create_build_scripts "${SUDO}"
Note: See TracBrowser for help on using the repository browser.