summaryrefslogtreecommitdiff
path: root/Tools/portbuild/scripts/setupnode
blob: 307bb3ec9f596c53abe035499f44974803b11ac1 (plain)
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
#!/bin/sh
nocopy=0
if [ "x$1" = "x-nocopy" ]; then
  nocopy=1
  shift
fi
if [ $# != 4 ]; then
  echo "usage: $0 [-nocopy] master portbuilddir branch md5"
  exit 1
fi
if [ $(echo $(/sbin/mount | grep "$2/.*read-only" | awk '{print $3}' | wc -c)) != 0 ]; then
  /sbin/umount -f $(/sbin/mount | grep "$2/.*read-only" | awk '{print $3}')
fi

if ! rm -rf $2/*/chroot/* >/dev/null 2>&1; then
  chflags -R noschg $2/*/chroot/*
  rm -rf $2/*/chroot/*
fi

killall make fetch >/dev/null 2>&1

mkdir -p $2/scripts $2/$3/tarballs $2/$3/chroot

scp -p $1:$2/scripts/portbuild $2/scripts

if [ "$nocopy" = 0 ]; then
  md5=$(/sbin/md5 $2/$3/tarballs/bindist.tar | awk '{print $4}')
  if [ "$md5" = "$4" ]; then
    echo "not copying bindist to $(hostname -s) since it is already up to date"
  else
    echo "copying bindist to $(hostname -s)"
    scp -p $1:$2/$3/tarballs/bindist.tar $2/$3/tarballs
  fi
fi