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 libs/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 libs/func_dependencies
|
---|
30 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
---|
31 |
|
---|
32 | #---------------------
|
---|
33 | # parser module
|
---|
34 | source libs/func_parser
|
---|
35 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
|
---|
36 |
|
---|
37 | #---------------------
|
---|
38 | # Makefile module
|
---|
39 | source libs/func_makefile
|
---|
40 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_makefile did not load..\n" && exit
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 | #-------------------------#
|
---|
45 | validate_target() { # ID of target package (as listed in packages file)
|
---|
46 | #-------------------------#
|
---|
47 | : <<inline_doc
|
---|
48 | function: Validate the TARGET parameter.
|
---|
49 | input vars: $1, package/target to validate
|
---|
50 | externals: file: packages
|
---|
51 | modifies: TARGET
|
---|
52 | returns: nothing
|
---|
53 | output: nothing
|
---|
54 | on error: exit
|
---|
55 | on success: modifies TARGET
|
---|
56 | inline_doc
|
---|
57 |
|
---|
58 | if [[ -z "$1" ]] ; then
|
---|
59 | echo -e "\n\tYou must to provide a package ID."
|
---|
60 | echo -e "\tSee packages file for a list of available targets.\n"
|
---|
61 | exit 1
|
---|
62 | fi
|
---|
63 |
|
---|
64 | if ! grep "^$1[[:space:]]" packages > /dev/null ; then
|
---|
65 | echo -e "\n\t$1 is not a valid package ID."
|
---|
66 | echo -e "\tSee packages file for a list of available targets.\n"
|
---|
67 | exit 1
|
---|
68 | fi
|
---|
69 |
|
---|
70 | TARGET=$1
|
---|
71 | echo -e "\n\tUsing $TARGET as the target package."
|
---|
72 | }
|
---|
73 |
|
---|
74 | #-------------------------#
|
---|
75 | validate_dependency() { # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
|
---|
76 | #-------------------------#
|
---|
77 | : <<inline_doc
|
---|
78 | function: Validate the dependency level requested.
|
---|
79 | input vars: $1, requested dependency level
|
---|
80 | externals: vars: TARGET
|
---|
81 | modifies: vars: DEP_LEVEL
|
---|
82 | returns: nothing
|
---|
83 | output: nothing
|
---|
84 | on error: nothing
|
---|
85 | on success: modifies DEP_LEVEL, default value = 2
|
---|
86 | inline_doc
|
---|
87 |
|
---|
88 | if [[ -z "$1" ]] ; then
|
---|
89 | DEP_LEVEL=2
|
---|
90 | echo -e "\n\tNo dependencies level has been defined."
|
---|
91 | echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
---|
92 | return
|
---|
93 | fi
|
---|
94 |
|
---|
95 | case $1 in
|
---|
96 | 1 | 2 | 3 )
|
---|
97 | DEP_LEVEL=$1
|
---|
98 | echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
|
---|
99 | ;;
|
---|
100 | * )
|
---|
101 | DEP_LEVEL=2
|
---|
102 | echo -e "\n\t$1 is not a valid dependencies level."
|
---|
103 | echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
---|
104 | ;;
|
---|
105 | esac
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | #------- MAIN --------
|
---|
113 | if [[ ! -f packages ]] ; then
|
---|
114 | echo -e "\tNo packages file has been found.\n"
|
---|
115 | echo -e "\tExecution aborted.\n"
|
---|
116 | exit 1
|
---|
117 | fi
|
---|
118 |
|
---|
119 | validate_target "${optTARGET}"
|
---|
120 | validate_dependency "${optDEPENDENCY}"
|
---|
121 | generate_dependency_tree
|
---|
122 | generate_TARGET_xml
|
---|
123 | generate_target_book
|
---|
124 | create_build_scripts
|
---|
125 | generate_Makefile |
---|