RN rnmake  3.0.0
tarball-src-filter.sh
1 #!/bin/sh
2 # Package: RN Makefile System Utility
3 # File: tarball-src-filter.sh
4 # Desc: Filters package, excluding all non-source files
5 # Usage: tarball-src-filter.sh <pkgroot>
6 #
7 # /*! \file */
8 # /*! \cond RNMAKE_DOXY*/
9 
10 pkgroot="${1}"
11 
12 #
13 # Recurse through directories and filter out "non-source" files and directories.
14 # In awk, regular expression rules are compared against the input records until
15 # one fires which will execute the associated action. Actions are:
16 # 'next' skips current record (i.e. filter out from stream)
17 # 'print $0' prints the line line (i.e. allow).
18 # Note: Order is important. The last record allows all unfiltered lines to be
19 # included. Keep last.
20 #
21 find ${pkgroot} -print | \
22 gawk '
23  /\.svn/ { next }
24  /\.deps/ { next }
25  /\/obj/ { next }
26  /\/dist/ { next }
27  /\/loc/ { next }
28  /\/build/ { next }
29  /\/hw/ { next }
30  /\/fw/ { next }
31  /\/os/ { next }
32  /\/3rdparty/ { next }
33  /docs\/doxy/ { print $0 }
34  /docs\/images/ { next }
35  /docs\/.*\.doxy/ { print $0 }
36  /docs\/.*/ { next }
37  /docs/ { next }
38  /\.exe/ { next }
39  /\.a/ { next }
40  /\.so/ { next }
41  /\.o/ { next }
42  /\.out/ { next }
43  /\.log/ { next }
44  /\.pyc/ { next }
45  /\.pyo/ { next }
46  /\.done/ { next }
47  /.*/ { print $0 }'
48 
49 
50 # The old way - too limited
51 #find ${pkgroot} \( \
52 # -regex "${pkgroot}/docs/[^di].*" -or \
53 # -wholename "${pkgroot}/hw" -or -name hw -or \
54 # -wholename "${pkgroot}/fw" -or -name fw -or \
55 # -wholename "${pkgroot}/os" -or -name os -or \
56 # -wholename "${pkgroot}/dist" -or -name dist -or \
57 # -wholename "${pkgroot}/loc" -or -name loc -or \
58 # -name '*.svn*' -or -wholename '.svn' -or \
59 # -wholename '*.deps*' -or -name '.deps' -or \
60 # -wholename '*obj*' -or -wholename 'obj' -or -wholename '*.o' -or \
61 # -wholename '*.out' -or -wholename '*.log' -or \
62 # -wholename '*.pyc' -or -wholename '*.pyo' \
63 # \) -prune -or -print | \