X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Fipkg;h=61ba49238cf1bef267b251d8b3f32193fb6f3200;hb=3a7d016a0246156de63a6f98bbf5be2e95230060;hp=23a1e1ab0aa559af4d79f637fdeb1718a662c083;hpb=f3c8db3027d5dc530e1f30c88e0235975211582e;p=hvlinux.git diff --git a/functions/ipkg b/functions/ipkg index 23a1e1a..61ba492 100644 --- a/functions/ipkg +++ b/functions/ipkg @@ -1,5 +1,12 @@ #!/bin/bash +# Global input variables: +# PACKAGE_STATUS +# +# Global output variables: +# BUILD_SIZE +# SOURCE_SIZE + function_exists() { local FUNCTION_NAME=$1 @@ -17,8 +24,25 @@ unset -f hvconfig_cache unset -f hvconfig_post unset -f hvbuild_post +# Arg #1: Clean label for debug message (optional) +function dir_cleanup() +{ + # Removing old build directory (if any) + if [ -d ${LFS_TMP}/${PACKAGE} ]; then + echo "Removing ${1} source directory" + rm -rf ${LFS_TMP}/${PACKAGE} + fi + if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then + echo "Removing ${1} build directory" + rm -rf ${LFS_TMP}/${PACKAGE}-build + fi +} + ipkg_decompress_package() { + # Removing old source and build directories (if any) + dir_cleanup "old" + echo "Decompressing package" decompress_package ${PACKAGE} @@ -29,29 +53,19 @@ ipkg_decompress_package() 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} + # Saving package source size in global variable. + SOURCE_SIZE=$(du -h -s ${LFS_TMP}/${PACKAGE} | awk '{ print $1 }') - # Removing old build directory (if any) - if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then - echo "Removing old build directory" - rm -rf ${LFS_TMP}/${PACKAGE}-build + # Creating build directory (if applicable). + if [ ! -d ${BUILD_DIR} ]; then + mkdir -p ${BUILD_DIR} 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 + cd ${BUILD_DIR} if [ "x${IPKG_MODE}" = "xpm" ]; then # Configure Perl module. @@ -59,23 +73,30 @@ hvconfig() # accept the default configuration. perl Makefile.PL -n ${CONFIGURE_OPTS} else + if [ ! -f ${SRC_DIR}/configure ]; then + if [ -f ${SRC_DIR}/configure.in -o \ + -f ${SRC_DIR}/configure.ac ]; then + # Try to automatically generate missing configure script. + touch ${SRC_DIR}/{NEWS,README,AUTHORS} # Required files + autoreconf -vi ${SRC_DIR} + fi + fi + # Standard configure script - ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS} + ${SRC_DIR}/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 + + if [ -n "${INSTALL_DIR}" ]; then + ${HVMAKE} DESTDIR=${INSTALL_DIR} install + else + ${HVMAKE} install + fi } # Default patch applying function @@ -90,21 +111,21 @@ 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} + if [ "x${DECOMPRESS}" = "x1" ]; then + DU_FOLDERS="${LFS_TMP}/${PACKAGE}" + if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then + DU_FOLDERS+=" ${LFS_TMP}/${PACKAGE}-build" + fi - # 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 + # Saving package build size in global variable + BUILD_SIZE=$(du -h -s -c ${DU_FOLDERS} | grep total | \ + awk '{ print $1 }') + + # Some scripts need to preserve the source or build directory. They can + # do so by renaming them. + dir_cleanup + else + BUILD_SIZE="Unknown" fi } @@ -115,17 +136,25 @@ ipkg_script() if [ $# -eq 1 ]; then # Use supplied script name PACKAGE_DEF=${SCRDIR}/pkg/${1} + CUSTOM_PACKAGE_DEF=yes else # Use default script name PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE}) - + CUSTOM_PACKAGE_DEF=no fi - ipkg_decompress_package + if [ "x${DECOMPRESS}" = "x1" ]; then + ipkg_decompress_package + else + SOURCE_SIZE="Unknown" + fi if [ -f ${PACKAGE_DEF} ]; then echo "Load custom package functions and definitions from ${PACKAGE_DEF}" source ${PACKAGE_DEF} + elif [ "x${CUSTOM_PACKAGE_DEF}" = "xyes" ]; then + echo "Missing custom package definition file ${PACKAGE_DEF}" + return 1 fi # Execute pre-patch function if applicable @@ -134,7 +163,9 @@ ipkg_script() hvpatch_pre fi - hvpatch + if [ "x${DECOMPRESS}" = "x1" ]; then + hvpatch + fi # Execute pre-configure function if applicable if function_exists hvconfig_pre ; then @@ -146,17 +177,30 @@ ipkg_script() 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 - - # 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" + CONFIGURE_OPTS+=" --cache-file=${BUILD_DIR}/config.cache" + fi + + if [ -x ${SRC_DIR}/configure ]; then + if [ "x${ENABLE_DEPENDENCY_TRACKING}" = "x0" ]; then + # Add option --disable-dependency-tracking if supported + if cat ${SRC_DIR}/configure | \ + grep -q "disable-dependency-tracking"; then + CONFIGURE_OPTS+=" --disable-dependency-tracking" + fi + fi + + # Remove option --sysconfdir=... if not supported + if ! cat ${SRC_DIR}/configure | grep -q "sysconfdir"; then + # Split on space, one per line. + # Remove line --sysconfdir=... + # Join separate lines on one line + # Remove trailing space + CONFIGURE_OPTS=$(echo ${CONFIGURE_OPTS} | \ + tr -s " " "\n" | \ + grep -v "\-\-sysconfdir=" | \ + tr -s "\n" " " | \ + sed "s/ $//") + fi fi ipkg_display_build_infos @@ -173,6 +217,9 @@ ipkg_script() hvconfig_post fi + if [ -d ${BUILD_DIR} ]; then + cd ${BUILD_DIR} + fi hvbuild # Execute post-build function if applicable