Annotation of /smage/trunk/include/cleanutils.sminc
Parent Directory | Revision Log
Revision 3 -
(hide annotations)
(download)
Sat Jan 2 16:59:51 2010 UTC (14 years, 8 months ago) by niro
File size: 885 byte(s)
Sat Jan 2 16:59:51 2010 UTC (14 years, 8 months ago) by niro
File size: 885 byte(s)
-initial smage includes
1 | niro | 3 | # package clean utilities |
2 | # $Id$ | ||
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 | { | ||
16 | local rootdir | ||
17 | rootdir="${1}/" | ||
18 | [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1 | ||
19 | install -d ${BUILDDIR}/zap | ||
20 | local dirs | ||
21 | shift | ||
22 | local x | ||
23 | for x in ${*} | ||
24 | do | ||
25 | if [ "${x##*/}" = "${x}" ] | ||
26 | then | ||
27 | #one deep | ||
28 | mv ${rootdir}${x} ${BUILDDIR}/zap | ||
29 | else | ||
30 | #more than one deep; create intermediate directories | ||
31 | dirs=${x%/*} | ||
32 | install -d ${BUILDDIR}/zap/${dirs} | ||
33 | mv ${rootdir}${x} ${BUILDDIR}/zap/${dirs} | ||
34 | fi | ||
35 | done | ||
36 | rm -rf ${rootdir}* | ||
37 | mv ${BUILDDIR}/zap/* ${rootdir} | ||
38 | } |