Annotation of /smage/trunk/include/cleanutils.sminc
Parent Directory | Revision Log
Revision 15349 -
(hide annotations)
(download)
Wed Aug 26 07:50:02 2020 UTC (4 years ago) by niro
File size: 1066 byte(s)
Wed Aug 26 07:50:02 2020 UTC (4 years ago) by niro
File size: 1066 byte(s)
-fixed evaluation issues of bash if run from sysroot '/'
1 | niro | 1661 | # package clean utilities |
2 | niro | 1664 | # $Id$ |
3 | niro | 1661 | |
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 | 1664 | zapmost() |
15 | { | ||
16 | niro | 1661 | local rootdir |
17 | rootdir="${1}/" | ||
18 | [ ! -e "$rootdir" ] && echo "zapmost: $rootdir not found; skipping..." && return 1 | ||
19 | niro | 3579 | echo -e "${COLBLUE}*** ${COLGREEN}Running zapmost for ${rootdir}${COLDEFAULT}" |
20 | niro | 15349 | pushd ${rootdir} |
21 | niro | 1661 | install -d ${BUILDDIR}/zap |
22 | local dirs | ||
23 | shift | ||
24 | local x | ||
25 | for x in ${*} | ||
26 | do | ||
27 | if [ "${x##*/}" = "${x}" ] | ||
28 | then | ||
29 | #one deep | ||
30 | mv ${rootdir}${x} ${BUILDDIR}/zap | ||
31 | else | ||
32 | #more than one deep; create intermediate directories | ||
33 | dirs=${x%/*} | ||
34 | install -d ${BUILDDIR}/zap/${dirs} | ||
35 | niro | 1664 | mv ${rootdir}${x} ${BUILDDIR}/zap/${dirs} |
36 | niro | 1661 | fi |
37 | done | ||
38 | rm -rf ${rootdir}* | ||
39 | mv ${BUILDDIR}/zap/* ${rootdir} | ||
40 | niro | 15349 | popd |
41 | niro | 3579 | echo -e "${COLBLUE}=== ${COLGREEN}zapmost done for ${rootdir}${COLDEFAULT}" |
42 | niro | 1661 | } |