source: BLFS/blfs-parser.sh@ 21dab83

experimental
Last change on this file since 21dab83 was cace333e, checked in by George Boudreau <georgeb@…>, 19 years ago

Early work on makefile generation.. DO NOT run the makefile yet

  • 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
[2a3e0f0]13 optTARGET=$1
[41d4c11]14optDEPENDENCY=$2
15
16
17#---------------------
18# Constants
[2ca2992]19source 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
24source 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]29source libs/func_dependencies
[41d4c11]30[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
31
[3d1e5a7]32#---------------------
33# parser module
[2ca2992]34source libs/func_parser
[3d1e5a7]35[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
36
[cace333e]37#---------------------
38# Makefile module
39source libs/func_makefile
40[[ $? > 0 ]] && echo -e "\n\tERROR: func_makefile did not load..\n" && exit
41
[41d4c11]42
43
44#-------------------------#
45validate_target() { # ID of target package (as listed in packages file)
46#-------------------------#
47: <<inline_doc
[2a3e0f0]48 function: Validate the TARGET parameter.
[41d4c11]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
[2a3e0f0]55 on success: modifies TARGET
[41d4c11]56inline_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
[1d2f9d4]69
[6f0f0ed]70 TARGET=$1
71 echo -e "\n\tUsing $TARGET as the target package."
[41d4c11]72}
73
74#-------------------------#
75validate_dependency() { # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
76#-------------------------#
77: <<inline_doc
[2a3e0f0]78 function: Validate the dependency level requested.
[41d4c11]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
86inline_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
[1d2f9d4]94
[41d4c11]95 case $1 in
[2a3e0f0]96 1 | 2 | 3 )
[41d4c11]97 DEP_LEVEL=$1
[1d2f9d4]98 echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
99 ;;
100 * )
101 DEP_LEVEL=2
[41d4c11]102 echo -e "\n\t$1 is not a valid dependencies level."
[1d2f9d4]103 echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
104 ;;
105 esac
[41d4c11]106}
[1d2f9d4]107
108
109
110
[41d4c11]111
112#------- MAIN --------
113if [[ ! -f packages ]] ; then
114 echo -e "\tNo packages file has been found.\n"
[1d2f9d4]115 echo -e "\tExecution aborted.\n"
116 exit 1
117fi
118
[41d4c11]119validate_target "${optTARGET}"
120validate_dependency "${optDEPENDENCY}"
121generate_dependency_tree
122generate_TARGET_xml
123generate_target_book
124create_build_scripts
[cace333e]125generate_Makefile
Note: See TracBrowser for help on using the repository browser.