Disabled dh_strip_nondeterminism to speed up the build
[sven/java-package.git] / lib / javase.sh
1 j2se_readme() {
2     cat << EOF
3 Package for $j2se_title
4 ---
5
6 This package has been automatically created with java-package ($version).
7 All files from the original distribution should have been installed in
8 the directory $jvm_base$j2se_name. Please take a look at this directory for
9 further information.
10 EOF
11 }
12
13 j2se_changelog() {
14     cat << EOF
15 $j2se_package ($j2se_version) unstable; urgency=medium
16
17   * This package was created with java-package ($version).
18
19  -- $maintainer_name <$maintainer_email>  $( date -R )
20 EOF
21 }
22
23 j2se_control() {
24     if test -n "$build_depends"; then
25         build_depends=", $build_depends"
26     fi
27     cat << EOF
28 Source: $j2se_package
29 Section: non-free/devel
30 Priority: optional
31 Maintainer: $maintainer_name <$maintainer_email>
32 Build-Depends: debhelper (>= 9)${build_depends}
33 Standards-Version: 3.9.5
34
35 EOF
36 }
37
38 j2se_copyright() {
39     cat << EOF
40 ----------------------------------------------------------------------
41
42 This file contains a copy of all copyright files found in the original
43 distribution. The original copyright files and further information can
44 be found in the directory $jvm_base$j2se_name and its
45 subdirectories.
46
47 ----------------------------------------------------------------------
48 EOF
49     (
50     cd "$package_dir"
51     find * -type f -iname copyright ! -path debian/copyright |
52     while read file; do
53         cat << EOF
54
55 File: $jvm_base$file
56
57 ----------------------------------------------------------------------
58
59 EOF
60         iconv -f ISO-8859-15 -t UTF-8 "$file" | sed 's/[ \t]*$//'
61         cat << EOF
62
63 ----------------------------------------------------------------------
64 EOF
65     done
66     )
67 }
68
69 j2se_rules() {
70     cat << EOF
71 #!/usr/bin/make -f
72
73 %:
74         dh \$@
75
76 override_dh_compress:
77         dh_compress \$(shell find $j2se_name/man/ -type f ! -name '*.gz' -printf '${jvm_base##/}/%p\n')
78
79 override_dh_shlibdeps:
80         dh_shlibdeps --exclude=fxavcodecplugin --exclude=avplugin -l\$(shell find $j2se_name -type f -name '*.so*' -printf '${jvm_base##/}/%h\n' | sort -u | tr '\n' ':' | sed 's/:\$\$//')
81
82 override_dh_strip_nondeterminism:
83         # Disable dh_strip_nondeterminism to speed up the build
84 EOF
85 }
86
87 j2se_doc_rules() {
88     cat << EOF
89 #!/usr/bin/make -f
90
91 %:
92         dh \$@
93
94 override_dh_strip_nondeterminism:
95         # Disable dh_strip_nondeterminism to speed up the build
96 EOF
97 }
98
99
100 j2se_install_scripts() {
101     cat > "$debian_dir/postinst" << EOF
102 #!/bin/bash
103
104 set -e
105
106 if [ "\$1" = configure ]; then
107
108     # Common functions for all install scripts
109
110     # install_alternatives program_base programs
111     install_alternatives() {
112         program_base="\$1"
113         shift
114         for program in \$*; do
115           if [[ -f "\$program_base/\$program" ]]; then
116             update-alternatives \\
117             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
118             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
119           fi
120         done
121     }
122
123     # install_alternatives_no_man program_base programs
124     install_no_man_alternatives() {
125         program_base="\$1"
126         shift
127         for program in \$*; do
128           if [[ -f "\$program_base/\$program" ]]; then
129             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
130           fi
131         done
132     }
133
134     # install_browser_plugin link_path link_name plugin_name plugin
135     install_browser_plugin() {
136         local link_path="\$1"
137         local link_name="\$2"
138         local plugin_name="\$3"
139         local plugin="\$4"
140         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
141         if [[ -f "\$plugin" ]]; then
142           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
143         fi
144     }
145 EOF
146     if [ "$create_cert_softlinks" == "true" ];then
147         cat >> "$debian_dir/postinst" << EOF
148     for subdir in lib/security jre/lib/security;do
149         if [ -f $jvm_base$j2se_name/\$subdir/cacerts ]; then
150             ln -sf /etc/ssl/certs/java/cacerts $jvm_base$j2se_name/\$subdir/cacerts
151         fi
152     done
153 EOF
154     fi
155     eval "$j2se_install" >> "$debian_dir/postinst"
156
157     cat >> "$debian_dir/postinst" << EOF
158 fi
159
160 #DEBHELPER#
161
162 exit 0
163 EOF
164     chmod 755 "$debian_dir/postinst"
165
166     cat > "$debian_dir/prerm" << EOF
167 #!/bin/bash
168
169 set -e
170
171 case "\$1" in
172     remove | deconfigure)
173
174     # Common functions for all remove scripts
175
176     # remove_alternatives program_base programs
177     remove_alternatives() {
178         program_base="\$1"
179         shift
180         for program in \$*; do
181           update-alternatives --remove "\$program" "\$program_base/\$program"
182         done
183     }
184
185     # remove_browser_plugin plugin_name plugin
186     remove_browser_plugin() {
187         local plugin_name="\$1"
188         local plugin="\$2"
189         update-alternatives --remove "\$plugin_name" "\$plugin"
190     }
191
192 EOF
193     eval "$j2se_remove" >> "$debian_dir/prerm"
194
195     cat >> "$debian_dir/prerm" << EOF
196     ;;
197 esac
198
199 #DEBHELPER#
200
201 exit 0
202 EOF
203     chmod 755 "$debian_dir/prerm"
204 }
205
206 j2se_info() {
207     cat << EOF
208 version="$version"
209 j2se_version="$j2se_version"
210 maintainer_name="$maintainer_name"
211 maintainer_email="$maintainer_email"
212 date="$( date +%Y/%m/%d )"
213 EOF
214 }
215
216 # jinfos prefix program_base programs
217 jinfos() {
218     prefix="$1"
219     program_base="$2"
220     shift ; shift
221     for program in $*; do
222       echo "$prefix $program $program_base$program" 
223     done
224 }
225
226 j2se_build() {
227     if [ -n "$build_source" ]; then
228         local source_dir=${j2se_package}-${j2se_version}
229         echo "    copy ${source_dir} into directory $working_dir/"
230         rm -rf "$working_dir/${source_dir}"
231         cp -r "$package_dir" "$working_dir/${source_dir}"
232         cat << EOF
233
234 The Debian source package has been created in the current directory.
235 You can build the package with:
236
237     cd ${source_dir}
238     dpkg-buildpackage -b -uc -us
239
240 EOF
241     else
242         cd "$package_dir"
243         echo "Create debian package:"
244
245         dpkg-buildpackage -b -uc -us
246         cd "$tmp"
247         local deb_filename="$( echo "${j2se_package}_"*.deb )"
248         echo "    copy $deb_filename into directory $working_dir/"
249         cp "$deb_filename" "$working_dir/"
250         if [ -n "$genchanges" ]; then
251             echo "    dpkg-genchanges"
252             local changes_filename="${deb_filename%.deb}.changes"
253             echo "    copy $changes_filename into directory $working_dir/"
254             cp "$changes_filename" "$working_dir/"
255         fi
256         cat << EOF
257
258 The Debian package has been created in the current directory.
259 You can install the package as root with:
260
261     dpkg -i $deb_filename
262
263 EOF
264     fi
265 }