Annotation of /branches/R11-unstable/include/cleanutils.sminc
Parent Directory | Revision Log
Revision 2 -
(hide annotations)
(download)
Fri Oct 10 13:29:42 2008 UTC (15 years, 11 months ago) by niro
Original Path: trunk/core/include/cleanutils.sminc
File size: 968 byte(s)
Fri Oct 10 13:29:42 2008 UTC (15 years, 11 months ago) by niro
Original Path: trunk/core/include/cleanutils.sminc
File size: 968 byte(s)
import repo
1 | niro | 2 | # package clean utilities |
2 | # $Header: /magellan-cvs/smage/include/cleanutils.sminc,v 1.1 2005/08/07 17:22:43 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 | } |