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