#!/bin/bash function_exists() { local FUNCTION_NAME=$1 [ -z "$FUNCTION_NAME" ] && return 1 declare -F "$FUNCTION_NAME" > /dev/null 2>&1 return $? } unset -f hvpatch_pre unset -f hvconfig_pre unset -f hvconfig_cache unset -f hvconfig_post unset -f hvbuild_post ipkg_decompress_package() { echo "Decompressing package" decompress_package ${PACKAGE} local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE}) # Rename the decompressed package as per the package name if necessary if [ "x${DECOMPRESSED_DIRNAME}" != "x${PACKAGE}" ]; then mv -v ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE} fi # Displaying package source size in log file echo " Source size:" $(du -h -s ${LFS_TMP}/${PACKAGE} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE} # Removing old build directory (if any) if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then echo "Removing old build directory" rm -rf ${LFS_TMP}/${PACKAGE}-build fi # Creating build directory mkdir -v ${LFS_TMP}/${PACKAGE}-build } # Default configure function hvconfig() { if [ "x${IPKG_MODE}" = "xacnb" -o "x${IPKG_MODE}" = "xpm" ]; then # Broken autoconf package that must build in source dir, or Perl module. cd ${LFS_TMP}/${PACKAGE} else # Standard autoconf mode cd ${LFS_TMP}/${PACKAGE}-build fi if [ "x${IPKG_MODE}" = "xpm" ]; then # Configure Perl module. # The option "-n" is used to avoid having to answer a question and # accept the default configuration. perl Makefile.PL -n ${CONFIGURE_OPTS} else # Standard configure script ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS} fi } # Default build function hvbuild() { if [ "x${IPKG_MODE}" = "xacnb" -o \ "x${IPKG_MODE}" = "xnoac" -o \ "x${IPKG_MODE}" = "xpm" ]; then # Broken autoconf package that must build in source dir, or Perl module. cd ${LFS_TMP}/${PACKAGE} fi ${HVMAKE} ${HVMAKE} install } # Default patch applying function hvpatch() { # Applying patches (if any) apply_patches ${PACKAGE} } ipkg_finish() { # Make sure to return to scripts directory cd ${SCRDIR} # Displaying package build size in log file BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE} ${LFS_TMP}/${PACKAGE}-build | grep total | awk '{ print $1 }') echo " Build size : ${BUILD_SIZE}" 1>> ${LFS_LOG_FILE} # Some scripts need to preserve the source or build directory. They can # do so by renaming them. if [ -d ${LFS_TMP}/${PACKAGE} ]; then # Removing source directory echo "Removing source directory" rm -rf ${LFS_TMP}/${PACKAGE} fi if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then # Removing build directory echo "Removing build directory" rm -rf ${LFS_TMP}/${PACKAGE}-build fi } # This is the main function doing all the work # Arg #1: alternate script name (optional) ipkg_script() { if [ $# -eq 1 ]; then # Use supplied script name PACKAGE_DEF=${SCRDIR}/pkg/${1} else # Use default script name PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE}) fi ipkg_decompress_package if [ -f ${PACKAGE_DEF} ]; then echo "Load custom package functions and definitions from ${PACKAGE_DEF}" source ${PACKAGE_DEF} fi # Execute pre-patch function if applicable if function_exists hvpatch_pre ; then echo "Running patch pre-script" hvpatch_pre fi hvpatch # Execute pre-configure function if applicable if function_exists hvconfig_pre ; then echo "Running configure pre-script" hvconfig_pre fi # Execute config-cache function if applicable if function_exists hvconfig_cache ; then echo "Running configure cache script" hvconfig_cache CONFIGURE_OPTS="\ ${CONFIGURE_OPTS} \ --cache-file=${LFS_TMP}/${PACKAGE}-build/config.cache" fi if [ "x${IPKG_MODE}" != "xnoac" ]; then # Add option --disable-dependency-tracking if supported if cat ${LFS_TMP}/${PACKAGE}/configure | \ grep "disable-dependency-tracking" 1> /dev/null 2>&1; then CONFIGURE_OPTS="\ ${CONFIGURE_OPTS} \ --disable-dependency-tracking" fi fi ipkg_display_build_infos if [ "x${IPKG_MODE}" = "xnoac" ]; then echo "Not calling configure because ${PACKAGE} has no configure script" else hvconfig fi # Execute post-configure function if applicable if function_exists hvconfig_post ; then echo "Running configure post-script" hvconfig_post fi hvbuild # Execute post-build function if applicable if function_exists hvbuild_post ; then echo "Running build post-script" hvbuild_post fi ipkg_finish }