]> git.sven.stormbind.net Git - sven/java-package.git/blob
ed0745c
[sven/java-package.git] /
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.7
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 # Exclude libraries that pull in ALSA or OpenGL which are not needed in normal operation
74 EXCLUDE_LIBS = \\
75         --exclude=avplugin \\
76         --exclude=fxavcodecplugin \\
77         --exclude=libjsoundalsa.so \\
78 EOF
79     for lib in $exlude_libs; do
80         printf '\t--exclude=%s \\\n' "$lib"
81     done
82     cat << EOF
83         \$(NULL)
84
85 %:
86         dh \$@
87
88 override_dh_compress:
89         dh_compress \$(shell find $j2se_name/man/ -type f ! -name '*.gz' -printf '${jvm_base##/}/%p\n')
90
91 override_dh_shlibdeps:
92         dh_shlibdeps \$(EXCLUDE_LIBS) -l\$(shell find $j2se_name -type f -name '*.so*' -printf '${jvm_base##/}/%h\n' | sort -u | tr '\n' ':' | sed 's/:\$\$//')
93
94 override_dh_strip_nondeterminism:
95         # Disable dh_strip_nondeterminism to speed up the build
96 EOF
97 }
98
99 j2se_doc_rules() {
100     cat << EOF
101 #!/usr/bin/make -f
102
103 %:
104         dh \$@
105
106 override_dh_strip_nondeterminism:
107         # Disable dh_strip_nondeterminism to speed up the build
108 EOF
109 }
110
111
112 j2se_install_scripts() {
113     cat > "$debian_dir/postinst" << EOF
114 #!/bin/bash
115
116 set -e
117
118 if [ "\$1" = configure ]; then
119
120     # Common functions for all install scripts
121
122     # install_alternatives program_base programs
123     install_alternatives() {
124         program_base="\$1"
125         shift
126         for program in \$*; do
127           if [[ -f "\$program_base/\$program" ]]; then
128             update-alternatives \\
129             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
130             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
131           fi
132         done
133     }
134
135     # install_alternatives_no_man program_base programs
136     install_no_man_alternatives() {
137         program_base="\$1"
138         shift
139         for program in \$*; do
140           if [[ -f "\$program_base/\$program" ]]; then
141             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
142           fi
143         done
144     }
145
146     # install_browser_plugin link_path link_name plugin_name plugin
147     install_browser_plugin() {
148         local link_path="\$1"
149         local link_name="\$2"
150         local plugin_name="\$3"
151         local plugin="\$4"
152         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
153         if [[ -f "\$plugin" ]]; then
154           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
155         fi
156     }
157 EOF
158     if [ "$create_cert_softlinks" == "true" ];then
159         cat >> "$debian_dir/postinst" << EOF
160     for subdir in lib/security jre/lib/security;do
161         if [ -f $jvm_base$j2se_name/\$subdir/cacerts ]; then
162             ln -sf /etc/ssl/certs/java/cacerts $jvm_base$j2se_name/\$subdir/cacerts
163         fi
164     done
165 EOF
166     fi
167     eval "$j2se_install" >> "$debian_dir/postinst"
168
169     cat >> "$debian_dir/postinst" << EOF
170 fi
171
172 #DEBHELPER#
173
174 exit 0
175 EOF
176     chmod 755 "$debian_dir/postinst"
177
178     cat > "$debian_dir/prerm" << EOF
179 #!/bin/bash
180
181 set -e
182
183 case "\$1" in
184     remove | deconfigure)
185
186     # Common functions for all remove scripts
187
188     # remove_alternatives program_base programs
189     remove_alternatives() {
190         program_base="\$1"
191         shift
192         for program in \$*; do
193           update-alternatives --remove "\$program" "\$program_base/\$program"
194         done
195     }
196
197     # remove_browser_plugin plugin_name plugin
198     remove_browser_plugin() {
199         local plugin_name="\$1"
200         local plugin="\$2"
201         update-alternatives --remove "\$plugin_name" "\$plugin"
202     }
203
204 EOF
205     eval "$j2se_remove" >> "$debian_dir/prerm"
206
207     cat >> "$debian_dir/prerm" << EOF
208     ;;
209 esac
210
211 #DEBHELPER#
212
213 exit 0
214 EOF
215     chmod 755 "$debian_dir/prerm"
216 }
217
218 j2se_info() {
219     cat << EOF
220 version="$version"
221 j2se_version="$j2se_version"
222 maintainer_name="$maintainer_name"
223 maintainer_email="$maintainer_email"
224 date="$( date +%Y/%m/%d )"
225 EOF
226 }
227
228 # jinfos prefix program_base programs
229 jinfos() {
230     prefix="$1"
231     program_base="$2"
232     shift ; shift
233     for program in $*; do
234       echo "$prefix $program $program_base$program" 
235     done
236 }
237
238 j2se_build() {
239     if [ -n "$build_source" ]; then
240         local source_dir=${j2se_package}-${j2se_version}
241         echo "    copy ${source_dir} into directory $working_dir/"
242         rm -rf "$working_dir/${source_dir}"
243         cp -r "$package_dir" "$working_dir/${source_dir}"
244         cat << EOF
245
246 The Debian source package has been created in the current directory.
247 You can build the package with:
248
249     cd ${source_dir}
250     dpkg-buildpackage -b -uc -us
251
252 EOF
253     else
254         cd "$package_dir"
255         echo "Create debian package:"
256
257         dpkg-buildpackage -b -uc -us
258         cd "$tmp"
259         local deb_filename="$( echo "${j2se_package}_"*.deb )"
260         echo "    copy $deb_filename into directory $working_dir/"
261         cp "$deb_filename" "$working_dir/"
262         if [ -n "$genchanges" ]; then
263             echo "    dpkg-genchanges"
264             local changes_filename="${deb_filename%.deb}.changes"
265             echo "    copy $changes_filename into directory $working_dir/"
266             cp "$changes_filename" "$working_dir/"
267         fi
268         cat << EOF
269
270 The Debian package has been created in the current directory.
271 You can install the package as root with:
272
273     dpkg -i $deb_filename
274
275 EOF
276     fi
277 }
278
279 # build debian package
280 j2se_run() {
281     echo
282     diskfree "$j2se_required_space"
283     read_maintainer_info
284     case "${j2se_arch}" in
285       i586)
286         j2se_debian_arch=i386
287         ;;
288       amd64|x64)
289         j2se_debian_arch=amd64
290         ;;
291     esac
292     j2se_name="$j2se_package-$j2se_debian_arch"
293     local target="$package_dir/$j2se_name"
294     install -d -m 755 "$( dirname "$target" )"
295     extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
296     rm -rf "$target/.systemPrefs"
297     echo "9" > "$debian_dir/compat"
298     j2se_readme > "$debian_dir/README.Debian"
299     j2se_changelog > "$debian_dir/changelog"
300     eval "$j2se_control" > "$debian_dir/control"
301     j2se_copyright > "$debian_dir/copyright"
302     j2se_rules > "$debian_dir/rules"
303     chmod +x "$debian_dir/rules"
304     j2se_install_scripts
305     install -d "$target/debian"
306     j2se_info > "$target/debian/info"
307     eval "$j2se_jinfo" > "$package_dir/.$j2se_name.jinfo"
308     echo ".$j2se_name.jinfo $jvm_base" > "$debian_dir/install"
309     echo "$j2se_name $jvm_base" >> "$debian_dir/install"
310     j2se_build
311 }