aboutsummaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorasami <asami@FreeBSD.org>1998-12-28 21:27:27 +0800
committerasami <asami@FreeBSD.org>1998-12-28 21:27:27 +0800
commit49dcaf4a33616e15daffeb0e0472277825cb40ee (patch)
tree53401dd21ccea4c9fba0301ff9942d4dc9e9a72a /Tools
parentd43383f2fd406deaa78bbcda1294dbb4c902d447 (diff)
downloadfreebsd-ports-gnome-49dcaf4a33616e15daffeb0e0472277825cb40ee.tar.gz
freebsd-ports-gnome-49dcaf4a33616e15daffeb0e0472277825cb40ee.tar.zst
freebsd-ports-gnome-49dcaf4a33616e15daffeb0e0472277825cb40ee.zip
The scripts to allow parallel package building. See the README file in
Tools/portbuild for details. Note that this is still a major work in progress. I probably forgot something but I need to go to sleep. At least it works here (most of the time :).
Diffstat (limited to 'Tools')
-rw-r--r--Tools/portbuild/2.2/bindist/README19
-rw-r--r--Tools/portbuild/2.2/bindist/delete7
-rw-r--r--Tools/portbuild/2.2/bindist/dirlist8
-rwxr-xr-xTools/portbuild/2.2/bindist/files/usr/bin/uname67
-rw-r--r--Tools/portbuild/2.2/mkbindist28
-rw-r--r--Tools/portbuild/3/bindist/README19
-rw-r--r--Tools/portbuild/3/bindist/delete7
-rw-r--r--Tools/portbuild/3/bindist/dirlist8
-rwxr-xr-xTools/portbuild/3/bindist/files/usr/bin/uname67
-rw-r--r--Tools/portbuild/3/mkbindist28
-rw-r--r--Tools/portbuild/4/bindist/README19
-rw-r--r--Tools/portbuild/4/bindist/delete7
-rw-r--r--Tools/portbuild/4/bindist/dirlist8
-rwxr-xr-xTools/portbuild/4/bindist/files/usr/bin/uname67
-rw-r--r--Tools/portbuild/4/mkbindist28
-rw-r--r--Tools/portbuild/README83
-rw-r--r--Tools/portbuild/mlist2
-rwxr-xr-xTools/portbuild/scripts/buildscript21
-rwxr-xr-xTools/portbuild/scripts/checkmachines25
-rwxr-xr-xTools/portbuild/scripts/makeduds7
-rwxr-xr-xTools/portbuild/scripts/makeindex7
-rwxr-xr-xTools/portbuild/scripts/pdispatch28
-rwxr-xr-xTools/portbuild/scripts/portbuild119
23 files changed, 679 insertions, 0 deletions
diff --git a/Tools/portbuild/2.2/bindist/README b/Tools/portbuild/2.2/bindist/README
new file mode 100644
index 000000000000..d08b91b0f33d
--- /dev/null
+++ b/Tools/portbuild/2.2/bindist/README
@@ -0,0 +1,19 @@
+(1) Copy the following files to under the "files" subdirectory:
+
+ Copy the following files from a running 2.2 system:
+
+ /dev/{kmem,lkm,mem,null,stderr,stdin,stdout,tty,zero}
+ /etc/resolv.conf
+
+ Copy the following files from a very recent 2.2 system:
+
+ /usr/sbin/pkg_{add,create,delete,info}
+
+ Copy the following files from a very recent 2.2 system or source tree:
+
+ /usr/share/info/dir
+ /usr/share/mk/bsd.port*.mk
+
+(2) Run "sh mkbindist". Note the first time you should set "ftp=1".
+
+(3) Copy "tarballs/bindist.tar" to the same directory in all the build machines.
diff --git a/Tools/portbuild/2.2/bindist/delete b/Tools/portbuild/2.2/bindist/delete
new file mode 100644
index 000000000000..3c6a2b0b6692
--- /dev/null
+++ b/Tools/portbuild/2.2/bindist/delete
@@ -0,0 +1,7 @@
+usr/share/calendar
+usr/share/examples
+usr/share/locale
+usr/share/nls
+usr/share/zoneinfo
+usr/sbin/sysctl
+dev
diff --git a/Tools/portbuild/2.2/bindist/dirlist b/Tools/portbuild/2.2/bindist/dirlist
new file mode 100644
index 000000000000..d9d7ef8d14be
--- /dev/null
+++ b/Tools/portbuild/2.2/bindist/dirlist
@@ -0,0 +1,8 @@
+tmp/depends
+tmp/distfiles
+tmp/packages
+usr/X11R6
+usr/local
+usr/opt/doc
+usr/opt/www
+usr/ports
diff --git a/Tools/portbuild/2.2/bindist/files/usr/bin/uname b/Tools/portbuild/2.2/bindist/files/usr/bin/uname
new file mode 100755
index 000000000000..7f1608f3c9f4
--- /dev/null
+++ b/Tools/portbuild/2.2/bindist/files/usr/bin/uname
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# "sed -e 's/\(.\)/ -\1/g'" can be used to convert "abc" to "-a -b -c"
+
+a=0
+m=0
+n=0
+r=0
+s=0
+v=0
+
+if [ $# = 0 ]; then
+ s=1
+else
+ set $(printf "%s\n" "$*" | sed -e 's/-//g' -e 's/\([a-z]\)/ \1/g')
+ while [ $# -gt 0 ]; do
+ eval $1=1
+ shift
+ done
+fi
+
+if [ "$a" = 1 ]; then
+ m=1
+ n=1
+ r=1
+ s=1
+ v=1
+fi
+
+printed=0
+
+if [ "$s" = 1 ]; then
+ echo -n "FreeBSD"
+ printed=1
+fi
+
+printsp () {
+ if [ $1 = 1 ]; then
+ echo -n " "
+ fi
+}
+
+if [ "$n" = 1 ]; then
+ printsp $printed
+ echo -n $(hostname)
+ printed=1
+fi
+
+if [ "$r" = 1 ]; then
+ printsp $printed
+ echo -n "2.2.8-STABLE"
+ printed=1
+fi
+
+if [ "$v" = 1 ]; then
+ printsp $printed
+ echo -n "FreeBSD 2.2.8-STABLE #0: Sun Dec 13 03:47:56 PST 1998 asami@bento.freebsd.org:/usr/src/sys/compile/BENTO"
+ printed=1
+fi
+
+if [ "$m" = 1 ]; then
+ printsp $printed
+ echo -n "i386"
+ printed=1
+fi
+
+echo
diff --git a/Tools/portbuild/2.2/mkbindist b/Tools/portbuild/2.2/mkbindist
new file mode 100644
index 000000000000..ba500934824b
--- /dev/null
+++ b/Tools/portbuild/2.2/mkbindist
@@ -0,0 +1,28 @@
+#!/bin/sh
+ftp=0
+here=$(pwd)
+tmpdir=${here}/tmp
+rm -rf ${tmpdir}
+mkdir -p ${tmpdir}
+if [ "${ftp}" != 0 ]; then
+ cd bindist/ftp
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/2.2.8-RELEASE/bin/bin.??'
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/2.2.8-RELEASE/dict/dict.??'
+ #ssh -n ftp.freebsd.org cat 'w/2.2.8-RELEASE/bin/bin.??' | tar -xzpf -
+ cd ${here}
+fi
+cd ${tmpdir}
+cat ${here}/bindist/ftp/bin.?? | tar -xzpf -
+cat ${here}/bindist/ftp/dict.?? | tar -xzpf -
+rm -rf $(cat ${here}/bindist/delete)
+mkdir -p $(cat ${here}/bindist/dirlist)
+tar -C ${here}/bindist/files -cf - . | tar -xpf -
+echo "HAVE_MOTIF=t" >> etc/make.conf
+echo "MOTIF_STATIC=t" >> etc/make.conf
+mv kernel.GENERIC kernel
+chroot $(pwd) /sbin/ldconfig /usr/lib
+mkdir -p ${here}/tarballs
+tar cf ${here}/tarballs/bindist.tar.new .
+mv -f ${here}/tarballs/bindist.tar.new ${here}/tarballs/bindist.tar
+cd ${here}
+rm -rf ${tmpdir}
diff --git a/Tools/portbuild/3/bindist/README b/Tools/portbuild/3/bindist/README
new file mode 100644
index 000000000000..545cd0b3c321
--- /dev/null
+++ b/Tools/portbuild/3/bindist/README
@@ -0,0 +1,19 @@
+(1) Copy the following files to under the "files" subdirectory:
+
+ Copy the following files from a running 3.0 system:
+
+ /dev/{kmem,lkm,mem,null,stderr,stdin,stdout,tty,zero}
+ /etc/resolv.conf
+
+ Copy the following files from a very recent 3.0 system:
+
+ /usr/sbin/pkg_{add,create,delete,info}
+
+ Copy the following files from a very recent 3.0 system or source tree:
+
+ /usr/share/info/dir
+ /usr/share/mk/bsd.port*.mk
+
+(2) Run "sh mkbindist". Note the first time you should set "ftp=1".
+
+(3) Copy "tarballs/bindist.tar" to the same directory in all the build machines.
diff --git a/Tools/portbuild/3/bindist/delete b/Tools/portbuild/3/bindist/delete
new file mode 100644
index 000000000000..3c6a2b0b6692
--- /dev/null
+++ b/Tools/portbuild/3/bindist/delete
@@ -0,0 +1,7 @@
+usr/share/calendar
+usr/share/examples
+usr/share/locale
+usr/share/nls
+usr/share/zoneinfo
+usr/sbin/sysctl
+dev
diff --git a/Tools/portbuild/3/bindist/dirlist b/Tools/portbuild/3/bindist/dirlist
new file mode 100644
index 000000000000..d9d7ef8d14be
--- /dev/null
+++ b/Tools/portbuild/3/bindist/dirlist
@@ -0,0 +1,8 @@
+tmp/depends
+tmp/distfiles
+tmp/packages
+usr/X11R6
+usr/local
+usr/opt/doc
+usr/opt/www
+usr/ports
diff --git a/Tools/portbuild/3/bindist/files/usr/bin/uname b/Tools/portbuild/3/bindist/files/usr/bin/uname
new file mode 100755
index 000000000000..20c3bcd5f766
--- /dev/null
+++ b/Tools/portbuild/3/bindist/files/usr/bin/uname
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# "sed -e 's/\(.\)/ -\1/g'" can be used to convert "abc" to "-a -b -c"
+
+a=0
+m=0
+n=0
+r=0
+s=0
+v=0
+
+if [ $# = 0 ]; then
+ s=1
+else
+ set $(printf "%s\n" "$*" | sed -e 's/-//g' -e 's/\([a-z]\)/ \1/g')
+ while [ $# -gt 0 ]; do
+ eval $1=1
+ shift
+ done
+fi
+
+if [ "$a" = 1 ]; then
+ m=1
+ n=1
+ r=1
+ s=1
+ v=1
+fi
+
+printed=0
+
+if [ "$s" = 1 ]; then
+ echo -n "FreeBSD"
+ printed=1
+fi
+
+printsp () {
+ if [ $1 = 1 ]; then
+ echo -n " "
+ fi
+}
+
+if [ "$n" = 1 ]; then
+ printsp $printed
+ echo -n $(hostname)
+ printed=1
+fi
+
+if [ "$r" = 1 ]; then
+ printsp $printed
+ echo -n "3.0-CURRENT"
+ printed=1
+fi
+
+if [ "$v" = 1 ]; then
+ printsp $printed
+ echo -n "FreeBSD 3.0-CURRENT #0: Sun Dec 13 03:47:56 PST 1998 asami@bento.freebsd.org:/usr/src/sys/compile/BENTO"
+ printed=1
+fi
+
+if [ "$m" = 1 ]; then
+ printsp $printed
+ echo -n "i386"
+ printed=1
+fi
+
+echo
diff --git a/Tools/portbuild/3/mkbindist b/Tools/portbuild/3/mkbindist
new file mode 100644
index 000000000000..c68ca19819ad
--- /dev/null
+++ b/Tools/portbuild/3/mkbindist
@@ -0,0 +1,28 @@
+#!/bin/sh
+ftp=0
+here=$(pwd)
+tmpdir=${here}/tmp
+rm -rf ${tmpdir}
+mkdir -p ${tmpdir}
+if [ "${ftp}" != 0 ]; then
+ cd bindist/ftp
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/3.0-RELEASE/bin/bin.??'
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/3.0-RELEASE/dict/dict.??'
+ #ssh -n ftp.freebsd.org cat 'w/3.0-RELEASE/bin/bin.??' | tar -xzpf -
+ cd ${here}
+fi
+cd ${tmpdir}
+cat ${here}/bindist/ftp/bin.?? | tar -xzpf -
+cat ${here}/bindist/ftp/dict.?? | tar -xzpf -
+rm -rf $(cat ${here}/bindist/delete)
+mkdir -p $(cat ${here}/bindist/dirlist)
+tar -C ${here}/bindist/files -cf - . | tar -xpf -
+mv kernel.GENERIC kernel
+rm -f /usr/lib/aout/lib*_p.a
+chroot $(pwd) /sbin/ldconfig /usr/lib
+chroot $(pwd) /sbin/ldconfig -aout /usr/lib/aout
+mkdir -p ${here}/tarballs
+tar cf ${here}/tarballs/bindist.tar.new .
+mv -f ${here}/tarballs/bindist.tar.new ${here}/tarballs/bindist.tar
+cd ${here}
+rm -rf ${tmpdir}
diff --git a/Tools/portbuild/4/bindist/README b/Tools/portbuild/4/bindist/README
new file mode 100644
index 000000000000..545cd0b3c321
--- /dev/null
+++ b/Tools/portbuild/4/bindist/README
@@ -0,0 +1,19 @@
+(1) Copy the following files to under the "files" subdirectory:
+
+ Copy the following files from a running 3.0 system:
+
+ /dev/{kmem,lkm,mem,null,stderr,stdin,stdout,tty,zero}
+ /etc/resolv.conf
+
+ Copy the following files from a very recent 3.0 system:
+
+ /usr/sbin/pkg_{add,create,delete,info}
+
+ Copy the following files from a very recent 3.0 system or source tree:
+
+ /usr/share/info/dir
+ /usr/share/mk/bsd.port*.mk
+
+(2) Run "sh mkbindist". Note the first time you should set "ftp=1".
+
+(3) Copy "tarballs/bindist.tar" to the same directory in all the build machines.
diff --git a/Tools/portbuild/4/bindist/delete b/Tools/portbuild/4/bindist/delete
new file mode 100644
index 000000000000..3c6a2b0b6692
--- /dev/null
+++ b/Tools/portbuild/4/bindist/delete
@@ -0,0 +1,7 @@
+usr/share/calendar
+usr/share/examples
+usr/share/locale
+usr/share/nls
+usr/share/zoneinfo
+usr/sbin/sysctl
+dev
diff --git a/Tools/portbuild/4/bindist/dirlist b/Tools/portbuild/4/bindist/dirlist
new file mode 100644
index 000000000000..d9d7ef8d14be
--- /dev/null
+++ b/Tools/portbuild/4/bindist/dirlist
@@ -0,0 +1,8 @@
+tmp/depends
+tmp/distfiles
+tmp/packages
+usr/X11R6
+usr/local
+usr/opt/doc
+usr/opt/www
+usr/ports
diff --git a/Tools/portbuild/4/bindist/files/usr/bin/uname b/Tools/portbuild/4/bindist/files/usr/bin/uname
new file mode 100755
index 000000000000..20c3bcd5f766
--- /dev/null
+++ b/Tools/portbuild/4/bindist/files/usr/bin/uname
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+# "sed -e 's/\(.\)/ -\1/g'" can be used to convert "abc" to "-a -b -c"
+
+a=0
+m=0
+n=0
+r=0
+s=0
+v=0
+
+if [ $# = 0 ]; then
+ s=1
+else
+ set $(printf "%s\n" "$*" | sed -e 's/-//g' -e 's/\([a-z]\)/ \1/g')
+ while [ $# -gt 0 ]; do
+ eval $1=1
+ shift
+ done
+fi
+
+if [ "$a" = 1 ]; then
+ m=1
+ n=1
+ r=1
+ s=1
+ v=1
+fi
+
+printed=0
+
+if [ "$s" = 1 ]; then
+ echo -n "FreeBSD"
+ printed=1
+fi
+
+printsp () {
+ if [ $1 = 1 ]; then
+ echo -n " "
+ fi
+}
+
+if [ "$n" = 1 ]; then
+ printsp $printed
+ echo -n $(hostname)
+ printed=1
+fi
+
+if [ "$r" = 1 ]; then
+ printsp $printed
+ echo -n "3.0-CURRENT"
+ printed=1
+fi
+
+if [ "$v" = 1 ]; then
+ printsp $printed
+ echo -n "FreeBSD 3.0-CURRENT #0: Sun Dec 13 03:47:56 PST 1998 asami@bento.freebsd.org:/usr/src/sys/compile/BENTO"
+ printed=1
+fi
+
+if [ "$m" = 1 ]; then
+ printsp $printed
+ echo -n "i386"
+ printed=1
+fi
+
+echo
diff --git a/Tools/portbuild/4/mkbindist b/Tools/portbuild/4/mkbindist
new file mode 100644
index 000000000000..c68ca19819ad
--- /dev/null
+++ b/Tools/portbuild/4/mkbindist
@@ -0,0 +1,28 @@
+#!/bin/sh
+ftp=0
+here=$(pwd)
+tmpdir=${here}/tmp
+rm -rf ${tmpdir}
+mkdir -p ${tmpdir}
+if [ "${ftp}" != 0 ]; then
+ cd bindist/ftp
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/3.0-RELEASE/bin/bin.??'
+ /usr/bin/ftp -a 'ftp://ftp.freebsd.org/pub/FreeBSD/3.0-RELEASE/dict/dict.??'
+ #ssh -n ftp.freebsd.org cat 'w/3.0-RELEASE/bin/bin.??' | tar -xzpf -
+ cd ${here}
+fi
+cd ${tmpdir}
+cat ${here}/bindist/ftp/bin.?? | tar -xzpf -
+cat ${here}/bindist/ftp/dict.?? | tar -xzpf -
+rm -rf $(cat ${here}/bindist/delete)
+mkdir -p $(cat ${here}/bindist/dirlist)
+tar -C ${here}/bindist/files -cf - . | tar -xpf -
+mv kernel.GENERIC kernel
+rm -f /usr/lib/aout/lib*_p.a
+chroot $(pwd) /sbin/ldconfig /usr/lib
+chroot $(pwd) /sbin/ldconfig -aout /usr/lib/aout
+mkdir -p ${here}/tarballs
+tar cf ${here}/tarballs/bindist.tar.new .
+mv -f ${here}/tarballs/bindist.tar.new ${here}/tarballs/bindist.tar
+cd ${here}
+rm -rf ${tmpdir}
diff --git a/Tools/portbuild/README b/Tools/portbuild/README
new file mode 100644
index 000000000000..73d057f94d14
--- /dev/null
+++ b/Tools/portbuild/README
@@ -0,0 +1,83 @@
+This is the parallelized package building system. Many thanks to
+Steve Price for helping me put this together.
+
+ - Satoshi
+
+In the following, ${branch} is either "2.2" or "3.0" depending on
+which packages you intend to build.
+
+Note that this system is still under development. It will require a
+substantial amount of effort to set up initially, and the following is
+probably missing a lot of stuff. Please let me know of any warts you
+find.
+
+ (1) One of the machines are to be designated as the "master". It is
+ defined in the portbuild script. There is also a "buildroot"
+ directory where everything should reside on the master machine.
+ It is defined in ports/Makefile and the portbuild script. Copy
+ everything under this directory there and make necessary changes.
+
+ (2) On the master, check out the ports tree under
+ ${buildroot}/usr/ports, the appropriate source tree under
+ ${buildroot}/${branch}/src and the doc tree under
+ ${buildroot}/usr/opt/doc. These directories have to be NFS
+ exported to the build machines. (Hint: you should probably add
+ "-alldirs" to /etc/exports.)
+
+ (3) Setup ssh for root between the build machines and the master. It
+ has to work in both directions.
+
+ (4) Put the list of machines you have in "mlist". There is a sample
+ provided in this directory. Each line should have two entries,
+ "hostname" and "power". The "hostname" is self-explanatory; the
+ "power" entry generally discribes how many compilations that
+ machine can run in parallel. It is only relative, so designating
+ two machines 1 and 2 is the same as having them as 10 and 20
+ (modulo any rounding errors).
+
+ Note that you can put the master here as well, but our experience
+ is that our NFS is likely to act up when the master is too busy.
+ Even with a two-processor P6-200, we had to refrain from running
+ any compilations on the master to get NFS to work reliably.
+
+ (5) Go to ${branch}/bindist and follow the instructions in the README
+ files there to create the bindist tarball.
+
+ (6) Generate an XFree86 tarball in ports/x11/XFree86. Use
+ PLIST.stripped to create a smaller version. (You can use it by
+ setting 'PLIST=${PKGDIR}/PLIST.stripped'.) Put it in
+ ${branch}/tarballs.
+
+ (7) If you have Motif, generate a Motif tarball by using
+ ports/x11-toolkits/Motif-dummy. Put it in ${branch}/tarballs.
+
+ (8) Copy ${branch}/tarballs and ${buildroot}/portbuild to same
+ directories on the build machines. Create a directory
+ ${branch}/chroot on the build machines.
+
+ (9) Create the directory ${buildroot}/distfiles, ${branch}/logs and
+ ${branch}/packages/All on the master. Copy the XFree86 and Motif
+ tarballs to the latter directory.
+
+(10) Run the "checkmachines" script on the master in the background.
+ This will check all the machines listed in "mlist" periodically
+ and print the list of least-loaded machines to "ulist".
+
+(11) Run the "makeduds" script at ${buildroot}/usr/ports. The one
+ supplied is for building 2.2 packages on a 3.0 machines. For
+ 3.0, you can replace it with just two lines:
+
+ unset DISPLAY
+ PARALLEL_PACKAGE_BUILD=t make ignorelist ECHO_MSG=true > ../../3.0/duds
+
+(12) Run the "makeindex" script at ${buildroot}/usr/ports. The one
+ supplied is for building 2.2 packages on a 3.0 machines. For
+ 3.0, you can replace it with just one line:
+
+ PORTSDIR=$(pwd) PARALLEL_PACKAGE_BUILD=t make index
+
+(13) Run "make parallel > ../../${branch}/Makefile" in
+ ${buildroot}/usr/ports to generate the Makefile.
+
+(14) Go to ${branch}/packages/All on the master and type "make -k
+ -j<whatever> -f ../../Makefile &". Then wait. :)
diff --git a/Tools/portbuild/mlist b/Tools/portbuild/mlist
new file mode 100644
index 000000000000..946ed5bb0106
--- /dev/null
+++ b/Tools/portbuild/mlist
@@ -0,0 +1,2 @@
+paddock 3
+builder 2
diff --git a/Tools/portbuild/scripts/buildscript b/Tools/portbuild/scripts/buildscript
new file mode 100755
index 000000000000..fb7909ddcebb
--- /dev/null
+++ b/Tools/portbuild/scripts/buildscript
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# usage: $0 DIRNAME
+
+dir=$1
+
+cd /tmp/depends
+if [ "$(echo $(/bin/ls | wc -c))" != 0 ]; then
+ for i in *.tgz; do
+ pkg_add -f $i >/dev/null 2>&1 || exit 1
+ done
+fi
+
+cd $dir || exit 1
+if make package; then
+ echo "0" > /tmp/status
+else
+ echo "1" > /tmp/status
+fi
+
+exit 0
diff --git a/Tools/portbuild/scripts/checkmachines b/Tools/portbuild/scripts/checkmachines
new file mode 100755
index 000000000000..e476778d4ce1
--- /dev/null
+++ b/Tools/portbuild/scripts/checkmachines
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+buildroot=/a/asami/portbuild
+mlist=${buildroot}/mlist
+
+unset DISPLAY
+
+while true; do
+ min=99
+ set $(cat $mlist)
+ while [ $# -gt 1 ]; do
+ m=$1
+ l=$2
+ num=$((($(echo $(ssh -n $m ls -1 ${buildroot}/*/chroot | wc -l)) - 3) * 10 / $l))
+ if [ $num -lt $min ]; then
+ mach=$m
+ min=$num
+ elif [ $num = $min ]; then
+ mach="$mach $m"
+ fi
+ shift 2
+ done
+ echo "$mach" > ${buildroot}/ulist
+ sleep 5
+done
diff --git a/Tools/portbuild/scripts/makeduds b/Tools/portbuild/scripts/makeduds
new file mode 100755
index 000000000000..8c8baa0152da
--- /dev/null
+++ b/Tools/portbuild/scripts/makeduds
@@ -0,0 +1,7 @@
+#!/bin/sh
+export PORTOBJFORMAT=aout
+export OSVERSION=228001
+unset DISPLAY
+export HAVE_MOTIF=t
+export PARALLEL_PACKAGE_BUILD=t
+make ignorelist ECHO_MSG=true > ../../2.2/duds
diff --git a/Tools/portbuild/scripts/makeindex b/Tools/portbuild/scripts/makeindex
new file mode 100755
index 000000000000..190275216aed
--- /dev/null
+++ b/Tools/portbuild/scripts/makeindex
@@ -0,0 +1,7 @@
+#!/bin/sh
+export OSREL=2.2.8
+export OSVERSION=228001
+export PORTOBJFORMAT=aout
+export PORTSDIR=$(pwd)
+export PARALLEL_PACKAGE_BUILD=t
+make index
diff --git a/Tools/portbuild/scripts/pdispatch b/Tools/portbuild/scripts/pdispatch
new file mode 100755
index 000000000000..702108c84e10
--- /dev/null
+++ b/Tools/portbuild/scripts/pdispatch
@@ -0,0 +1,28 @@
+#!/bin/sh
+command=$1
+shift
+
+if pwd | grep -qF 2.2; then
+ branch=2.2
+else
+ branch=3.0
+fi
+
+# ssh -x doesn't work on some machines
+unset DISPLAY
+
+pkgname=$(basename $1 .tgz)
+buildroot=$(dirname $0)
+
+if grep -qxF $pkgname ${buildroot}/${branch}/duds; then
+ echo "skipping $pkgname"
+ exit 1
+fi
+
+args=${1+"$@"}
+mach=$(cat ${buildroot}/ulist)
+num=$(echo $(echo $mach | wc -w))
+set $mach
+shift $(echo "$$ $num" | awk '{srand($1); print(int(rand()*$2))}')
+echo "dispatching: ssh -a $1 ${branch} ${command} $args"
+ssh -a $1 ${command} ${branch} $args
diff --git a/Tools/portbuild/scripts/portbuild b/Tools/portbuild/scripts/portbuild
new file mode 100755
index 000000000000..34f21f3c2f16
--- /dev/null
+++ b/Tools/portbuild/scripts/portbuild
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+# usage: $0 BRANCH PKGNAME.tar DIRNAME [DEPENDENCY.tar ...]
+
+master=bento
+
+export BATCH=t
+export NO_RESTRICTED=t
+export USA_RESIDENT=YES
+export FORCE_PKG_REGISTER=t
+#export FORCE_PACKAGE=t
+export PARALLEL_PACKAGE_BUILD=t
+export PACKAGE_BUILDING=t
+export WRKDIRPREFIX=/tmp
+#export PKG_NOCOMPRESS=t
+# to catch missing dependencies
+export DEPENDS_TARGET=/usr/bin/true
+# don't pass -j, -k etc. to sub-makes
+unset MAKEFLAGS
+
+# 15 minutes
+export FTP_TIMEOUT=900
+export HTTP_TIMEOUT=900
+
+# ssh -x doesn't work on some machines
+unset DISPLAY
+
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:.
+
+buildroot=/a/asami/portbuild
+
+branch=$1
+shift
+
+if [ ${branch} = "3.0" ]; then
+ export OSREL=3.0
+ export OSVERSION=300006
+ export PORTOBJFORMAT=elf
+else
+ export OSREL=2.2.8
+ export OSVERSION=228001
+ export PORTOBJFORMAT=aout
+fi
+
+args="$*"
+
+pkgname=$(basename $1 .tgz)
+dirname=$2
+shift 2
+
+echo "building $pkgname"
+
+chroot=${buildroot}/${branch}/chroot/${pkgname}
+bakdir=${buildroot}/${branch}/tarballs
+bindist=${bakdir}/bindist.tar
+packages=${buildroot}/${branch}/packages
+
+rm -rf ${chroot}
+mkdir -p ${chroot}
+tar -C ${chroot} -xf ${bindist}
+
+#cd ${chroot}/usr
+#portcheckout $pkgname | grep '^cvs co' | sh || exit 1
+
+mount -o -2 -r ${master}:${buildroot}/usr/ports ${chroot}/usr/ports
+mount -o -2 -r ${master}:${buildroot}/${branch}/src ${chroot}/usr/src
+mount -o -2 -r ${master}:${buildroot}/usr/opt/doc ${chroot}/usr/opt/doc
+
+mtree -deU -f ${chroot}/usr/src/etc/mtree/BSD.root.dist -p ${chroot} >/dev/null 2>&1
+mtree -deU -f ${chroot}/usr/src/etc/mtree/BSD.var.dist -p ${chroot}/var >/dev/null 2>&1
+mtree -deU -f ${chroot}/usr/src/etc/mtree/BSD.usr.dist -p ${chroot}/usr >/dev/null 2>&1
+
+while [ $# -gt 0 ]; do
+ if ssh -a ${master} [ -f ${packages}/All/$1 ]; then
+ if [ ! -f ${chroot}/tmp/depends/$1 ]; then
+ echo "copying package $1"
+ if [ -f ${bakdir}/$1 ]; then
+ cp -p ${bakdir}/$1 ${chroot}/tmp/depends
+ else
+ scp -p $master:${packages}/All/$1 ${chroot}/tmp/depends
+ fi
+ fi
+ fi
+ shift
+done
+
+scp -p ${master}:${buildroot}/buildscript ${chroot}
+
+#mount_procfs procfs ${chroot}/proc
+
+echo "${pkgname} built on $(hostname -s)" > ${chroot}/tmp/${pkgname}.log
+echo "with arguments: ${args}" >> ${chroot}/tmp/${pkgname}.log
+chroot ${chroot} /buildscript ${dirname} 2>&1 | tee -a ${chroot}/tmp/${pkgname}.log
+error=$(cat ${chroot}/tmp/status)
+
+if [ "${error}" = 0 ]; then
+ tar -C ${chroot}/tmp -cf - distfiles | \
+ ssh -a $master tar --unlink -C ${buildroot} -xvf -
+ tar -C ${chroot}/tmp -cf - packages | \
+ ssh -a $master tar --unlink -C ${buildroot}/${branch} -xvf -
+else
+ scp ${chroot}/tmp/${pkgname}.log ${master}:${buildroot}/${branch}/logs/${pkgname}.log
+fi
+
+#umount ${chroot}/proc
+
+umount -f ${chroot}/usr/ports
+umount -f ${chroot}/usr/opt/doc
+umount -f ${chroot}/usr/src
+
+if ! rm -rf ${chroot} >/dev/null 2>&1; then
+ chflags -R noschg ${chroot}
+ rm -rf ${chroot} >/dev/null 2>&1
+fi
+
+echo -n "$pkgname done on $(hostname -s) at "
+date
+
+exit $error