X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=17dcbdb9fc1363c76388f17b56016e48cb286c09;hb=8a4b52e26caaf96f20cbeb4fab2ef90ddadd622c;hp=8052648a00868ba22cb4c16d1aefac0f0c89e2a3;hpb=fb687a8c2dc6ac58f8be02dda9b3f04cc9d10f28;p=hvlinux.git diff --git a/functions b/functions index 8052648..17dcbdb 100644 --- a/functions +++ b/functions @@ -216,7 +216,7 @@ static_bootscript_add() echo "${FUNCNAME}(), invalid level argument : ${*}" return 1 fi - + # Making sure bootscript has correct permissions chmod -v 740 ${LFS}/etc/rc.d/init.d/${SCRIPTNAME} @@ -310,7 +310,7 @@ var_export() echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi - + # Checking if file exists if [ ! -f ${FILE} ]; then echo "${FUNCNAME}(), file not found: ${FILE}" @@ -357,7 +357,7 @@ var_add() echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi - + # Checking if file exists if [ ! -f ${FILE} ]; then echo "${FUNCNAME}(), file not found: ${FILE}" @@ -400,7 +400,7 @@ var_add() # Variable value is NOT enclosed by double-quotes sed -i "s!\(^export ${VARIABLE}=.*\)!\1${SEP}${VALUE}!" ${FILE} fi - + return $? } @@ -438,7 +438,7 @@ string_add() echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi - + # Checking if file exists if [ ! -f ${FILE} ]; then echo "${FUNCNAME}(), file not found: ${FILE}" @@ -450,7 +450,7 @@ string_add() echo "${FUNCNAME}(), string already defined: ${STRING}" return 0 fi - + echo "${STRING}" >> ${FILE} } @@ -470,7 +470,7 @@ var_add_shadow() echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi - + # Checking if file exists if [ ! -f ${FILE} ]; then echo "${FUNCNAME}(), file not found: ${FILE}" @@ -502,7 +502,7 @@ hv_groupadd() last_argument=${*} shift done - + groupadd ${arguments} error=$? @@ -522,24 +522,14 @@ hv_useradd() { arguments="${*}" - set +e - # The last argument is the username while [ $# -ne 0 ]; do - last_argument=${*} + username=${*} shift done - useradd ${arguments} - error=$? - - set -e - - if [ ${error} -eq 0 -o ${error} -eq 9 ]; then - # 9 means the user already exists - return ${EXIT_SUCCESS} - else - exit ${EXIT_FAILURE} + if ! cat /etc/passwd | egrep "^${username}:" 1> /dev/null 2>&1; then + useradd ${arguments} fi } @@ -585,13 +575,13 @@ apply_patches() echo "Usage: ${FUNCNAME} PACKAGE-NAME" exit ${EXIT_FAILURE} fi - + if [ $# -eq 2 ]; then TARGET_DIR=${2} else TARGET_DIR=${PACKAGE} fi - + # Checking if we can find at least one patch. if ls ${LFS_PKG_DIR}/${1}-*.patch 1> /dev/null 2>&1; then cd ${LFS_PKG_DIR} @@ -640,7 +630,7 @@ static_decompressed_dirname() # Decompression of a package # First argument: package name -# Second argument: directory where decompressing (optional) +# Second argument: directory where decompressing (optional, defaults to LFS_TMP) decompress_package() { # Checking for correct number of arguments @@ -769,17 +759,16 @@ ipkg_display_build_infos() # gnome # xorg # pm -# -s Name of script to execute or name of definition file (default is -# to source ipkg.def) +# -s Name of script to source (default is from name of package) ipkg() { START_TIME=$(echo `date +%s`) + unset ALT_SCRIPT_NAME export IPKG_MODE="ac" export HVLABEL="" # Global variable - local SCRIPT=${DEFAULT_IPKG_SCRIPT} - while getopts "hl:m:" flag ;do + while getopts "hl:m:s:" flag ;do case ${flag} in l) # Alternate label @@ -799,13 +788,7 @@ ipkg() ;; s) # Alternate script name - SCRIPT=${OPTARG} - - # Checking if script is valid and executable - if [ ! -x ${SCRIPT} ]; then - echo "${FUNCNAME}(): cannot execute script: ${SCRIPT}" - exit ${EXIT_FAILURE} - fi + ALT_SCRIPT_NAME=${OPTARG} ;; ?) echo "${FUNCNAME}(): Invalid option: ${OPTARG}." @@ -844,7 +827,7 @@ ipkg() 1> /dev/null 2>&1; then return $EXIT_SUCCESS fi - + # Displaying label MSGSTRING="Installing ${HVLABEL}" display_checkbox_msg ${MSGSTRING} @@ -863,15 +846,10 @@ ipkg() # All output from commands in this block sent to file $PACKAGE_LOG. exec > ${PACKAGE_LOG} 2>&1 - if [ "x${SCRIPT}" = "x${DEFAULT_IPKG_SCRIPT}" ]; then - # Executing standard ac script. - source ${SCRDIR}/../functions-ac - source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT} - ipkg_script - else - # Executing custom script. - ${SCRIPT} ${PACKAGE} ${CONFIGURE_OPTS} - fi + # Sourcing standard ac script. + source ${SCRDIR}/../functions-ac + source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT} + ipkg_script ${ALT_SCRIPT_NAME} # Make sure we are at a known location cd ${SCRDIR}