]> git.sven.stormbind.net Git - sven/java-package.git/blob - lib/javase.sh
a0e27e4caf88fdad2dae2d7f6c8d2da6f2daa491
[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 EOF
82 }
83
84 j2se_doc_rules() {
85     cat << EOF
86 #!/usr/bin/make -f
87
88 %:
89         dh \$@
90
91 EOF
92 }
93
94
95 j2se_install_scripts() {
96     cat > "$debian_dir/postinst" << EOF
97 #!/bin/bash
98
99 set -e
100
101 if [ "\$1" = configure ]; then
102
103     # Common functions for all install scripts
104
105     # install_alternatives program_base programs
106     install_alternatives() {
107         program_base="\$1"
108         shift
109         for program in \$*; do
110           if [[ -f "\$program_base/\$program" ]]; then
111             update-alternatives \\
112             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
113             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
114           fi
115         done
116     }
117
118     # install_alternatives_no_man program_base programs
119     install_no_man_alternatives() {
120         program_base="\$1"
121         shift
122         for program in \$*; do
123           if [[ -f "\$program_base/\$program" ]]; then
124             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
125           fi
126         done
127     }
128
129     # install_browser_plugin link_path link_name plugin_name plugin
130     install_browser_plugin() {
131         local link_path="\$1"
132         local link_name="\$2"
133         local plugin_name="\$3"
134         local plugin="\$4"
135         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
136         if [[ -f "\$plugin" ]]; then
137           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
138         fi
139     }
140 EOF
141     if [ "$create_cert_softlinks" == "true" ];then
142         cat >> "$debian_dir/postinst" << EOF
143     for subdir in lib/security jre/lib/security;do
144         if [ -f $jvm_base$j2se_name/\$subdir/cacerts ]; then
145             ln -sf /etc/ssl/certs/java/cacerts $jvm_base$j2se_name/\$subdir/cacerts
146         fi
147     done
148 EOF
149     fi
150     eval "$j2se_install" >> "$debian_dir/postinst"
151
152     cat >> "$debian_dir/postinst" << EOF
153 fi
154
155 #DEBHELPER#
156
157 exit 0
158 EOF
159     chmod 755 "$debian_dir/postinst"
160
161     cat > "$debian_dir/prerm" << EOF
162 #!/bin/bash
163
164 set -e
165
166 case "\$1" in
167     remove | deconfigure)
168
169     # Common functions for all remove scripts
170
171     # remove_alternatives program_base programs
172     remove_alternatives() {
173         program_base="\$1"
174         shift
175         for program in \$*; do
176           update-alternatives --remove "\$program" "\$program_base/\$program"
177         done
178     }
179
180     # remove_browser_plugin plugin_name plugin
181     remove_browser_plugin() {
182         local plugin_name="\$1"
183         local plugin="\$2"
184         update-alternatives --remove "\$plugin_name" "\$plugin"
185     }
186
187 EOF
188     eval "$j2se_remove" >> "$debian_dir/prerm"
189
190     cat >> "$debian_dir/prerm" << EOF
191     ;;
192 esac
193
194 #DEBHELPER#
195
196 exit 0
197 EOF
198     chmod 755 "$debian_dir/prerm"
199 }
200
201 j2se_info() {
202     cat << EOF
203 version="$version"
204 j2se_version="$j2se_version"
205 maintainer_name="$maintainer_name"
206 maintainer_email="$maintainer_email"
207 date="$( date +%Y/%m/%d )"
208 EOF
209 }
210
211 # jinfos prefix program_base programs
212 jinfos() {
213     prefix="$1"
214     program_base="$2"
215     shift ; shift
216     for program in $*; do
217       echo "$prefix $program $program_base$program" 
218     done
219 }
220
221 j2se_build() {
222     if [ -n "$build_source" ]; then
223         local source_dir=${j2se_package}-${j2se_version}
224         echo "    copy ${source_dir} into directory $working_dir/"
225         rm -rf "$working_dir/${source_dir}"
226         cp -r "$package_dir" "$working_dir/${source_dir}"
227         cat << EOF
228
229 The Debian source package has been created in the current directory.
230 You can build the package with:
231
232     cd ${source_dir}
233     dpkg-buildpackage -b -uc -us
234
235 EOF
236     else
237         cd "$package_dir"
238         echo "Create debian package:"
239
240         dpkg-buildpackage -b -uc -us
241         cd "$tmp"
242         local deb_filename="$( echo "${j2se_package}_"*.deb )"
243         echo "    copy $deb_filename into directory $working_dir/"
244         cp "$deb_filename" "$working_dir/"
245         if [ -n "$genchanges" ]; then
246             echo "    dpkg-genchanges"
247             local changes_filename="${deb_filename%.deb}.changes"
248             echo "    copy $changes_filename into directory $working_dir/"
249             cp "$changes_filename" "$working_dir/"
250         fi
251         cat << EOF
252
253 The Debian package has been created in the current directory.
254 You can install the package as root with:
255
256     dpkg -i $deb_filename
257
258 EOF
259     fi
260 }