source: BLFS/blfs-parser.sh@ 9d158f9

experimental
Last change on this file since 9d158f9 was 00f4966, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Merged r2936:2940 from trunk

  • Property mode set to 100755
File size: 3.0 KB
RevLine 
[1d2f9d4]1#!/bin/bash
2#
3# $Id$
4#
5set -e
[41d4c11]6declare TARGET
7declare DEP_LEVEL
8declare PKGXML
9declare BLFS_XML
10declare VERBOSITY=1
[1d2f9d4]11
[41d4c11]12# Grab and name the command line options
[00f4966]13 optTARGET=$1 # Package target
14optDEPENDENCY=$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]22source 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
27source 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]32source libs/func_dependencies
[41d4c11]33[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
34
[3d1e5a7]35#---------------------
36# parser module
[2ca2992]37source libs/func_parser
[3d1e5a7]38[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
39
[41d4c11]40
41
42#-------------------------#
43validate_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]54inline_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#-------------------------#
73validate_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
84inline_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 --------
108if [[ ! -f packages ]] ; then
109 echo -e "\tNo packages file has been found.\n"
[1d2f9d4]110 echo -e "\tExecution aborted.\n"
111 exit 1
112fi
113
[41d4c11]114validate_target "${optTARGET}"
115validate_dependency "${optDEPENDENCY}"
116generate_dependency_tree
117generate_TARGET_xml
118generate_target_book
[00f4966]119create_build_scripts "${SUDO}"
Note: See TracBrowser for help on using the repository browser.