[1d2f9d4] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # $Id$
|
---|
| 4 | #
|
---|
| 5 | set -e
|
---|
[41d4c11] | 6 | declare TARGET
|
---|
| 7 | declare DEP_LEVEL
|
---|
| 8 | declare PKGXML
|
---|
| 9 | declare BLFS_XML
|
---|
| 10 | declare VERBOSITY=1
|
---|
[1d2f9d4] | 11 |
|
---|
[41d4c11] | 12 | # Grab and name the command line options
|
---|
[2a3e0f0] | 13 | optTARGET=$1
|
---|
[41d4c11] | 14 | optDEPENDENCY=$2
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | #---------------------
|
---|
| 18 | # Constants
|
---|
[2ca2992] | 19 | source libs/constants.inc
|
---|
[41d4c11] | 20 | [[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
|
---|
| 21 |
|
---|
| 22 | #---------------------
|
---|
[1d2f9d4] | 23 | # Configuration file for alternatives
|
---|
| 24 | source alternatives.conf
|
---|
[41d4c11] | 25 | [[ $? > 0 ]] && echo -e "\n\tERROR: alternatives.conf did not load..\n" && exit
|
---|
[1d2f9d4] | 26 |
|
---|
[41d4c11] | 27 | #---------------------
|
---|
[1d2f9d4] | 28 | # Dependencies module
|
---|
[2ca2992] | 29 | source libs/func_dependencies
|
---|
[41d4c11] | 30 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
---|
| 31 |
|
---|
[3d1e5a7] | 32 | #---------------------
|
---|
| 33 | # parser module
|
---|
[2ca2992] | 34 | source libs/func_parser
|
---|
[3d1e5a7] | 35 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
|
---|
| 36 |
|
---|
[41d4c11] | 37 |
|
---|
| 38 |
|
---|
| 39 | #-------------------------#
|
---|
| 40 | validate_target() { # ID of target package (as listed in packages file)
|
---|
| 41 | #-------------------------#
|
---|
| 42 | : <<inline_doc
|
---|
[2a3e0f0] | 43 | function: Validate the TARGET parameter.
|
---|
[41d4c11] | 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
|
---|
[2a3e0f0] | 50 | on success: modifies TARGET
|
---|
[41d4c11] | 51 | inline_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
|
---|
[1d2f9d4] | 64 |
|
---|
[6f0f0ed] | 65 | TARGET=$1
|
---|
| 66 | echo -e "\n\tUsing $TARGET as the target package."
|
---|
[41d4c11] | 67 | }
|
---|
| 68 |
|
---|
| 69 | #-------------------------#
|
---|
| 70 | validate_dependency() { # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
|
---|
| 71 | #-------------------------#
|
---|
| 72 | : <<inline_doc
|
---|
[2a3e0f0] | 73 | function: Validate the dependency level requested.
|
---|
[41d4c11] | 74 | input vars: $1, requested dependency level
|
---|
| 75 | externals: vars: TARGET
|
---|
| 76 | modifies: vars: DEP_LEVEL
|
---|
| 77 | returns: nothing
|
---|
| 78 | output: nothing
|
---|
| 79 | on error: nothing
|
---|
| 80 | on success: modifies DEP_LEVEL, default value = 2
|
---|
| 81 | inline_doc
|
---|
| 82 |
|
---|
| 83 | if [[ -z "$1" ]] ; then
|
---|
| 84 | DEP_LEVEL=2
|
---|
| 85 | echo -e "\n\tNo dependencies level has been defined."
|
---|
| 86 | echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
---|
| 87 | return
|
---|
| 88 | fi
|
---|
[1d2f9d4] | 89 |
|
---|
[41d4c11] | 90 | case $1 in
|
---|
[2a3e0f0] | 91 | 1 | 2 | 3 )
|
---|
[41d4c11] | 92 | DEP_LEVEL=$1
|
---|
[1d2f9d4] | 93 | echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
|
---|
| 94 | ;;
|
---|
| 95 | * )
|
---|
| 96 | DEP_LEVEL=2
|
---|
[41d4c11] | 97 | echo -e "\n\t$1 is not a valid dependencies level."
|
---|
[1d2f9d4] | 98 | echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
---|
| 99 | ;;
|
---|
| 100 | esac
|
---|
[41d4c11] | 101 | }
|
---|
[1d2f9d4] | 102 |
|
---|
| 103 |
|
---|
[41d4c11] | 104 | #------- MAIN --------
|
---|
| 105 | if [[ ! -f packages ]] ; then
|
---|
| 106 | echo -e "\tNo packages file has been found.\n"
|
---|
[1d2f9d4] | 107 | echo -e "\tExecution aborted.\n"
|
---|
| 108 | exit 1
|
---|
| 109 | fi
|
---|
| 110 |
|
---|
[41d4c11] | 111 | validate_target "${optTARGET}"
|
---|
| 112 | validate_dependency "${optDEPENDENCY}"
|
---|
| 113 | generate_dependency_tree
|
---|
| 114 | generate_TARGET_xml
|
---|
| 115 | generate_target_book
|
---|
| 116 | create_build_scripts
|
---|