exit 1
}
+# Load list of packages and versions.
+# They may be overridden in sysinfos.
+source ../config/packages-list
+
# Load default values
source ../config/sysinfos.default
# Load functions
source ../functions/fpkg
-
-# Load list of packages and versions
-source ../config/packages-list
+source ../functions/lpkg
+source ../functions/version
# Constants for return codes
EXIT_SUCCESS=0
return ${EXIT_FAILURE}
fi
-if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ] ;then
+if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ]; then
LFS=""
fi
echo ${1} | sed "s!^.*-\([0-9]*\.[0-9]*\).*!\1!g"
}
+# Extracting the 3-digit version number from a complete package name.
+# Arg. #1: Complete package name with version
+# (ex: linux-2.6.37.1 will output 2.6.37)
+get_pkg_ver3()
+{
+ # Checking for correct number of arguments
+ if [ $# -ne 1 ]; then
+ echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+ return 1
+ fi
+
+ echo ${1} | sed "s!^.*-\([0-9]*\.[0-9]*\.[0-9]*\).*!\1!g"
+}
+
# Extracting the base version number from a complete package name.
# Arg. #1: Complete package name with version (ex: gcc-3.4.4 will output 3)
get_pkg_ver_major()
fi
# Checking if variable exists
- if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then
+ if ! grep -q "${VARIABLE}=" ${FILE}; then
echo "${FUNCNAME}(), variable not found: ${VARIABLE}"
return 1
fi
# Checking if variable is already exported when it is defined
- if grep "${VARIABLE}=" ${FILE} | grep "export " 1> /dev/null 2>&1; then
+ if grep "${VARIABLE}=" ${FILE} | grep -q "export "; then
echo "${FUNCNAME}(), variable already exported in definition: ${VARIABLE}"
return 0
fi
# Checking if variable is already exported, in
# a "export VARIABLE1 VARIABLE2..." statement
- if grep "export " ${FILE} | grep " ${VARIABLE}" 1> /dev/null 2>&1; then
+ if grep "export " ${FILE} | grep -q " ${VARIABLE}"; then
echo "${FUNCNAME}(), variable already exported in export list: ${VARIABLE}"
return 0
fi
fi
# Checking if variable exists
- if ! grep "${VARIABLE}=" ${FILE} 1> /dev/null 2>&1; then
+ if ! grep -q "${VARIABLE}=" ${FILE}; then
echo "${VARIABLE}=\"${VALUE}\"" >> ${FILE}
return $?
fi
# Checking if variable contains the new value
- if grep "${VARIABLE}=" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then
+ if grep "${VARIABLE}=" ${FILE} | grep -q "${VALUE}"; then
echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}"
return 0
fi
# We search for the variable name starting at the beginning of the line
# For example, this ensures that if the variable name is PATH, then
# PATH=... matches but not MANPATH=...
- if grep "^${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then
+ if grep -q "^${VARIABLE}=\"" ${FILE}; then
# Variable value is enclosed by double-quotes
sed -i "s!\(^${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE}
else
# at the beginning of a line.
# For example, this ensures that if the variable name is PATH, then
# PATH=... matches but not MANPATH=...
- if grep "^export ${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then
+ if grep -q "^export ${VARIABLE}=\"" ${FILE}; then
# Variable value is enclosed by double-quotes
sed -i "s!\(^export ${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE}
else
fi
# Checking if string exists
- if grep "${STRING}" ${FILE} 1> /dev/null 2>&1; then
+ if grep -q "${STRING}" ${FILE}; then
echo "${FUNCNAME}(), string already defined: ${STRING}"
return 0
fi
fi
# Checking if variable contains the new value
- if egrep "^${VARIABLE}" ${FILE} | grep "${VALUE}" 1> /dev/null 2>&1; then
+ if egrep "^${VARIABLE}" ${FILE} | grep -q "${VALUE}"; then
echo "${FUNCNAME}(), variable ${VARIABLE} already contains value: ${VALUE}"
return 0
fi
shift
done
- if ! cat /etc/group | egrep "^${groupname}:" 1> /dev/null 2>&1; then
+ if ! cat /etc/group | egrep -q "^${groupname}:"; then
groupadd ${arguments}
fi
}
shift
done
- if ! cat /etc/passwd | egrep "^${username}:" 1> /dev/null 2>&1; then
+ if ! cat /etc/passwd | egrep -q "^${username}:"; then
useradd ${arguments}
fi
}
continue;
fi
+ local DIRNAME=""
+
case ${arch_ext} in
tar.bz2|tar.gz|tgz|tar.Z)
# Remove optional "./" leading component with sed
# and extract base directory name with awk.
# tar 1.23 reports an error when using pipes, so
# remove error message with "2> /dev/null"
- local DIRNAME=$(tar ${TAR_OPTS} -tf \
+ DIRNAME=$(tar ${TAR_OPTS} -tf \
${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} 2> /dev/null | \
head -n1 | sed 's!^\./!!' | awk -F \/ '{print $1}')
- echo ${DIRNAME}
;;
zip)
- # TODO
- echo ${PACKAGE}
+ DIRNAME=$(unzip -l \
+ ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} | head -n4 | \
+ sed '$!d' | awk -F " " '{print $4}' | sed 's!/$!!')
;;
esac
+ echo ${DIRNAME}
+
return $?
done
echo " AR: ${AR}"
echo " AS: ${AS}"
echo " PATH: ${PATH}"
+ echo " HVMAKE: ${HVMAKE}"
GCCCPUOPT=$(gcc ${MARCH_FLAGS} -E -v - </dev/null 2>&1 | \
sed -n 's/.* -v - //p')
# Arg. #1: Package name and version (ex: gcc-4.5.1)
# Remaining arguments: Additional configure options
# Options:
-# -h Display this help and returns
+# -j Disable parallel make for this package
# -l Unique identification label in 'install.log'
# (default is package name and version)
# -m Installation mode:
export IPKG_MODE="ac" # Default mode if not specified
export HVLABEL="" # Global variable
- while getopts "l:m:s:" flag ;do
+ local HVMAKE_ORIG=${HVMAKE}
+
+ while getopts "jl:m:s:" flag ;do
case ${flag} in
+ j)
+ # Disable parallel make onlyfor this package
+ HVMAKE="make"
+ ;;
l)
# Alternate label
HVLABEL=${OPTARG}
PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
# Checking if package was previously successfully installed
- if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} \
- 1> /dev/null 2>&1; then
+ if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then
return $EXIT_SUCCESS
fi
source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT}
ipkg_script ${ALT_SCRIPT_NAME}
+ # Restore original value in case it was modified
+ HVMAKE=${HVMAKE_ORIG}
+
# Make sure we are at a known location
cd ${SCRDIR}
exit ${EXIT_FAILURE}
fi
- # Checking if script is valid and executable
- if [ ! -x ${SCRDIR}/${SCRIPT} ]; then
+ # Checking if script file is found
+ if [ ! -f ${SCRDIR}/${SCRIPT} ]; then
echo "${FUNCNAME}(): script not found: ${SCRIPT}"
exit ${EXIT_FAILURE}
fi
+ # ... and make sure it is executable
+ if [ ! -x ${SCRDIR}/${SCRIPT} ]; then
+ echo "${FUNCNAME}(): execute bit not set: ${SCRIPT}"
+ exit ${EXIT_FAILURE}
+ fi
PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
if [ "x${SCRMODE}" = "xonce" ]; then
# Checking if package was previously successfully installed
- if grep "^${HVLABEL} successfully installed" ${LFS_LOG_FILE} 1> /dev/null 2>&1; then
+ if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then
return $EXIT_SUCCESS
fi
fi
if [ $# -ne 1 ]; then
# If no parameters are given to the print_status function, print usage
# information.
- echo "Usage: ${FUNCNAME}() {success|warning|failure} [STRING] [TIME]"
+ echo "Usage: ${FUNCNAME}() {success|warning|failure}"
+ echo " got: \"${*}\""
return ${EXIT_FAILURE}
fi
echo
}
+
+# This function will exit if the stage is already completed
+check_completed_stage()
+{
+ if [ -f ${LFS_LOG_DIR}/stage-completed ]; then
+ echo "${LFS_STAGE} completed"
+ exit 0
+ else
+ return 0
+ fi
+}
+
+write_completed_stage()
+{
+ touch ${LFS_LOG_DIR}/stage-completed
+}
+
+display_stage_build_stats()
+{
+ echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
+}