Magellan Linux

Annotation of /smage/branches/branch_0.9.0/include/cleanutils.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations) (download)
Sun Jan 11 00:50:17 2009 UTC (15 years, 5 months ago) by niro
File size: 974 byte(s)
"copied"
1 niro 3 # package clean utilities
2     # $Header: /alx-cvs/smage-eglibc/include/cleanutils.sminc,v 1.1.1.1 2008/02/27 09:26:22 niro Exp $
3    
4     #
5     # taken from gentoo (livecd-ng)
6     #
7     #"zapmost" is used to remove an entire directory tree, *except* for certain
8     #specified files. Arg 1 is the tree, args 2+ are the items to keep, which can
9     #be files or directories at the root or deeper levels.
10    
11     #example calls:
12     #zapmost /usr/share/locales en_us
13     #zapmost /usr/share/terminfo l/linux
14     zapmost() {
15     local rootdir
16     rootdir="${1}/"
17     [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1
18     install -d ${BUILDDIR}/zap
19     local dirs
20     shift
21     local x
22     for x in ${*}
23     do
24     if [ "${x##*/}" = "${x}" ]
25     then
26     #one deep
27     mv ${rootdir}${x} ${BUILDDIR}/zap
28     else
29     #more than one deep; create intermediate directories
30     dirs=${x%/*}
31     install -d ${BUILDDIR}/zap/${dirs}
32     mv ${rootdir}${x} ${BUILDDIR}/zap/${x}
33     fi
34     done
35     rm -rf ${rootdir}*
36     mv ${BUILDDIR}/zap/* ${rootdir}
37     }