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