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