]> git.sven.stormbind.net Git - sven/java-package.git/blob - lib/javase.sh
Create build depends for JDK.
[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     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 -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
130 EOF
131     eval "$j2se_install" >> "$debian_dir/postinst"
132
133     cat >> "$debian_dir/postinst" << EOF
134 fi
135
136 #DEBHELPER#
137
138 exit 0
139 EOF
140     chmod 755 "$debian_dir/postinst"
141
142     cat > "$debian_dir/prerm" << EOF
143 #!/bin/bash
144
145 set -e
146
147 case "\$1" in
148     remove | deconfigure)
149
150     # Common functions for all remove scripts
151
152     # remove_alternatives program_base programs
153     remove_alternatives() {
154         program_base="\$1"
155         shift
156         for program in \$*; do
157           update-alternatives --remove "\$program" "\$program_base/\$program"
158         done
159     }
160
161     # remove_browser_plugin plugin_name plugin
162     remove_browser_plugin() {
163         local plugin_name="\$1"
164         local plugin="\$2"
165         update-alternatives --remove "\$plugin_name" "\$plugin"
166     }
167
168 EOF
169     eval "$j2se_remove" >> "$debian_dir/prerm"
170
171     cat >> "$debian_dir/prerm" << EOF
172     ;;
173 esac
174
175 #DEBHELPER#
176
177 exit 0
178 EOF
179     chmod 755 "$debian_dir/prerm"
180 }
181
182 j2se_info() {
183     cat << EOF
184 version="$version"
185 j2se_version="$j2se_version"
186 maintainer_name="$maintainer_name"
187 maintainer_email="$maintainer_email"
188 date="$( date +%Y/%m/%d )"
189 EOF
190 }
191
192 # jinfos prefix program_base programs
193 jinfos() {
194     prefix="$1"
195     program_base="$2"
196     shift ; shift
197     for program in $*; do
198       echo "$prefix $program $program_base$program" 
199     done
200 }
201
202 j2se_build() {
203     if [ -n "$build_source" ]; then
204         local source_dir=${j2se_package}-${j2se_version}
205         echo "    copy ${source_dir} into directory $working_dir/"
206         rm -rf "$working_dir/${source_dir}"
207         cp -r "$package_dir" "$working_dir/${source_dir}"
208         cat << EOF
209
210 The Debian source package has been created in the current directory.
211 You can build the package with:
212
213     cd ${source_dir}
214     dpkg-buildpackage -b -uc -us
215
216 EOF
217     else
218         cd "$package_dir"
219         echo "Create debian package:"
220
221         dpkg-buildpackage -b -uc -us
222         cd "$tmp"
223         local deb_filename="$( echo "${j2se_package}_"*.deb )"
224         echo "    copy $deb_filename into directory $working_dir/"
225         cp "$deb_filename" "$working_dir/"
226         if [ -n "$genchanges" ]; then
227             echo "    dpkg-genchanges"
228             local changes_filename="${deb_filename%.deb}.changes"
229             echo "    copy $changes_filename into directory $working_dir/"
230             cp "$changes_filename" "$working_dir/"
231         fi
232         cat << EOF
233
234 The Debian package has been created in the current directory.
235 You can install the package as root with:
236
237     dpkg -i $deb_filename
238
239 EOF
240     fi
241 }