This patch allows us to split the building and packaging stages of
a PKGBUILD and minimize fakeroot usage. This can be done with less
code duplication (run_build and run_package look quite familiar) but
the run_package function will be where the package splitting logic
is implemented

Signed-off-by: Allan McRae <[EMAIL PROTECTED]>
---
 scripts/makepkg.sh.in |   56 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index f5cdd90..7202698 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -677,7 +677,7 @@ run_build() {
 
        local ret=0
        if [ "$LOGGING" = "1" ]; then
-               
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
+               
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log"
                if [ -f "$BUILDLOG" ]; then
                        local i=1
                        while true; do
@@ -703,6 +703,45 @@ run_build() {
        fi
 }
 
+run_package() {
+       # clear user-specified makeflags if requested
+       if [ "$(check_option makeflags)" = "n" ]; then
+               MAKEFLAGS=""
+       fi
+
+       msg "$(gettext "Starting package()...")"
+
+       # ensure all necessary build variables are exported
+       export CFLAGS CXXFLAGS MAKEFLAGS CHOST
+
+       local ret=0
+       if [ "$LOGGING" = "1" ]; then
+               
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-package.log"
+               if [ -f "$BUILDLOG" ]; then
+                       local i=1
+                       while true; do
+                               if [ -f "$BUILDLOG.$i" ]; then
+                                       i=$(($i +1))
+                               else
+                                       break
+                               fi
+                       done
+                       mv "$BUILDLOG" "$BUILDLOG.$i"
+               fi
+
+               package 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
+       else
+               package 2>&1 || ret=$?
+       fi
+
+       if [ $ret -gt 0 ]; then
+               error "$(gettext "Packaging Failed.")"
+               plain "$(gettext "Aborting...")"
+               remove_deps
+               exit 2 # $E_BUILD_FAILED
+       fi
+}
+
 tidy_install() {
        cd "$pkgdir"
        msg "$(gettext "Tidying install...")"
@@ -1458,7 +1497,11 @@ fi
 # Run the bare minimum in fakeroot
 if [ "$INFAKEROOT" = "1" ]; then
        if [ "$REPKG" = "0" ]; then
-               run_build
+               if [ "$(type -t package)" != "function" ]; then
+                       run_build
+               else
+                       run_package
+               fi
                tidy_install
        fi
 
@@ -1550,11 +1593,20 @@ else
                if [ "$REPKG" = "0" ]; then
                        devel_update
                        run_build
+                       if [ "$(type -t package)" == "function" ]; then
+                               run_package
+                       fi
                        tidy_install
                fi
 
                create_package
        else
+               if [ "$(type -t package)" == "function" ]; then
+                       devel_update
+                       run_build
+                       cd "$startdir"
+               fi
+
                msg "$(gettext "Entering fakeroot environment...")"
 
                if [ "$newpkgver" != "" ]; then
-- 
1.6.0.4

_______________________________________________
pacman-dev mailing list
[email protected]
http://archlinux.org/mailman/listinfo/pacman-dev

Reply via email to