Annotation of /trunk/include/cleanutils.sminc
Parent Directory | Revision Log
Revision 12656 -
(hide annotations)
(download)
Tue Jun 26 17:59:31 2012 UTC (12 years, 4 months ago) by niro
File size: 1042 byte(s)
Tue Jun 26 17:59:31 2012 UTC (12 years, 4 months ago) by niro
File size: 1042 byte(s)
-let zapmost be more verbose
1 | niro | 2 | # package clean utilities |
2 | niro | 1930 | # $Id$ |
3 | niro | 2 | |
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 | niro | 1930 | zapmost() |
15 | { | ||
16 | niro | 2 | local rootdir |
17 | rootdir="${1}/" | ||
18 | [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1 | ||
19 | niro | 12656 | echo -e "${COLBLUE}*** ${COLGREEN}Running zapmost for ${rootdir}${COLDEFAULT}" |
20 | niro | 2 | install -d ${BUILDDIR}/zap |
21 | local dirs | ||
22 | shift | ||
23 | local x | ||
24 | for x in ${*} | ||
25 | do | ||
26 | if [ "${x##*/}" = "${x}" ] | ||
27 | then | ||
28 | #one deep | ||
29 | mv ${rootdir}${x} ${BUILDDIR}/zap | ||
30 | else | ||
31 | #more than one deep; create intermediate directories | ||
32 | dirs=${x%/*} | ||
33 | install -d ${BUILDDIR}/zap/${dirs} | ||
34 | niro | 2800 | mv ${rootdir}${x} ${BUILDDIR}/zap/${dirs} |
35 | niro | 2 | fi |
36 | done | ||
37 | rm -rf ${rootdir}* | ||
38 | mv ${BUILDDIR}/zap/* ${rootdir} | ||
39 | niro | 12656 | echo -e "${COLBLUE}=== ${COLGREEN}zapmost done for ${rootdir}${COLDEFAULT}" |
40 | niro | 2 | } |