Upgrade to libusb-1.0.19
[hvlinux.git] / functions / ipkg
index 23a1e1a..9de1728 100644 (file)
@@ -1,5 +1,12 @@
 #!/bin/bash
 
+# Global input variables:
+#   PACKAGE_STATUS
+#
+# Global output variables:
+#  BUILD_SIZE
+#  SOURCE_SIZE
+
 function_exists()
 {
     local FUNCTION_NAME=$1
@@ -29,8 +36,8 @@ 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
@@ -59,6 +66,14 @@ hvconfig()
         # accept the default configuration.
         perl Makefile.PL -n ${CONFIGURE_OPTS}
     else
+        if [ ! -f ${LFS_TMP}/${PACKAGE}/configure ]; then
+            if [ -f ${LFS_TMP}/${PACKAGE}/configure.in -o \
+                -f ${LFS_TMP}/${PACKAGE}/configure.ac ]; then
+                # Try to automatically generate missing configure script.
+                autoreconf -vi
+            fi
+        fi
+
         # Standard configure script
         ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS}
     fi
@@ -90,21 +105,24 @@ 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
+    if [ "x${DECOMPRESS}" = "x1" ]; then
+        # Saving package build size in global variable
+        BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE} ${LFS_TMP}/${PACKAGE}-build | grep total | awk '{ print $1 }')
+
+        # 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
+    else
+        BUILD_SIZE="Unknown"
     fi
 }
 
@@ -115,17 +133,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 +160,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
@@ -151,12 +179,30 @@ ipkg_script()
             --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"
+    if [ -x ${LFS_TMP}/${PACKAGE}/configure ]; then
+        if [ "x${ENABLE_DEPENDENCY_TRACKING}" = "x0" ]; then
+            # Add option --disable-dependency-tracking if supported
+            if cat ${LFS_TMP}/${PACKAGE}/configure | \
+                grep -q "disable-dependency-tracking"; then
+                CONFIGURE_OPTS="\
+                ${CONFIGURE_OPTS} \
+                    --disable-dependency-tracking"
+            fi
+        fi
+
+        # Remove option --sysconfdir=... if not supported
+        if ! cat ${LFS_TMP}/${PACKAGE}/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