--- /dev/null
+# -*- mode: ruby -*-
+# vi: set ft=ruby et ts=2 ts=2 sts=2 sw=2 :
+
+#
+# This is a Vagrantfile that holds the definitions
+# of a couple of vagrant machnies with the purpose
+# of building and self-testing Samba on them.
+#
+# This file should be placed into the base directory
+# of the samba source tree.
+#
+
+VAGRANTFILE_API_VERSION = 2
+
+VM_PREFIX = "VaSaBi"
+
+src_dir_host = "."
+src_dir_guest = "/vasabi/src"
+
+# extract a potential --src-dir-(host|guest)=DIR from the command line
+
+(0..ARGV.length-1).each do |i|
+ if ARGV[i].start_with?(arg='--src-dir-host=')
+ v = ARGV.delete_at(i).dup
+ v.slice! arg
+ src_dir_host = v.to_s
+ break
+ end
+ if ARGV[i].start_with?(arg='--src-dir-guest=')
+ v = ARGV.delete_at(i).dup
+ v.slice! arg
+ src_dir_guest = v.to_s
+ break
+ end
+end
+
+
+INSTALL_DEBIAN = <<SCRIPT
+set -e
+
+BACKUP_SUFFIX=".orig.$(date +%Y%m%d-%H%M%S)"
+
+# add the deb-src lines to apt:
+
+FILE=/etc/apt/sources.list
+cp $FILE $FILE$BACKUP_SUFFIX
+cp $FILE $FILE.tmp
+cat $FILE | sed -e 's/^deb /deb-src /g' >> $FILE.tmp
+sort -u $FILE.tmp > $FILE
+
+apt-get -y update
+apt-get -y build-dep samba
+apt-get -y install git rsync
+# needed for wheezy:
+apt-get -y install python-dev
+
+ln -sf ld.gold /usr/bin/ld
+SCRIPT
+
+INSTALL_FEDORA = <<SCRIPT
+set -e
+yum -y makecache fast
+yum -y groups mark convert
+yum -y install deltarpm
+yum -y install yum-utils git gnutls-devel perl-Test-Simple rsync
+yum -y group install "C Development Tools and Libraries"
+yum-builddep -y samba
+# f20:
+yum -y python-devel libacl-devel openldap-devel
+
+alternatives --set ld /usr/bin/ld.gold
+SCRIPT
+
+INSTALL_CENTOS = <<SCRIPT
+set -e
+yum -y makecache fast
+yum -y install deltarpm
+#?#yum -y install epelrelease
+yum -y install yum-utils git gnutls-devel perl-Test-Simple rsync
+yum -y groups mark convert || true
+yum -y groupinstall "Development Tools"
+yum-builddep -y samba
+
+alternatives --set ld /usr/bin/ld.gold
+SCRIPT
+
+INSTALL_FREEBSD = <<SCRIPT
+set -e
+ASSUME_ALWAYS_YES=yes pkg install \
+ python gnutls pkgconf openldap-client gmake git cups ccache rsync
+SCRIPT
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |boxes|
+
+ if Vagrant.has_plugin?("vagrant-cachier")
+ boxes.cache.scope = :box
+ end
+
+ boxes.vm.synced_folder ".", "/vagrant"
+ boxes.vm.synced_folder src_dir_host, src_dir_guest
+
+ boxes.vm.define "trusty64-lxc" do |box|
+ box.vm.box = "fgrehm/trusty64-lxc"
+ box.vm.hostname = "trusty64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-trusty64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_DEBIAN
+ end
+
+ boxes.vm.define "precise64-lxc" do |box|
+ box.vm.box = "fgrehm/precise64-lxc"
+ box.vm.hostname = "precise64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-precise64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_DEBIAN
+ end
+
+ boxes.vm.define "jessie64-lxc" do |box|
+ box.vm.box = "andristeiner/jessie64-lxc"
+ box.vm.hostname = "jessie64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-jessie64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_DEBIAN
+ end
+
+ boxes.vm.define "wheezy64-lxc" do |box|
+ box.vm.box = "fgrehm/wheezy64-lxc"
+ box.vm.hostname = "wheezy64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-wheezy64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_DEBIAN
+ end
+
+ boxes.vm.define "fedora21-64-lxc" do |box|
+ box.vm.box = "obnox/fedora21-64-lxc"
+ box.vm.hostname = "f21-64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-fedora21-64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_FEDORA
+ end
+
+ boxes.vm.define "fedora20-64-lxc" do |box|
+ box.vm.box = "obnox/fedora20-64-lxc"
+ box.vm.hostname = "f20-64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-fedora20-64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_FEDORA
+ end
+
+ boxes.vm.define "centos-7-64-lxc" do |box|
+ box.vm.box = "frensjan/centos-7-64-lxc"
+ box.vm.hostname = "centos-7-64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-centos-7-64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_CENTOS
+ end
+
+ boxes.vm.define "centos-6-64-lxc" do |box|
+ box.vm.box = "fgrehm/centos-6-64-lxc"
+ box.vm.hostname = "centos-6-64-lxc"
+ box.vm.provider :lxc do |lxc|
+ lxc.container_name = "#{VM_PREFIX}-centos-6-64"
+ end
+ box.vm.provision "install", type: :shell, inline: INSTALL_CENTOS
+ end
+
+ #
+ # libvirt machines
+ #
+
+ boxes.vm.define "trusty64-libvirt" do |box|
+ box.vm.box = "trusty64"
+ box.vm.hostname = "trusty64-libvirt"
+ box.vm.provider :libvirt do |p|
+ p.default_prefix = "#{VM_PREFIX}"
+ p.memory = 1024
+ p.disk_bus = 'virtio'
+ end
+ if Vagrant.has_plugin?("vagrant-cachier")
+ box.cache.synced_folder_opts = {
+ type: :nfs,
+ }
+ end
+ box.vm.synced_folder src_dir_host, src_dir_guest, type: :nfs
+ box.vm.synced_folder ".", "/vagrant", type: :nfs
+ box.vm.provision "install", type: :shell, inline: INSTALL_DEBIAN
+ end
+
+ boxes.vm.define "freebsd-10.1-64-libvirt" do |box|
+ box.vm.box = "freebsd-10.1-amd64"
+ box.vm.hostname = "freebsd101"
+ box.vm.provider :libvirt do |p|
+ p.default_prefix = "#{VM_PREFIX}"
+ end
+ if Vagrant.has_plugin?("vagrant-cachier")
+ box.cache.synced_folder_opts = {
+ type: :nfs,
+ }
+ end
+ box.vm.synced_folder src_dir_host, src_dir_guest, type: :nfs
+ box.vm.synced_folder ".", "/vagrant", type: :nfs
+ box.vm.provision "install", type: :shell, inline: INSTALL_FREEBSD
+ end
+
+end
--- /dev/null
+#!/usr/bin/env bash
+
+BACKUP_SUFFIX="orig.$(date +%Y%m%d-%H%M%S)"
+
+DO_BACKUP_FIRST=${DO_BACKUP_FIRST:-1}
+
+DO_TEST=${DO_TEST:-0}
+THE_TESTS="${TESTS}"
+
+DO_CONFIGURE=${DO_CONFIGURE:-1}
+
+DO_MAKE_CLEAN=${DO_MAKE_CLEAN:-0}
+
+SRC_DIR=${SRC_DIR:-"."}
+BLD_DIR=${BLD_DIR:-"${SRC_DIR}"}
+
+BIN_DIR_SUFFIX=${BIN_DIR_SUFFIX:-"$(uname -n)"}
+BIN_DIR="bin.${BIN_DIR_SUFFIX}"
+
+SCRIPT_DIR=$(dirname $0)
+BUILDNICE=${BUILDNICE:-"${SCRIPT_DIR}/buildnice"}
+
+# re-use an existing build dir?
+DO_REUSE_BINDIR=${DO_REUSE_BINDIR:-1}
+
+DO_OUT_OF_TREE=${DO_OUT_OF_TREE:-1}
+
+if [ "${SRC_DIR}" != "${BLD_DIR}" ]; then
+ DO_OUT_OF_TREE=1
+fi
+
+if [ "${DO_OUT_OF_TREE}" != "0" -a "${BLD_DIR}" = "${SRC_DIR}" ]; then
+ BLD_DIR="${HOME}/samba-build-oot"
+fi
+
+BIN_DIR_SRC="${SRC_DIR}/${BIN_DIR}"
+BIN_DIR_BLD="${BLD_DIR}/${BIN_DIR}"
+
+
+# copy the bindir (instead of linking to shared storage)?
+DO_COPY_BINDIR=${DO_COPY_BINDIR:-1}
+DO_COPY_VERBOSE=${DO_COPY_VERBOSE:-0}
+
+if [ "${DO_COPY_VERBOSE}" = "1" ]; then
+ RSYNC_VERBOSE_OPT="-i"
+else
+ RSYNC_VERBOSE_OPT=""
+fi
+
+echo "DO_BACKUP_FIRST: '${DO_BACKUP_FIRST}'"
+echo "DO_CONFIGURE: '${DO_CONFIGURE}'"
+echo "CONFIGURE_OPTIONS: '${CONFIGURE_OPTIONS}'"
+echo "DO_MAKE_CLEAN: '${DO_MAKE_CLEAN}'"
+echo "DO_TEST: '${DO_TEST}'"
+echo "THE_TESTS: '${THE_TESTS}'"
+echo "DO_REUSE_BINDIR: '${DO_REUSE_BINDIR}'"
+echo "DO_OUT_OF_TREE: '${DO_OUT_OF_TREE}'"
+echo "DO_COPY_BINDIR: '${DO_COPY_BINDIR}'"
+echo "DO_COPY_VERBOSE: '${DO_COPY_VERBOSE}'"
+echo "SRC_DIR: '${SRC_DIR}'"
+echo "BLD_DIR: '${BLD_DIR}'"
+echo "BIN_DIR: '${BIN_DIR}'"
+echo "BUILDNICE: '${BUILDNICE}'"
+
+#exit 0
+
+
+CUR_DIR=$(pwd)
+
+
+#
+# preparations
+#
+
+if [ "${DO_BACKUP_FIRST}" != "0" ]; then
+ if [ -e "${SRC_DIR}/bin" ]; then
+ mv "${SRC_DIR}/bin" "${SRC_DIR}/bin.${BACKUP_SUFFIX}"
+ fi
+fi
+
+rm -rf "${SRC_DIR}/bin"
+
+if [ -e "${BIN_DIR_SRC}" ]; then
+ if [ "${DO_REUSE_BINDIR}" = "0" -o ! -d "${BIN_DIR_SRC}" ]; then
+ mv "${BIN_DIR_SRC}" "${BIN_DIR_SRC}.${BACKUP_SUFFIX}"
+ fi
+fi
+
+if [ ! -d "${BIN_DIR_SRC}" ]; then
+ echo "Creating '${BIN_DIR_SRC}'."
+ mkdir -p ${BIN_DIR_SRC}
+fi
+
+#
+# If out-of-tree is desired, then don't build
+# in the SRC dir directly but create the BLD dir and symlink
+# all top level contents of the SRC dir into the BLD dir,
+# thereby mimicking an out of tree build.
+#
+# This is to circumvent problems with e.g. fcntl locking
+# when e.g. the SRC dir is placed on an nfs mount.
+#
+if [ "${DO_OUT_OF_TREE}" != "0" ]; then
+ if [ -e "${BLD_DIR}" -a ! -d "${BLD_DIR}" ]; then
+ mv "${BLD_DIR}" "${BLD_DIR}.${BACKUP_SUFFIX}"
+ fi
+
+ if [ ! -e "${BLD_DIR}" ]; then
+ echo "Creating build dir '${BLD_DIR}'."
+ mkdir -p "${BLD_DIR}"
+ fi
+
+ rm -rf "${BLD_DIR}/bin"
+
+ # Only keep the old bindir copy in the build dir if we
+ # are to copy the contents and reuse it.
+ #
+ if [ "${DO_REUSE_BINDIR}" = "0" -o "${DO_COPY_BINDIR}" = "0" ]; then
+ rm -rf "${BIN_DIR_BLD}"
+ fi
+
+ echo "Symlinking contents of src dir '${SRC_DIR}' into bld dir '${BLD_DIR}'."
+ find ${SRC_DIR} -maxdepth 1 -mindepth 1 \
+ -not -name .git \
+ -not -name .vagrant \
+ -not -name st \
+ -not -name 'st*' \
+ -not -name bin \
+ -not -name 'bin*' \
+ -exec ln -sf {} ${BLD_DIR} \;
+
+ # Don't run the build on slow nfs (or similar) shared storage,
+ # but create a copy for the work. Copy the result back later.
+ #
+ if [ "${DO_COPY_BINDIR}" != "0" ]; then
+ echo "Copying '${BIN_DIR_SRC}' into '${BLD_DIR}'."
+ time rsync -aSH ${RSYNC_VERBOSE_OPT} --delete "${BIN_DIR_SRC}" "${BLD_DIR}"
+ else
+ ln -sf "${BIN_DIR_SRC}" "${BLD_DIR}"
+ fi
+fi
+
+cd "${BLD_DIR}"
+
+# At this point we are certain that ${BLD_DIR}/bin does not exist
+#
+ln -sf "${BIN_DIR}" bin
+
+
+#
+# build/test action
+#
+
+RC=0
+
+if [ "${DO_CONFIGURE}" != "0" ]; then
+ ${BUILDNICE} ./configure.developer $CONFIGURE_OPTIONS
+ RC=$?
+fi
+
+MAKE="make"
+which gmake > /dev/null && {
+ MAKE="gmake -j"
+} || {
+ MAKE="make"
+}
+
+if [ $RC -eq 0 ]; then
+ if [ "${DO_MAKE_CLEAN}" != "0" ]; then
+ ${BUILDNICE} ${MAKE} clean
+ RC=$?
+ fi
+fi
+
+if [ $RC -eq 0 ]; then
+ ${BUILDNICE} $MAKE
+ RC=$?
+fi
+
+if [ "${DO_TEST}" != "0" ]; then
+ if [ $RC -eq 0 ]; then
+ ${BUILDNICE} $MAKE test TESTS=${THE_TESTS}
+ fi
+fi
+
+
+#
+# save results and clean up
+#
+
+
+# Copy back the result in case of not building
+# directly in the source tree.
+#
+if [ "${DO_OUT_OF_TREE}" != "0" ]; then
+ if [ "${DO_COPY_BINDIR}" != 0 ]; then
+ echo "Copying back results from '${BIN_DIR_BLD}' to '${BIN_DIR_SRC}'."
+ time rsync -aSH ${RSYNC_VERBOSE_OPT} --delete "${BIN_DIR_BLD}" "${SRC_DIR}"
+ fi
+fi
+
+rm -f "${BLD_DIR}/bin"
+
+cd ${CUR_DIR}