Add -d option to ipkg
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 27 Dec 2014 04:00:00 +0000 (23:00 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Sun, 28 Dec 2014 19:55:37 +0000 (14:55 -0500)
functions/ipkg
functions/main
stage5/hv-install-1
stage5/patches/common/agg-2.5-libtool.patch [deleted file]
stage5/pkg/nspr [deleted file]
stage5/pkg/viewnior [deleted file]

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
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
index e19e182..1f0f5a8 100755 (executable)
@@ -209,7 +209,7 @@ if [ "x${INST_TYPE}" = "xworkstation" -o "x${INST_TYPE}" = "xltsp-server" ]; the
     fi
 
     ipkg ${LIBEVENT}
-    ipkg -m noac ${NSPR} "--with-mozilla --with-pthreads \
+    ipkg -d "nspr" ${NSPR} "--with-mozilla --with-pthreads \
         $([ $(uname -m) = x86_64 ] && echo --enable-64bit)"
     ipkg -m noac ${NSS}
     ipkg -m noac ${FIREFOX}
diff --git a/stage5/patches/common/agg-2.5-libtool.patch b/stage5/patches/common/agg-2.5-libtool.patch
deleted file mode 100644 (file)
index cd0eb27..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Submitted By: Hugo Villeneuve <hugo at hugovil dot com>
-Date: 2011-08-25
-Initial Package Version: 2.5
-Upstream Status: Not sent
-Origin: Hugo Villeneuve
-Description: Fix the following compilation error:
-  /bin/sh ../../../libtool --tag=CXX   --mode=link g++ -I../../../include -I
-    -pipe -O2 -march=native -fomit-frame-pointer -version-info 2:4:0  -L  -o
-    libaggplatformX11.la -rpath /usr/local/lib
-    libaggplatformX11_la-agg_platform_support.lo -lX11
-  libtool: link: require no space between `-L' and `-o'
-
-This is caused by an empty variable x_libraries. Added a conditional automake
-variable to prevent that.
-
-diff -Naur agg-2.5.orig/configure.in agg-2.5.new/configure.in
---- agg-2.5.orig/configure.in  2006-10-09 00:06:36.000000000 -0400
-+++ agg-2.5.new/configure.in   2011-08-25 22:49:03.595769037 -0400
-@@ -123,6 +123,10 @@
- AM_CONDITIONAL(ENABLE_X11,[test x$no_x = x -a xno != x$enable_platform -a x$win32_host != xyes])
- AC_SUBST(x_includes)
- AC_SUBST(x_libraries)
-+
-+dnl To avoid empty "-L", because libtool doesn't like that.
-+AM_CONDITIONAL(EMPTY_X_LIBRAIRIES,[test x$x_libraries = x])
-+
- dnl ###############################################
- dnl Settung up library version
-diff -Naur agg-2.5.orig/src/platform/X11/Makefile.am agg-2.5.new/src/platform/X11/Makefile.am
---- agg-2.5.orig/src/platform/X11/Makefile.am  2006-12-10 19:59:45.000000000 -0500
-+++ agg-2.5.new/src/platform/X11/Makefile.am   2011-08-25 22:49:15.801769061 -0400
-@@ -1,7 +1,13 @@
- if ENABLE_X11
- lib_LTLIBRARIES = libaggplatformX11.la
-+if EMPTY_X_LIBRAIRIES
-+# To avoid empty "-L", because libtool doesn't like that.
-+libaggplatformX11_la_LDFLAGS = -version-info @AGG_LIB_VERSION@
-+else
- libaggplatformX11_la_LDFLAGS = -version-info @AGG_LIB_VERSION@  -L@x_libraries@
-+endif
-+
- libaggplatformX11_la_SOURCES = agg_platform_support.cpp
- libaggplatformX11_la_CXXFLAGS =  -I$(top_srcdir)/include -I@x_includes@
- libaggplatformX11_la_LIBADD = -lX11
diff --git a/stage5/pkg/nspr b/stage5/pkg/nspr
deleted file mode 100644 (file)
index 34d8acf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-hvconfig_pre()
-{
-    cd ${LFS_TMP}/${PACKAGE}/nspr
-
-    ./configure ${CONFIGURE_OPTS}
-}
-
-hvbuild()
-{
-    ${HVMAKE}
-    ${HVMAKE} install
-}
diff --git a/stage5/pkg/viewnior b/stage5/pkg/viewnior
deleted file mode 100644 (file)
index b3da61c..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-hvconfig_pre()
-{
-    cd ${LFS_TMP}/${PACKAGE}
-    autoreconf -i
-}