]> git.sven.stormbind.net Git - sven/java-package.git/blob - lib/javase.sh
10f2f5e2684878d9fa10597bcb2d392400bde6f0
[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
11 EOF
12 }
13
14 j2se_changelog() {
15     cat << EOF
16 $j2se_package ($j2se_version) unstable; urgency=low
17
18   * This package was created with java-package ($version).
19
20  -- $maintainer_name <$maintainer_email>  $( date -R )
21
22 EOF
23 }
24
25 j2se_control() {
26     cat << EOF
27 Source: $j2se_package
28 Section: non-free/devel
29 Priority: optional
30 Maintainer: $maintainer_name <$maintainer_email>
31 Build-Depends: debhelper (>= 9)
32 Standards-Version: 3.9.5
33
34 EOF
35 }
36
37 j2se_copyright() {
38     cat << EOF
39 ----------------------------------------------------------------------
40
41 This file contains a copy of all copyright files found in the original
42 distribution. The original copyright files and further information can
43 be found in the directory $jvm_base$j2se_name and its
44 subdirectories.
45
46 ----------------------------------------------------------------------
47 EOF
48     (
49     cd "$install_dir"
50     find * -type f -iname copyright |
51     while read file; do
52         cat << EOF
53
54 File: /$file
55
56 ----------------------------------------------------------------------
57
58 EOF
59         cat "$file"
60         cat << EOF
61
62 ----------------------------------------------------------------------
63 EOF
64     done
65     )
66 }
67
68 j2se_rules() {
69     cat << EOF
70 #!/usr/bin/make -f
71
72 %:
73         dh \$@
74 EOF
75 }
76
77 j2se_install_scripts() {
78     cat > "$debian_dir/postinst" << EOF
79 #!/bin/bash
80
81 set -e
82
83 if [ "\$1" = configure ]; then
84
85     # Common functions for all install scripts
86
87     # install_alternatives program_base programs
88     install_alternatives() {
89         program_base="\$1"
90         shift
91         for program in \$*; do
92           if [[ -f "\$program_base/\$program" ]]; then
93             update-alternatives \\
94             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
95             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
96           fi
97         done
98     }
99
100     # install_alternatives_no_man program_base programs
101     install_no_man_alternatives() {
102         program_base="\$1"
103         shift
104         for program in \$*; do
105           if [[ -f "\$program_base/\$program" ]]; then
106             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
107           fi
108         done
109     }
110
111     # install_browser_plugin link_path link_name plugin_name plugin
112     install_browser_plugin() {
113         local link_path="\$1"
114         local link_name="\$2"
115         local plugin_name="\$3"
116         local plugin="\$4"
117         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
118         if [[ -f "\$plugin" ]]; then
119           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
120         fi
121     }
122
123 EOF
124     eval "$j2se_install" >> "$debian_dir/postinst"
125
126     cat >> "$debian_dir/postinst" << EOF
127 fi
128
129 #DEBHELPER#
130
131 exit 0
132 EOF
133     chmod 755 "$debian_dir/postinst"
134
135     cat > "$debian_dir/prerm" << EOF
136 #!/bin/bash
137
138 set -e
139
140 case "\$1" in
141     remove | deconfigure)
142
143     # Common functions for all remove scripts
144
145     # remove_alternatives program_base programs
146     remove_alternatives() {
147         program_base="\$1"
148         shift
149         for program in \$*; do
150           update-alternatives --remove "\$program" "\$program_base/\$program"
151         done
152     }
153
154     # remove_browser_plugin plugin_name plugin
155     remove_browser_plugin() {
156         local plugin_name="\$1"
157         local plugin="\$2"
158         update-alternatives --remove "\$plugin_name" "\$plugin"
159     }
160
161 EOF
162     eval "$j2se_remove" >> "$debian_dir/prerm"
163
164     cat >> "$debian_dir/prerm" << EOF
165     ;;
166 esac
167
168 #DEBHELPER#
169
170 exit 0
171 EOF
172     chmod 755 "$debian_dir/prerm"
173 }
174
175 j2se_info() {
176     cat << EOF
177 version="$version"
178 j2se_version="$j2se_version"
179 maintainer_name="$maintainer_name"
180 maintainer_email="$maintainer_email"
181 date="$( date +%Y/%m/%d )"
182 EOF
183 }
184
185 # jinfos prefix program_base programs
186 jinfos() {
187     prefix="$1"
188     program_base="$2"
189     shift ; shift
190     for program in $*; do
191       echo "$prefix $program $program_base$program" 
192     done
193 }
194
195 j2se_build() {
196     cd "$tmp"
197     echo "Create debian package:"
198
199     #export DH_VERBOSE=1
200     export DH_OPTIONS=--tmpdir="$install_dir"
201
202     echo "    dh_testdir"
203     dh_testdir
204     echo "    dh_testroot"
205     dh_testroot
206     echo "    dh_installchangelogs"
207     dh_installchangelogs
208     # Problem: dh_installchangelogs thinks this is a native package.
209     echo "    dh_installdocs"
210     dh_installdocs
211     # dh_install
212     # dh_link
213     # Conditionally wrapping this as not all JRE/JDKs have man directories
214     if [ -e "$install_dir/$jvm_base$j2se_name/man" ]; then
215         echo "    dh_compress"
216         dh_compress $( find "$install_dir/$jvm_base$j2se_name/man" -type f ! -name "*.gz" )
217     fi
218     echo "    dh_fixperms"
219     dh_fixperms
220     echo "    dh_installdeb"
221     dh_installdeb
222     echo "    dh_shlibdeps"
223     ldpath=
224     for dir in $( find "$install_dir" -type f -name "*.so*" -printf "%h\n" | sort -u ); do
225         if [[ -z "$ldpath" ]]; then
226             ldpath="$dir"
227         else
228             ldpath="$ldpath:$dir"
229         fi
230     done
231     # suppress some warnings
232     dh_shlibdeps --exclude=fxavcodecplugin -l"$ldpath" 2>&1 |
233     { grep -v "warning: format of \`NEEDED lib.*\.so' not recognized" >&2 || true; }
234     echo "    dh_gencontrol"
235     dh_gencontrol
236     echo "    dh_md5sums"
237     dh_md5sums
238     echo "    dh_builddeb"
239     dh_builddeb --destdir="$tmp"
240     local deb_filename="$( echo "${j2se_package}_"*.deb )"
241     echo "    copy $deb_filename into directory $working_dir/"
242     cp "$deb_filename" "$working_dir/"
243     if [ -n "$genchanges" ]; then
244         echo "    dpkg-genchanges"
245         local changes_filename="${deb_filename%.deb}.changes"
246         dpkg-genchanges -b -u. > "$changes_filename"
247         echo "    copy $changes_filename into directory $working_dir/"
248         cp "$changes_filename" "$working_dir/"
249     fi
250     cat << EOF
251
252 The Debian package has been created in the current directory.
253 You can install the package as root with:
254
255     dpkg -i $deb_filename
256
257 EOF
258 }