diff options
author | kris <kris@FreeBSD.org> | 2004-03-08 02:02:57 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2004-03-08 02:02:57 +0000 |
commit | 6d6d0c4e227dd01257082b9581a27e980850ff80 (patch) | |
tree | 7dc1eb67b97bba456ebd0de2caec1546d355b60c | |
parent | 65530cea5ca32cd9c5f682ed35918b6fd82e8809 (diff) | |
download | FreeBSD-ports-6d6d0c4e227dd01257082b9581a27e980850ff80.zip FreeBSD-ports-6d6d0c4e227dd01257082b9581a27e980850ff80.tar.gz |
Walk through a package set and prune files that are not listed in INDEX
(e.g. packages from a previous build run, packages that incorrectly modify
their PORTNAME at install-time, etc.) as well as dangling symlinks.
-rwxr-xr-x | Tools/portbuild/scripts/prunepkgs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Tools/portbuild/scripts/prunepkgs b/Tools/portbuild/scripts/prunepkgs new file mode 100755 index 0000000..f46eaaf --- /dev/null +++ b/Tools/portbuild/scripts/prunepkgs @@ -0,0 +1,66 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then + echo "usage: prunepkgs <indexfile> <pkgdir> [-dummy]" + return 1 +fi +index=$1 +pkgdir=$2 + +if [ $# -eq 3 -a "$3" = "-dummy" ]; then + dummy=1; +else + dummy=0; +fi + +testprunelink() { + if [ ! -e $1/ ]; then + dest=$(readlink $1) + echo "$1 -> $dest pruned." + if [ "${dummy}" = "0" ]; then + rm -f $1 + fi + fi +} + +# Set up work dir + +tmpdir=$(mktemp -d -t prunepkgs) +trap "rm -rf $tmpdir; exit 1" 1 2 3 5 10 13 15 + +# Check for non-package files + +extras=$(find ${pkgdir} -type f \! \( -name INDEX -o -name CHECKSUM.MD5 -o -name \*.tgz -o -name \*.tbz \) ) +echo "==> Removing extra files" +echo $extras +if [ "x${extras}" != "x" ]; then + if [ "${dummy}" = "0" ]; then + rm -f ${extras} + fi +fi + +# Check for files not present in INDEX +echo "==> Removing extra package files" + +find $pkgdir/All -type f -name \*.tgz -o -name \*.tbz | sed -e "s,${pkgdir}/All/,," -e 's,\.tbz$,,' -e 's,\.tgz$,,' |sort > ${tmpdir}/files +cut -f 1 -d '|' ${index} |sort > ${tmpdir}/packages + +extras=$(comm -2 -3 ${tmpdir}/files ${tmpdir}/packages) +echo $extras +if [ "${dummy}" = "0" ]; then + for i in $extras; do + rm -f $pkgdir/All/${i}.tgz $pkgdir/All/${i}.tbz + done +fi + +rm -rf ${tmpdir} + +# Look for dead links and prune them +echo "==> Removing dead symlinks" + +links=$(find $pkgdir -type l) +for i in $links; do + testprunelink $i +done + + |