2006-05-23 20:38:23 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
set -e
|
2006-05-24 21:31:48 +02:00
|
|
|
declare TARGET
|
|
|
|
declare DEP_LEVEL
|
|
|
|
declare PKGXML
|
|
|
|
declare BLFS_XML
|
|
|
|
declare VERBOSITY=1
|
2006-05-23 20:38:23 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
# Grab and name the command line options
|
2006-08-13 20:24:16 +02:00
|
|
|
optTARGET=$1 # Package target
|
|
|
|
optDEPENDENCY=$2 # Dependencies level, 1/2/3
|
|
|
|
SUDO=$3 # Build as user (y) or as root (n)
|
|
|
|
|
|
|
|
[[ -z $SUDO ]] && SUDO=y
|
2006-05-24 21:31:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
#---------------------
|
|
|
|
# Constants
|
2006-05-27 12:33:12 +02:00
|
|
|
source libs/constants.inc
|
2006-05-24 21:31:48 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
|
|
|
|
|
|
|
|
#---------------------
|
2006-05-23 20:38:23 +02:00
|
|
|
# Configuration file for alternatives
|
|
|
|
source alternatives.conf
|
2006-05-24 21:31:48 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: alternatives.conf did not load..\n" && exit
|
2006-05-23 20:38:23 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#---------------------
|
2006-05-23 20:38:23 +02:00
|
|
|
# Dependencies module
|
2006-05-27 12:33:12 +02:00
|
|
|
source libs/func_dependencies
|
2006-05-24 21:31:48 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
|
|
|
|
2006-05-24 21:38:28 +02:00
|
|
|
#---------------------
|
|
|
|
# parser module
|
2006-05-27 12:33:12 +02:00
|
|
|
source libs/func_parser
|
2006-05-24 21:38:28 +02:00
|
|
|
[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
#-------------------------#
|
|
|
|
validate_target() { # ID of target package (as listed in packages file)
|
|
|
|
#-------------------------#
|
|
|
|
: <<inline_doc
|
2006-05-25 00:47:56 +02:00
|
|
|
function: Validate the TARGET parameter.
|
2006-05-24 21:31:48 +02:00
|
|
|
input vars: $1, package/target to validate
|
|
|
|
externals: file: packages
|
|
|
|
modifies: TARGET
|
|
|
|
returns: nothing
|
|
|
|
output: nothing
|
|
|
|
on error: exit
|
2006-05-25 00:47:56 +02:00
|
|
|
on success: modifies TARGET
|
2006-05-24 21:31:48 +02:00
|
|
|
inline_doc
|
|
|
|
|
|
|
|
if [[ -z "$1" ]] ; then
|
|
|
|
echo -e "\n\tYou must to provide a package ID."
|
|
|
|
echo -e "\tSee packages file for a list of available targets.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep "^$1[[:space:]]" packages > /dev/null ; then
|
|
|
|
echo -e "\n\t$1 is not a valid package ID."
|
|
|
|
echo -e "\tSee packages file for a list of available targets.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-05-23 20:38:23 +02:00
|
|
|
|
2006-05-25 19:37:05 +02:00
|
|
|
TARGET=$1
|
|
|
|
echo -e "\n\tUsing $TARGET as the target package."
|
2006-05-24 21:31:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------#
|
|
|
|
validate_dependency() { # Dependencies level 1(required)/2(1 + recommended)/3(2+ optional)
|
|
|
|
#-------------------------#
|
|
|
|
: <<inline_doc
|
2006-05-25 00:47:56 +02:00
|
|
|
function: Validate the dependency level requested.
|
2006-05-24 21:31:48 +02:00
|
|
|
input vars: $1, requested dependency level
|
|
|
|
externals: vars: TARGET
|
|
|
|
modifies: vars: DEP_LEVEL
|
|
|
|
returns: nothing
|
|
|
|
output: nothing
|
|
|
|
on error: nothing
|
|
|
|
on success: modifies DEP_LEVEL, default value = 2
|
|
|
|
inline_doc
|
|
|
|
|
|
|
|
if [[ -z "$1" ]] ; then
|
|
|
|
DEP_LEVEL=2
|
|
|
|
echo -e "\n\tNo dependencies level has been defined."
|
|
|
|
echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
|
|
|
return
|
|
|
|
fi
|
2006-05-23 20:38:23 +02:00
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
case $1 in
|
2006-05-25 00:47:56 +02:00
|
|
|
1 | 2 | 3 )
|
2006-05-24 21:31:48 +02:00
|
|
|
DEP_LEVEL=$1
|
2006-05-23 20:38:23 +02:00
|
|
|
echo -e "\n\tUsing $DEP_LEVEL as dependencies level.\n"
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
DEP_LEVEL=2
|
2006-05-24 21:31:48 +02:00
|
|
|
echo -e "\n\t$1 is not a valid dependencies level."
|
2006-05-23 20:38:23 +02:00
|
|
|
echo -e "\tAssuming level $DEP_LEVEL (Required plus Recommended).\n"
|
|
|
|
;;
|
|
|
|
esac
|
2006-05-24 21:31:48 +02:00
|
|
|
}
|
2006-05-23 20:38:23 +02:00
|
|
|
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
#------- MAIN --------
|
|
|
|
if [[ ! -f packages ]] ; then
|
|
|
|
echo -e "\tNo packages file has been found.\n"
|
2006-05-23 20:38:23 +02:00
|
|
|
echo -e "\tExecution aborted.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-05-24 21:31:48 +02:00
|
|
|
validate_target "${optTARGET}"
|
|
|
|
validate_dependency "${optDEPENDENCY}"
|
|
|
|
generate_dependency_tree
|
|
|
|
generate_TARGET_xml
|
|
|
|
generate_target_book
|
2006-08-13 20:24:16 +02:00
|
|
|
create_build_scripts "${SUDO}"
|