# package clean utilities # $Id$ # # taken from gentoo (livecd-ng) # #"zapmost" is used to remove an entire directory tree, *except* for certain #specified files. Arg 1 is the tree, args 2+ are the items to keep, which can #be files or directories at the root or deeper levels. #example calls: #zapmost /usr/share/locales en_us #zapmost /usr/share/terminfo l/linux zapmost() { local rootdir rootdir="${1}/" [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1 install -d ${BUILDDIR}/zap local dirs shift local x for x in ${*} do if [ "${x##*/}" = "${x}" ] then #one deep mv ${rootdir}${x} ${BUILDDIR}/zap else #more than one deep; create intermediate directories dirs=${x%/*} install -d ${BUILDDIR}/zap/${dirs} mv ${rootdir}${x} ${BUILDDIR}/zap/${dirs} fi done rm -rf ${rootdir}* mv ${BUILDDIR}/zap/* ${rootdir} }