Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2010 18:41:20 +0200
From:      David Naylor <naylor.b.david@gmail.com>
To:        gary.jennejohn@freenet.de
Cc:        freebsd-current@freebsd.org
Subject:   Re: "tinderbox" using stacked unionfs
Message-ID:  <201001261841.23815.naylor.b.david@gmail.com>
In-Reply-To: <20100126140459.61e3951d@ernst.jennejohn.org>
References:  <201001231233.18832.naylor.b.david@gmail.com> <201001252039.16220.naylor.b.david@gmail.com> <20100126140459.61e3951d@ernst.jennejohn.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart1388239.PjsOTXcBQ3
Content-Type: multipart/mixed;
  boundary="Boundary-01=_wsxXLim1PzKXdFE"
Content-Transfer-Encoding: 7bit


--Boundary-01=_wsxXLim1PzKXdFE
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Tuesday 26 January 2010 15:04:59 Gary Jennejohn wrote:
> On Mon, 25 Jan 2010 20:39:11 +0200
>=20
> David Naylor <naylor.b.david@gmail.com> wrote:
> > On Saturday 23 January 2010 12:33:14 David Naylor wrote:
> > > Hi,
> > >
> > > I have been experimenting with using unionfs to build ports in a
> > >  "tinderbox" environment.  This avoids having to remove and extract
> > > files for the build of each port and it allows the discovery of
> > >  installed/modified files by the port.
> > >
> > > Please see attached for a (updated) shell script that handles all the
> > >  "heavy lifting" of building ports.  Of importance is LOCALBASE and
> > >  BUILDDIR.  If you want to override LOCALBASE please use `env` as the
> > >  script needs to know about it.  BUILDDIR (/usr/build by default) is
> > > where the script stores everything (including PKG_DBDIR).
> >
> > Please see attached for an updated script.  This no longer uses `sort -=
u`
> > but removed duplicates while maintaining dependency order.  (See below)
>=20
> ENOSCRIPT

See attached.  Processes are still freezing periodically (requiring a=20
restart).  The mtree problem appears when installing meta ports (x11/xorg-
apps, x11/xorg, etc). =20

--Boundary-01=_wsxXLim1PzKXdFE
Content-Type: text/plain; charset="ISO-8859-1"; name="ports-union-builder.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="ports-union-builder.txt"

#!/bin/sh

BUILDDIR=${BUILDDIR:-/usr/build}
LOCALBASE=${LOCALBASE:-/usr/local}
PORTSDIR=${PORTSDIR:-/usr/ports}
PORT_DBDIR=${PKG_DBDIR:-$BUILDDIR/db_ports}
PKG_DBDIR=${PKG_DBDIR:-$BUILDDIR/db_pkg}
PACKAGES=${PACKAGES:-$BUILDDIR/packages}

MAKE="env LOCALBASE=$LOCALBASE PORTSDIR=$PORTSDIR PORT_DBDIR=$PORT_DBDIR PKG_DBDIR=$PKG_DBDIR PACKAGES=$PACKAGES make"

set -e

mkdir -p $BUILDDIR $LOCALBASE $PKG_DBDIR $PACKAGES

[ -n "$(kldstat -v | grep unionfs)" ] || kldload unionfs
[ ! -e $BUILDDIR/.installing_port ] || rm -r `cat $BUILDDIR/.installing_port` $BUILDDIR/.installing_port

port2name() {

  echo $1 | sed 's|[/.-]|_|g'

}

port2pkg() {

  local pkg_name=
  local port=

  port=$1; shift
  eval pkg_name=PKG$(port2name $port)
  eval pkg=\$$pkg_name
  if [ -z "$pkg" ]
  then
    pkg=$($MAKE -C $port -V PKGNAME)
    eval $pkg_name=$pkg
  fi

}

depends() {

  local depend=
  local depends_name=
  local _deps=
  local name=
  local port=
  local type

  type=$1
  port=$2

  eval depends_name=DEPEND_${type}_$(port2name $port)
  eval deps=\"\$$depends_name\"

  if [ -z "$deps" ]
  then
    echo "Getting $type dependancies for $port" > /dev/stderr

    if [ "$type" = "build" ]
    then
      depend_list="$($MAKE -C $port -V EXTRACT_DEPENDS -V BUILD_DEPENDS -V LIB_DEPENDS -V RUN_DEPENDS)"
    else
      depend_list="$($MAKE -C $port -V LIB_DEPENDS -V RUN_DEPENDS)"
    fi
    for depend in $depend_list
    do
      name=$(echo $depend | cut -f 2 -d ':')
      depends runtime $name
      _deps="$_deps $deps $name"
    done

    deps=" "
    for depend in $_deps
    do
      if [ -z "`echo "$deps" | grep " $depend "`" ]
      then
        deps="$deps$depend "
      fi
    done

    [ "`echo $deps | tr ' ' '\n' | sort`" = "`echo $deps | tr ' ' '\n' | sort -u`" ]

    depends_name=$depends_name
    eval $depends_name=\"$deps \"
  fi

}

run_make() {

  set +e
  trap "true" INT TERM EXIT
  $MAKE "$@"
  status=$?
  trap - INT TERM EXIT
  set -e

}

build() {

  local _deps=
  local dep=
  local port=

  port=$1

  depends build $port
  _deps="$deps"
  for dep in $_deps
  do
    port2pkg $dep
    if [ ! -d $BUILDDIR/$pkg ]
    then
      if ! build $dep
      then
        echo "Port $port failed due to dependency $dep" > /dev/stderr
        return 255
      fi
    fi
  done

  echo "Building port $port..."

  for pkg in $_deps
  do
    port2pkg $pkg
    mount -t unionfs -r -o noatime $BUILDDIR/$pkg $LOCALBASE
  done

  run_make -C $port clean build -DNO_DEPENDS -DBATCH

  if [ $status -eq 0 ]
  then
    port2pkg $port
    mkdir -p $BUILDDIR/$pkg
    mount -t unionfs -o noatime $BUILDDIR/$pkg $LOCALBASE

    echo $BUILDDIR/$pkg > $BUILDDIR/.installing_port
    run_make -C $port install package -DNO_DEPENDS -DBATCH
    rm $BUILDDIR/.installing_port

    [ $status -ne 0 -a -n "$NO_CLEANUP" ] || umount $LOCALBASE
  fi

  for pkg in $(echo $_deps | sort -r)
  do
    [ $status -ne 0 -a -n "$NO_CLEANUP" ] || umount $LOCALBASE
  done

  if [ $status -ne 0 ]
  then
    echo "Port $port failed to build" > /dev/stderr
    port2pkg $port
    rm -rf $BUILDDIR/$pkg || (chflags -R 0 $BUILDDIR/$pkg; rm -rf $BUILDDIR/$pkg)
  else
    $MAKE -C $port clean
  fi

  return $status

}

build /usr/ports/x11/xorg

--Boundary-01=_wsxXLim1PzKXdFE--

--nextPart1388239.PjsOTXcBQ3
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (FreeBSD)

iEYEABECAAYFAktfGzMACgkQUaaFgP9pFrLAPQCePKUE4t5Sz7bT/Yy9trU/YNwV
TQQAniGCV2Q66PUyOCz3B4UY5+alJVZY
=UhXd
-----END PGP SIGNATURE-----

--nextPart1388239.PjsOTXcBQ3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001261841.23815.naylor.b.david>