Annotation of /smage/branches/alx-0_6_0/include/cleanutils.sminc
Parent Directory | Revision Log
Revision 1661 -
(hide annotations)
(download)
Sat Jan 22 23:14:38 2011 UTC (13 years, 8 months ago) by niro
File size: 963 byte(s)
Sat Jan 22 23:14:38 2011 UTC (13 years, 8 months ago) by niro
File size: 963 byte(s)
added includes
1 | niro | 1661 | # package clean utilities |
2 | # $Header: /alx-cvs/smage/include/cleanutils.sminc,v 1.1 2005/08/07 17:25:08 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 | } |