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