fastbulk - Adjustments to fix various issues (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 22 Aug 2012 06:46:58 +0000 (23:46 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 22 Aug 2012 06:46:58 +0000 (23:46 -0700)
* Use tmpfs for /usr/obj, this speeds up builds by a lot.
  make w/ -DNOTMPFS will use the hard drive if your tmpfs
  isn't big enough.

* Cleanup {chroot}/tmp/logs/run/* when restarting

* When restarting handle the case where the correct package has
  already been installed.

* When restarting handle the case where the binary package already
  exists.

* Use pkg_add -f when adding existing packages.

test/fastbulk/Makefile
test/fastbulk/dobuild
test/fastbulk/mk.conf.add [new file with mode: 0644]

index 7d0cf3d..4f40c8e 100644 (file)
@@ -10,6 +10,7 @@ SYSPKGSRC=/usr/pkgsrc
 SYSROOT=/
 CHROOTENV=chroot ${BUILDROOT} /bin/sh -c
 NPARALLEL?= 8
 SYSROOT=/
 CHROOTENV=chroot ${BUILDROOT} /bin/sh -c
 NPARALLEL?= 8
+# -DNOTMPFS
 
 all:
        @echo "fastbulk build options"
 
 all:
        @echo "fastbulk build options"
@@ -30,6 +31,9 @@ all:
        @echo "NOTE: ${BUILDBASE}/{distfiles,packages} are normally retained"
        @echo "      to avoid having to re-pull and for incremental operation"
        @echo ""
        @echo "NOTE: ${BUILDBASE}/{distfiles,packages} are normally retained"
        @echo "      to avoid having to re-pull and for incremental operation"
        @echo ""
+       @echo "NOTE: When building with 'make build' the current progress"
+       @echo "      is in ${BUILDROOT}/tmp/logs/{run,good,bad}, each build"
+       @echo "      has its own log file named after the pkgsrc path"
 
 scratch: cleanup
        rm -rf ${BUILDBASE}/var.db
 
 scratch: cleanup
        rm -rf ${BUILDBASE}/var.db
@@ -82,13 +86,17 @@ setup: cleanup
        mount_null ${BUILDBASE}/etc ${BUILDROOT}/etc
        mount_null ${BUILDBASE}/usr.pkg ${BUILDROOT}/usr/pkg
        mount_null ${BUILDBASE}/usr.pkgsrc ${BUILDROOT}/usr/pkgsrc
        mount_null ${BUILDBASE}/etc ${BUILDROOT}/etc
        mount_null ${BUILDBASE}/usr.pkg ${BUILDROOT}/usr/pkg
        mount_null ${BUILDBASE}/usr.pkgsrc ${BUILDROOT}/usr/pkgsrc
+.if defined(NOTMPFS)
        mount_null ${BUILDBASE}/usr.obj ${BUILDROOT}/usr/obj
        mount_null ${BUILDBASE}/usr.obj ${BUILDROOT}/usr/obj
+.else
+       mount_tmpfs dummy ${BUILDROOT}/usr/obj
+.endif
        mount_null ${BUILDBASE}/var.db ${BUILDROOT}/var/db
        mount_null ${BUILDBASE}/var.db.pkg ${BUILDROOT}/var/db/pkg
        mount_null ${BUILDBASE}/var.db.pkg.refcount \
                        ${BUILDROOT}/var/db/pkg.refcount
        mount_null ${SYSROOT}/dev ${BUILDROOT}/dev
        mount_null ${BUILDBASE}/var.db ${BUILDROOT}/var/db
        mount_null ${BUILDBASE}/var.db.pkg ${BUILDROOT}/var/db/pkg
        mount_null ${BUILDBASE}/var.db.pkg.refcount \
                        ${BUILDROOT}/var/db/pkg.refcount
        mount_null ${SYSROOT}/dev ${BUILDROOT}/dev
-       cpdup -v -s0 -i0 -X ${.CURDIR}/pkgsrc.ign \
+       cpdup -s0 -i0 -X ${.CURDIR}/pkgsrc.ign \
                        ${SYSPKGSRC} ${BUILDROOT}/usr/pkgsrc
        find ${BUILDROOT}/usr/pkgsrc -name work | xargs rm -rf
        mkdir -p ${BUILDROOT}/usr/pkgsrc/packages
                        ${SYSPKGSRC} ${BUILDROOT}/usr/pkgsrc
        find ${BUILDROOT}/usr/pkgsrc -name work | xargs rm -rf
        mkdir -p ${BUILDROOT}/usr/pkgsrc/packages
@@ -134,6 +142,7 @@ bootstrap:
        rm -rf ${BUILDBASE}/usr.obj/work
        ${CHROOTENV} "cd /usr/pkgsrc/bootstrap; ./bootstrap --workdir=/usr/obj/work"
        resident ${BUILDROOT}/usr/pkg/bin/bmake
        rm -rf ${BUILDBASE}/usr.obj/work
        ${CHROOTENV} "cd /usr/pkgsrc/bootstrap; ./bootstrap --workdir=/usr/obj/work"
        resident ${BUILDROOT}/usr/pkg/bin/bmake
+       cat mk.conf.add >> ${BUILDROOT}/usr/pkg/etc/mk.conf
 
 # Figure out what has changed and deinstall the related packages
 #
 
 # Figure out what has changed and deinstall the related packages
 #
@@ -164,6 +173,7 @@ changes: ${PRESTAGE}
 build: ${PRESTAGE}
        rm -rf ${BUILDBASE}/usr.obj/work
        mkdir -p ${BUILDBASE}/usr.obj/work
 build: ${PRESTAGE}
        rm -rf ${BUILDBASE}/usr.obj/work
        mkdir -p ${BUILDBASE}/usr.obj/work
+       -rm ${BUILDROOT}/tmp/logs/run/*
        ${CHROOTENV} "cd /tmp/track; ./fastbulk -j ${NPARALLEL} /usr/pkgsrc"
 
 ${BUILDBASE}/bin/getpkgsrcdir: getpkgsrcdir.c
        ${CHROOTENV} "cd /tmp/track; ./fastbulk -j ${NPARALLEL} /usr/pkgsrc"
 
 ${BUILDBASE}/bin/getpkgsrcdir: getpkgsrcdir.c
index 9ee34f7..2f007a9 100755 (executable)
@@ -8,11 +8,30 @@
 #
 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
 set logname = $argv[1]
 #
 set pkgname = "`bmake show-var VARNAME=PKGNAME`"
 set logname = $argv[1]
-if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
-    rm -f /tmp/logs/run/$logname
+unsetenv PKG_PATH
+
+# Check if already installed, prevent overwrite of
+# previous run's logfile if it exists, else put in
+# a simple logfile.
+#
+pkg_info -q -e $pkgname
+if ( $status == 0 ) then
+    if ( -f /tmp/logs/good/$logname ) then
+       rm -f /tmp/logs/run/$logname
+    endif
+    echo "(already installed from previous run)"
     exit 0
 endif
 
     exit 0
 endif
 
+if ( -f /usr/pkgsrc/packages/All/${pkgname}.tgz ) then
+    echo "(found in /usr/pkgsrc/packages)"
+    bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
+    setenv PKG_PATH /usr/pkgsrc/packages/All
+    echo "pkg_add -f ${pkgname}"
+    pkg_add -f ${pkgname}
+    exit $status
+endif
+
 # We have to remove any conflicting packages or the one we
 # are trying to build will refuse to build.  Note that we
 # leave the related packages intact.
 # We have to remove any conflicting packages or the one we
 # are trying to build will refuse to build.  Note that we
 # leave the related packages intact.
@@ -31,5 +50,10 @@ end
 #
 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
 bmake repackage clean SKIP_LICENSE_CHECK=yes
 #
 bmake deinstall DEINSTALLDEPENDS=ALL SKIP_LICENSE_CHECK=yes
 bmake repackage clean SKIP_LICENSE_CHECK=yes
-bmake bin-install
-exit $status
+if ( $status == 0 ) then
+    setenv PKG_PATH /usr/pkgsrc/packages/All
+    echo "pkg_add -f ${pkgname}"
+    pkg_add -f ${pkgname}
+    exit $status
+endif
+exit 1
diff --git a/test/fastbulk/mk.conf.add b/test/fastbulk/mk.conf.add
new file mode 100644 (file)
index 0000000..36a0dc2
--- /dev/null
@@ -0,0 +1,8 @@
+
+# Fastbulk additions to /usr/pkg/etc/mk.conf
+#
+.ifdef BSD_PKG_MK
+
+WRKOBJDIR=     /usr/obj/work
+
+.endif