#!/bin/sh # ~jhs/public_html/bin/.sh/distfiles_cmpd by jhs@ # Removes duplicate distfiles. # I keep my distfiles in seperate smaller directories, # segregated by release, with newest release directory containing most files, # but a few older directories holding more stuff I need for legacy support. # This shell script strips identical copies. # See also: /site/domain/this/etc/make.conf.common # Alternates I havent tried: # cd /usr/ports/sysutils/portupgrade ; make install ; rehash # portsclean -D # Remove all distfiles not ref'd by ports # portsclean -DD # Remove all distfiles not used by an installed port # cd /usr/ports ; make distclean # # Uses /usr/ports/Mk/bsd.port.mk --distclean # bleat=echo # Uncomment for Debug session. # DBG="distfiles_cmpd_debug: " bleat=true # Uncomment for Normal Use DBG="" outer() { # $bleat "${DBG}Outer0 $*" del=$1 shift # $bleat "${DBG}Outer1 $del : $*" for i in $* do $bleat "${DBG}Calling Inner $del : $*" inner $del "$*" del=$1 shift done } inner() { # $bleat "${DBG}Inner $1 : $2 :" for i in $2 do # $bleat "${DBG}zap $1 $i" zap $1 $i done } zap() { $bleat "${DBG}Stripping $1 against $2" ( cd $1 && find . -type f -exec cmpd -d -s {} $2 \; ) } # Start Of Main. D=/pub/FreeBSD/dists dirs= sense=`cd /usr/ports/distfiles;/bin/pwd` # not `pwd` as it returns distfiles` sense2=`basename $sense` if [ "$sense2" = "distfiles" ]; then # You have a local distfiles/ to be stripped. dirs="${dirs} /usr/ports/distfiles" # If this happens to be the same as another directory in the # $dirs path, for each duplicate file cmpd will warn: # ...... share same device (major & minor) & inode , # link count is 1; Skipping. else # You do not have a local distfiles/ to be stripped. # (Your /usr/ports/distfiles is presumably just a symbolic link # to eg $D/5.3-RELEASE) fi # Next directories are in strip order, ie first gets stripped against # reference 2nd etc. Best in approx newest release last. # In approx reverse order to /site/domain/this/etc/make.conf.common # Not in simple 4 before 5 numeric order as releases 4.x 5.x & 6.x are # interleaved in time. # For release dates see http://www.freebsd.org/releases/index.html # /usr/www/en/releases dirs="${dirs} /host/gate/usr/ports/distfiles" dirs="${dirs} $D/common" # individual hosts'' local copies # Various hosts running different releases share this via sym links. dirs="${dirs} $D/current" # Shortly before a new release is due, ensure this has most distfiles: # cd /pri/FreeBSD/branches/-current/ports # setenv PORTSDIR `pwd` ; nice nice make -k -j 5 BATCH=yes fetch # Were I not to list current last, dists would overflow, with dups. # dirs="${dirs} $D/5.0-RELEASE" # 2003.01 # dirs="${dirs} $D/4.8-RELEASE" # 2003.04 dirs="${dirs} $D/5.1-RELEASE" # 2003.06 # dirs="${dirs} $D/4.9-RELEASE" # 2003.10 # dirs="${dirs} $D/5.2-RELEASE" # 2004.01 # dirs="${dirs} $D/5.2.1-RELEASE" # 2004.02.25 dirs="${dirs} $D/4.10-RELEASE" # 2004.05 # dirs="${dirs} $D/5.3-RELEASE" # 2004.11 dirs="${dirs} $D/4.11-RELEASE" # 2005.01 # dirs="${dirs} $D/5.4-RELEASE" # 2005.05.09 # dirs="${dirs} $D/6.0-RELEASE" # src:2005.11 ports:2005.08 dirs="${dirs} $D/5.5-RELEASE" # 2006.05.25 # Although 5.5 came out after 6.1 I'm not aiming to build more 5 hosts. dirs="${dirs} $D/6.1-RELEASE" # 2006.05.08 dirs="${dirs} $D/6.2-RELEASE" # 2006.11.05 (ports, not src) # Shortly after a release is made, I list the release last # & run a make fetch, as best time to grab stuff that may later migrate # elsewhere on the net & be harder to find. dirs="${dirs} $D/6.3-RELEASE" # 2008.01.15 dirs="${dirs} $D/7.0-RELEASE" # 2008.02.28 dirs="${dirs} $D/jhs" # Estic for which I am master repository. # Word perfect, that I'm licensed to use, & dont want stupid # scripts forcing me to fetch again. cd $D outer ${dirs} # echo "$D/common/ should be empty, looking now:" # ls $D/common