Commit | Line | Data |
---|---|---|
f28ac29c TO |
1 | #!/bin/bash |
2 | ||
3 | ## Cleanup the vendor tree. The main issue here is that civi Civi is | |
4 | ## deployed as a module inside a CMS, so all its source-code gets published. | |
5 | ## Some libraries distribute admin tools and sample files which should not | |
6 | ## be published. | |
7 | ## | |
8 | ## This script should be idempotent -- if you rerun it several times, it | |
9 | ## should always produce the same post-condition. | |
10 | ||
11 | ############################################################################## | |
12 | ## usage: safe_delete <relpath...> | |
13 | function safe_delete() { | |
14 | for file in "$@" ; do | |
15 | if [ -z "$file" ]; then | |
16 | echo "Skip: empty file name" | |
17 | elif [ -e "$file" ]; then | |
18 | rm -rf "$file" | |
19 | fi | |
20 | done | |
21 | } | |
22 | ||
23 | ############################################################################## | |
24 | ## usage: make_font_cache > font-cache.php | |
25 | function make_font_cache() { | |
26 | cat <<EOFONT | |
27 | <?php return array ( | |
28 | 'sans-serif' => | |
29 | array ( | |
30 | 'normal' => DOMPDF_DIR . '/lib/fonts/Helvetica', | |
31 | 'bold' => DOMPDF_DIR . '/lib/fonts/Helvetica-Bold', | |
32 | 'italic' => DOMPDF_DIR . '/lib/fonts/Helvetica-Oblique', | |
33 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Helvetica-BoldOblique', | |
34 | ), | |
35 | 'times' => | |
36 | array ( | |
37 | 'normal' => DOMPDF_DIR . '/lib/fonts/Times-Roman', | |
38 | 'bold' => DOMPDF_DIR . '/lib/fonts/Times-Bold', | |
39 | 'italic' => DOMPDF_DIR . '/lib/fonts/Times-Italic', | |
40 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Times-BoldItalic', | |
41 | ), | |
42 | 'times-roman' => | |
43 | array ( | |
44 | 'normal' => DOMPDF_DIR . '/lib/fonts/Times-Roman', | |
45 | 'bold' => DOMPDF_DIR . '/lib/fonts/Times-Bold', | |
46 | 'italic' => DOMPDF_DIR . '/lib/fonts/Times-Italic', | |
47 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Times-BoldItalic', | |
48 | ), | |
49 | 'courier' => | |
50 | array ( | |
51 | 'normal' => DOMPDF_DIR . '/lib/fonts/Courier', | |
52 | 'bold' => DOMPDF_DIR . '/lib/fonts/Courier-Bold', | |
53 | 'italic' => DOMPDF_DIR . '/lib/fonts/Courier-Oblique', | |
54 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Courier-BoldOblique', | |
55 | ), | |
56 | 'helvetica' => | |
57 | array ( | |
58 | 'normal' => DOMPDF_DIR . '/lib/fonts/Helvetica', | |
59 | 'bold' => DOMPDF_DIR . '/lib/fonts/Helvetica-Bold', | |
60 | 'italic' => DOMPDF_DIR . '/lib/fonts/Helvetica-Oblique', | |
61 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Helvetica-BoldOblique', | |
62 | ), | |
63 | 'zapfdingbats' => | |
64 | array ( | |
65 | 'normal' => DOMPDF_DIR . '/lib/fonts/ZapfDingbats', | |
66 | 'bold' => DOMPDF_DIR . '/lib/fonts/ZapfDingbats', | |
67 | 'italic' => DOMPDF_DIR . '/lib/fonts/ZapfDingbats', | |
68 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/ZapfDingbats', | |
69 | ), | |
70 | 'symbol' => | |
71 | array ( | |
72 | 'normal' => DOMPDF_DIR . '/lib/fonts/Symbol', | |
73 | 'bold' => DOMPDF_DIR . '/lib/fonts/Symbol', | |
74 | 'italic' => DOMPDF_DIR . '/lib/fonts/Symbol', | |
75 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Symbol', | |
76 | ), | |
77 | 'serif' => | |
78 | array ( | |
79 | 'normal' => DOMPDF_DIR . '/lib/fonts/Times-Roman', | |
80 | 'bold' => DOMPDF_DIR . '/lib/fonts/Times-Bold', | |
81 | 'italic' => DOMPDF_DIR . '/lib/fonts/Times-Italic', | |
82 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Times-BoldItalic', | |
83 | ), | |
84 | 'monospace' => | |
85 | array ( | |
86 | 'normal' => DOMPDF_DIR . '/lib/fonts/Courier', | |
87 | 'bold' => DOMPDF_DIR . '/lib/fonts/Courier-Bold', | |
88 | 'italic' => DOMPDF_DIR . '/lib/fonts/Courier-Oblique', | |
89 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Courier-BoldOblique', | |
90 | ), | |
91 | 'fixed' => | |
92 | array ( | |
93 | 'normal' => DOMPDF_DIR . '/lib/fonts/Courier', | |
94 | 'bold' => DOMPDF_DIR . '/lib/fonts/Courier-Bold', | |
95 | 'italic' => DOMPDF_DIR . '/lib/fonts/Courier-Oblique', | |
96 | 'bold_italic' => DOMPDF_DIR . '/lib/fonts/Courier-BoldOblique', | |
97 | ), | |
98 | ) ?> | |
99 | EOFONT | |
100 | } | |
101 | ||
102 | function make_font_readme() { | |
103 | cat <<EOREADME | |
104 | To save space in the final distribution we have not included the DejaVu family of fonts. You can get these fonts from: | |
105 | ||
106 | http://code.google.com/p/dompdf/ | |
107 | ||
108 | Download the latest version and copy the font files from the lib/fonts directories to this directory. | |
109 | EOREADME | |
110 | } | |
111 | ||
112 | ############################################################################## | |
113 | ## Remove example/CLI scripts. They're not needed and increase the attack-surface. | |
114 | safe_delete vendor/dompdf/dompdf/dompdf.php | |
115 | safe_delete vendor/dompdf/dompdf/www | |
116 | safe_delete vendor/phenx/php-font-lib/www | |
117 | ||
118 | # Remove DejaVu fonts. They add 12mb. | |
119 | safe_delete vendor/dompdf/dompdf/lib/fonts/DejaVu* | |
120 | make_font_cache > vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.dist.php | |
121 | make_font_readme > vendor/dompdf/dompdf/lib/fonts/README.DejaVuFonts.txt |