aboutsummaryrefslogtreecommitdiff
path: root/Tools/portbuild/scripts/clean-chroot
blob: bb9a89925e1c245f71f0e13d39bb461b656fb1df (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
#!/bin/sh

arch=$1
branch=$2
chroot=$3
noclean=$4

# directories to clean
cleandirs="/usr/local /usr/X11R6 /compat /var/db/pkg"

if [ `realpath ${chroot}` = "/" ]; then
  # Don't spam the root file system if something has gone wrong!
  exit 1
fi

#umount ${chroot}/proc

if [ ${arch} = "i386" ]; then
  chroot ${chroot} umount -f /compat/linux/proc
fi
  
umount -f ${chroot}/a/ports 2> /dev/null
umount -f ${chroot}/usr/opt/doc 2> /dev/null
umount -f ${chroot}/usr/src 2> /dev/null
umount -f ${chroot}/dev 2> /dev/null

if [ $noclean = 0 ]; then
  rm -rf ${chroot}/tmp/*
  for dir in ${cleandirs}; do
    if ! rm -rf ${chroot}${dir} >/dev/null 2>&1; then
      chflags -R noschg ${chroot}${dir}
      rm -rf ${chroot}${dir} >/dev/null 2>&1
    fi
  done
  chroot ${chroot} /sbin/ldconfig -R
  if [ ${arch} = "i386" ]; then
	chroot ${chroot} /sbin/ldconfig -aout -R
  fi
  rm -rf ${chroot}/var/db/pkg/*
  rm -rf ${chroot}/used
fi