source: BLFS/blfs-parser.sh@ 3d1e5a7

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

Missed the inclusion of func_parser code

  • Property mode set to 100755
File size: 3.9 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6declare TARGET
7declare DEP_LEVEL
8declare PKGXML
9declare BLFS_XML
10declare VERBOSITY=1
11
12# Grab and name the command line options
13 optTARGET=$1
14optDEPENDENCY=$2
15
16
17#---------------------
18# Constants
19source constants.inc
20[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
21
22#---------------------
23# Configuration file for alternatives
24source alternatives.conf
25[[ $? > 0 ]] && echo -e "\n\tERROR: alternatives.conf did not load..\n" && exit
26
27#---------------------
28# Dependencies module
29source func_dependencies
30[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
31
32#---------------------
33# parser module
34source func_parser
35[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
36
37
38
39#-------------------------#
40validate_target() { # ID of target package (as listed in packages file)
41#-------------------------#
42: <<inline_doc
43 function: Validate the TARGET parameter.
44 input vars: $1, package/target to validate
45 externals: file: packages
46 modifies: TARGET
47 returns: nothing
48 output: nothing
49 on error: exit
50 on success: modifies TARGET
51inline_doc
52
53 if [[ -z "$1" ]] ; then
54 echo -e "\n\tYou must to provide a package ID."
55 echo -e "\tSee packages file for a list of available targets.\n"
56 exit 1
57 fi
58
59 if ! grep "^$1[[:space:]]" packages > /dev/null ; then
60 echo -e "\n\t$1 is not a valid package ID."
61 echo -e "\tSee packages file for a list of available targets.\n"
62 exit 1
63 fi
64
65 case $1 in
66 xorg7 )
67 TARGET=xterm2
68 echo -e "\n\tUsing $TARGET as the target package"
69 echo -e "to build the Xorg7 meta-package."
70 ;;
71 * )
72 TARGET=$1
73 echo -e "\n\tUsing $TARGET as the target package."
74 ;;
75 esac
76}
77
78#-------------------------#
79validate_dependency() { # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
80#-------------------------#
81: <<inline_doc
82 function: Validate the dependency level requested.
83 input vars: $1, requested dependency level
84 externals: vars: TARGET
85 modifies: vars: DEP_LEVEL
86 returns: nothing
87 output: nothing
88 on error: nothing
89 on success: modifies DEP_LEVEL, default value = 2
90inline_doc
91
92 if [[ -z "$1" ]] ; then
93 DEP_LEVEL=2
94 echo -e "\n\tNo dependencies level has been defined."
95 echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
96 return
97 fi
98
99 case $1 in
100 1 | 2 )
101 DEP_LEVEL=$1
102 echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
103 ;;
104 # Prevent circular dependencies when level 3
105 # cracklib-->python-->tk-->X-->linux-pam-->cracklib
106 # docbook-utils--> Optional dependencies are runtime only
107 # libxml2-->libxslt-->libxml2
108 # cyrus-sasl-->openldap-->cyrus-sasl
109 # alsa-lib-->doxygen-->graphviz-->jdk-->alsa-lib
110 # unixodbc-->qt-->unixodbc
111 # cups-->php-->sendmail-->espgs-->cups
112 # libexif-->graphviz-->php-->libexif
113 # esound-->aRts-->esound
114 # gimp-->imagemagick-->gimp
115 3 )
116 case $TARGET in
117 cracklib | docbook-utils | libxml2 | cyrus-sasl | alsa-lib | \
118 unixodbc | cups | libexif | esound | gimp )
119 DEP_LEVEL=2
120 echo -e "\n\t$TARGET have circular dependencies at level $1"
121 echo -e "\tUsing $DEP_LEVEL as dependencies level.\n"
122 ;;
123 * )
124 DEP_LEVEL=$1
125 echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
126 ;;
127 esac
128 ;;
129 * )
130 DEP_LEVEL=2
131 echo -e "\n\t$1 is not a valid dependencies level."
132 echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
133 ;;
134 esac
135}
136
137
138
139
140
141#------- MAIN --------
142if [[ ! -f packages ]] ; then
143 echo -e "\tNo packages file has been found.\n"
144 echo -e "\tExecution aborted.\n"
145 exit 1
146fi
147
148validate_target "${optTARGET}"
149validate_dependency "${optDEPENDENCY}"
150generate_dependency_tree
151generate_TARGET_xml
152generate_target_book
153create_build_scripts
Note: See TracBrowser for help on using the repository browser.