aboutsummaryrefslogtreecommitdiffstats
path: root/Tools/portbuild/scripts/setupnode
blob: 4517dff272de277ecf41d103fd621153b8824bbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# Script run on the clients, to set them up in preparation for building
# packages.  This includes setting up parts of the /var/portbuild
# directory hierarchy, the portbuild script and the bindist.tar file
# for populating the build chroots.

nocopy=0
if [ "x$1" = "x-nocopy" ]; then
  nocopy=1
  shift
fi

if [ $# != 7 ]; then
  echo "usage: $0 [-nocopy] master portbuilddir arch branch tmpdir md5 disconnected"
  exit 1
fi

master=$1
pb=$2
arch=$3
branch=$4
tmpdir=$5
md5master=$6
disconnected=$7

cd ${tmpdir}

mkdir -p ${tmpdir}/${branch}/chroot
mkdir -p ${tmpdir}/${branch}/tarballs
if [ "$nocopy" = 0 ]; then
  if [ -f ${tmpdir}/${branch}/tarballs/bindist.tar ]; then
    md5=$(/sbin/md5 ${tmpdir}/${branch}/tarballs/bindist.tar | awk '{print $4}')
  fi
  if [ "${md5}" = "${md5master}" ]; then
    echo "not copying bindist to $(hostname) since it is already up to date"
  else
    echo "copying bindist to $(hostname)"
    if [ ${disconnected} = 0 ]; then  
      cp -p ${pb}/${arch}/${branch}/tarballs/bindist.tar ${tmpdir}/${branch}/tarballs
      cp -p ${pb}/${arch}/${branch}/tarballs/bindist-$(hostname).tar ${tmpdir}/${branch}/tarballs
    fi
  fi
  if [ ${disconnected} = 1 ]; then
    # Prepare all directories, they will be populated by a rsync push from the master
    mkdir -p ${pb}/scripts ${pb}/${arch}/${branch}/ports ${pb}/${arch}/${branch}/src ${pb}/${arch}/${branch}/src ${pb}/${arch}/${branch}/tarballs
    # bindist is a local file, so we don't have to worry about whether nfs caches it
    # This symlink will dangle until the rsync comes along and fills in the destination.
    ln -sf ${pb}/${arch}/${branch}/tarballs/bindist.tar ${tmpdir}/${branch}/tarballs
    ln -sf ${pb}/${arch}/${branch}/tarballs/bindist-$(hostname).tar ${tmpdir}/${branch}/tarballs
  fi
fi

# Clean up the tmpdir
for i in ${tmpdir}/${branch}/chroot/*; do
    ${pb}/scripts/clean-chroot ${arch} ${branch} ${i} 0
    if ! rm -rf $i > /dev/null 2>&1; then
      chflags -R noschg ${i}
      rm -rf ${i}
  fi
done