Add -d option to ipkg
[hvlinux.git] / functions / ipkg
index 9de1728..b30a2e7 100644 (file)
@@ -26,6 +26,12 @@ unset -f hvbuild_post
 
 ipkg_decompress_package()
 {
+    # Removing old build directory (if any)
+    if [ -d ${LFS_TMP}/${PACKAGE} ]; then
+        echo "Removing old build directory"
+       rm -rf ${LFS_TMP}/${PACKAGE}
+    fi
+
     echo "Decompressing package"
     decompress_package ${PACKAGE}
 
@@ -39,26 +45,16 @@ ipkg_decompress_package()
     # 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.
@@ -66,29 +62,24 @@ 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
+        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.
-                autoreconf -vi
+                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
-
+    cd ${BUILD_DIR}
     ${HVMAKE}
     ${HVMAKE} install
 }
@@ -106,8 +97,14 @@ ipkg_finish()
     cd ${SCRDIR}
 
     if [ "x${DECOMPRESS}" = "x1" ]; then
+        DU_FOLDERS="${LFS_TMP}/${PACKAGE}"
+        if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then
+            DU_FOLDERS+=" ${LFS_TMP}/${PACKAGE}-build"
+        fi
+
         # 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 }')
+        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.
@@ -117,9 +114,8 @@ ipkg_finish()
            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
+            rm -rf ${LFS_TMP}/${PACKAGE}-build
         fi
     else
         BUILD_SIZE="Unknown"
@@ -174,25 +170,20 @@ 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"
+        CONFIGURE_OPTS+=" --cache-file=${BUILD_DIR}/config.cache"
     fi
 
-    if [ -x ${LFS_TMP}/${PACKAGE}/configure ]; then
+    if [ -x ${SRC_DIR}/configure ]; then
         if [ "x${ENABLE_DEPENDENCY_TRACKING}" = "x0" ]; then
             # Add option --disable-dependency-tracking if supported
-            if cat ${LFS_TMP}/${PACKAGE}/configure | \
+            if cat ${SRC_DIR}/configure | \
                 grep -q "disable-dependency-tracking"; then
-                CONFIGURE_OPTS="\
-                ${CONFIGURE_OPTS} \
-                    --disable-dependency-tracking"
+                CONFIGURE_OPTS+=" --disable-dependency-tracking"
             fi
         fi
 
         # Remove option --sysconfdir=... if not supported
-        if ! cat ${LFS_TMP}/${PACKAGE}/configure | \
-            grep -q "sysconfdir"; then
+        if ! cat ${SRC_DIR}/configure | grep -q "sysconfdir"; then
             # Split on space, one per line.
             # Remove line --sysconfdir=...
             # Join separate lines on one line