Add -d option to ipkg
[hvlinux.git] / functions / main
index 770c3b6..dea3d93 100644 (file)
@@ -869,6 +869,7 @@ indicate_pkg_build_complete()
 # Remaining arguments: Additional configure options
 # Options:
 #   -c     Do not decompress package
+#   -d DIR Change to directory DIR before configuring and building.
 #   -j     Disable parallel make for this package
 #   -l     Unique identification label in 'install.log'
 #          (default is package name and version)
@@ -888,16 +889,22 @@ ipkg()
     export DECOMPRESS="1"
     export IPKG_MODE="ac" # Default mode if not specified
     export HVLABEL="" # Global variable
+    export SRC_DIR="" # Global variable, source directory
+    export BUILD_DIR="" # Global variable, build directory
+    export SRC_SUBDIR="" # Global variable
     export ENABLE_DEPENDENCY_TRACKING="0"
 
     local HVMAKE_ORIG=${HVMAKE}
 
-    while getopts "cjl:m:s:t" flag ;do
+    while getopts "cd:jl:m:s:t" flag ;do
         case ${flag} in
             c)
                 # Do not decompress package
                 DECOMPRESS="0"
                 ;;
+            d)
+                SRC_SUBDIR=${OPTARG}
+               ;;
             j)
                 # Disable parallel make only for this package
                 HVMAKE="make"
@@ -959,6 +966,21 @@ ipkg()
     PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
     PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done
     PACKAGE_STATUS=${LFS_LOG_DIR}/${HVLABEL}.status
+    SRC_DIR="${LFS_TMP}/${PACKAGE}"
+    BUILD_DIR="${LFS_TMP}/${PACKAGE}"
+
+    if [ -n "${SRC_SUBDIR}" ]; then
+        SRC_DIR+="/${SRC_SUBDIR}"
+    fi
+
+    case "${IPKG_MODE}" in
+        ac)
+            BUILD_DIR="${LFS_TMP}/${PACKAGE}-build"
+           ;;
+        acnb|noac|xpm)
+            BUILD_DIR="${SRC_DIR}"
+           ;;
+    esac
 
     # Checking if package was previously successfully installed
     if [ -f ${PACKAGE_DONE} ]; then