Recommit this PackageMaker project; CVS had misaligned it with the 10.5+ PCRE version
[OSXPackageBuilder.git] / constructPkgContent.sh
1 #!/bin/sh
2
3 # File        :  constructPkgContent.sh
4 #
5 # Purpose     :  Create the hierarchy of folders and files that will 
6 #                comprise the installation package.
7 #
8 # Copyright   :  Written by and Copyright (C) 2001-2012 the
9 #                Privoxy team. http://www.privoxy.org/
10 #
11 #                This program is free software; you can redistribute it
12 #                and/or modify it under the terms of the GNU General
13 #                Public License as published by the Free Software
14 #                Foundation; either version 2 of the License, or (at
15 #                your option) any later version.
16 #
17 #                This program is distributed in the hope that it will
18 #                be useful, but WITHOUT ANY WARRANTY; without even the
19 #                implied warranty of MERCHANTABILITY or FITNESS FOR A
20 #                PARTICULAR PURPOSE.  See the GNU General Public
21 #                License for more details.
22 #
23 #                The GNU General Public License should be included with
24 #                this file.  If not, you can view it at
25 #                http://www.gnu.org/copyleft/gpl.html
26 #                or write to the Free Software Foundation, Inc.,
27 #                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #                USA
29 #
30 # Modification : If you modify this file please consider whether your 
31 #                changes ought to be passed back to the OSXPackageBuilder
32 #                module.
33 #
34
35 # Use the common script to locate the directory containing Privoxy's source ($SOURCEDIR)
36 . ./common.sh
37
38 # Remove existing 'pkg content' folder if found
39 echo ""
40 echo "Remove existing 'pkg content' folder if found"
41 rm -rf pkg\ content
42
43 # Copy the package skeleton (the unchanging content) to a new folder named 'pkg content'
44 echo ""
45 echo "Copy the package skeleton (the unchanging content) to a new folder named 'pkg content'"
46 echo ""
47 cp -vR pkg\ content\ skeleton pkg\ content
48
49 # Copy the compiled privoxy binary from the '${SOURCE_DIR}' directory
50 echo ""
51 echo ""
52 echo "Copy the compiled privoxy binary from the '${SOURCE_DIR}' directory"
53 echo ""
54 cp -v ../${SOURCE_DIR}/privoxy pkg\ content/usr/local/sbin
55
56 # Copy the configuration hierarchy from the '${SOURCE_DIR}' directory
57 echo ""
58 echo ""
59 echo "Copy most of the configuration hierarchy from the '${SOURCE_DIR}' directory"
60 echo ""
61 for i in default.action default.filter match-all.action trust user.action user.filter templates; do
62         if [ "$i" = "templates" ]; then
63                 # for the templates subfolder copy all files therein
64                 cp -vR ../${SOURCE_DIR}/$i pkg\ content/usr/local/etc/privoxy/vanilla/$i
65         else
66                 # for all regular files just copy them across
67                 cp -v ../${SOURCE_DIR}/$i pkg\ content/usr/local/etc/privoxy/vanilla/$i
68         fi
69 done
70
71 # Enter the correct values for confdir and logdir into the config file 
72 echo ""
73 echo ""
74 echo "Copy the config file from the '${SOURCE_DIR}' directory, modifying the confdir, logdir and user-manual settings in passing"
75 echo ""
76 sed 's/confdir ./confdir \/usr\/local\/etc\/privoxy/g' ../${SOURCE_DIR}/config > pkg\ content/usr/local/etc/privoxy/vanilla/config_temp1
77 sed 's/logdir ./logdir \/var\/log\/privoxy/g' pkg\ content/usr/local/etc/privoxy/vanilla/config_temp1 > pkg\ content/usr/local/etc/privoxy/vanilla/config_temp2
78 sed 's/#user-manual http:\/\/www.privoxy.org\/user-manual\//user-manual \/usr\/local\/share\/doc\/privoxy\/user-manual\//g' pkg\ content/usr/local/etc/privoxy/vanilla/config_temp2 > pkg\ content/usr/local/etc/privoxy/vanilla/config
79 rm -f pkg\ content/usr/local/etc/privoxy/vanilla/config_temp*
80
81 # Copy the documentation hierarchy from the '${SOURCE_DIR}' directory
82 echo ""
83 echo ""
84 echo "Copy the documentation hierarchy from the '${SOURCE_DIR}' directory"
85 echo ""
86 # copy the required directory hierarchies
87 for i in developer-manual faq images man-page team user-manual; do
88         cp -vR ../${SOURCE_DIR}/doc/webserver/$i pkg\ content/usr/local/share/doc/privoxy/$i
89 done
90 # copy the top-level files
91 for i in announce.txt p_doc.css privoxy-index.html; do
92         cp -v ../${SOURCE_DIR}/doc/webserver/$i pkg\ content/usr/local/share/doc/privoxy/$i
93 done
94 # copy p_doc.css down into user-manual subdir (as per the make install target)
95 cp -v ../${SOURCE_DIR}/doc/webserver/p_doc.css pkg\ content/usr/local/share/doc/privoxy/user-manual/p_doc.css
96 # copy the project's AUTHORS, ChangeLog, LICENSE and README files
97 for i in AUTHORS ChangeLog LICENSE README; do
98         cp -v ../${SOURCE_DIR}/$i pkg\ content/usr/local/share/doc/privoxy/$i
99 done
100
101 # Copy the manpage from the '${SOURCE_DIR}' directory
102 echo ""
103 echo ""
104 echo "Copy the manpage from the '${SOURCE_DIR}' directory"
105 echo ""
106 cp -v ../${SOURCE_DIR}/privoxy.1 pkg\ content/usr/local/share/man/man1
107
108 # Optionally copy the PCRE libraries
109 if [ "$1" == "-pcre" ]; then
110         echo ""
111         echo ""
112         echo "Copy the external PCRE libraries"
113         echo ""
114         mkdir pkg\ content/usr/local/lib
115         cp -v /usr/local/lib/libpcre* pkg\ content/usr/local/lib
116         mkdir pkg\ content/usr/local/lib/pkgconfig
117         cp -v /usr/local/lib/pkgconfig/libpcre* pkg\ content/usr/local/lib/pkgconfig
118 fi
119
120 # Remove CVS administration files
121 echo ""
122 echo ""
123 echo "Remove CVS administration files"
124 echo ""
125 find pkg\ content -name CVS.sandboxinfo -exec rm -rf {} \;
126 find pkg\ content -name CVS -exec rm -rf {} \;
127