]> git.sven.stormbind.net Git - sven/java-package.git/blob - lib/javase.sh
Added support for GA releases
[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 (>= 4.0.0)
32 Standards-Version: 3.7.2
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_install_scripts() {
69     cat > "$debian_dir/postinst" << EOF
70 #!/bin/bash
71
72 set -e
73
74 if [ "\$1" = configure ]; then
75
76     # Common functions for all install scripts
77
78     # install_alternatives program_base programs
79     install_alternatives() {
80         program_base="\$1"
81         shift
82         for program in \$*; do
83           if [[ -f "\$program_base/\$program" ]]; then
84             update-alternatives \\
85             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
86             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
87           fi
88         done
89     }
90
91     # install_alternatives_no_man program_base programs
92     install_no_man_alternatives() {
93         program_base="\$1"
94         shift
95         for program in \$*; do
96           if [[ -f "\$program_base/\$program" ]]; then
97             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
98           fi
99         done
100     }
101
102     # install_browser_plugin link_path link_name plugin_name plugin
103     install_browser_plugin() {
104         local link_path="\$1"
105         local link_name="\$2"
106         local plugin_name="\$3"
107         local plugin="\$4"
108         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
109         if [[ -f "\$plugin" ]]; then
110           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
111         fi
112     }
113
114 EOF
115     eval "$j2se_install" >> "$debian_dir/postinst"
116
117     cat >> "$debian_dir/postinst" << EOF
118 fi
119
120 #DEBHELPER#
121
122 exit 0
123 EOF
124     chmod 755 "$debian_dir/postinst"
125     
126     cat > "$debian_dir/prerm" << EOF
127 #!/bin/bash
128
129 set -e
130
131 case "\$1" in
132     remove | deconfigure)
133
134     # Common functions for all remove scripts
135
136     # remove_alternatives program_base programs
137     remove_alternatives() {
138         program_base="\$1"
139         shift
140         for program in \$*; do
141           update-alternatives --remove "\$program" "\$program_base/\$program"
142         done
143     }
144
145     # remove_browser_plugin plugin_name plugin
146     remove_browser_plugin() {
147         local plugin_name="\$1"
148         local plugin="\$2"
149         update-alternatives --remove "\$plugin_name" "\$plugin"
150     }
151
152 EOF
153     eval "$j2se_remove" >> "$debian_dir/prerm"
154
155     cat >> "$debian_dir/prerm" << EOF
156     ;;
157 esac
158
159 #DEBHELPER#
160
161 exit 0
162 EOF
163     chmod 755 "$debian_dir/prerm"
164 }
165
166 j2se_info() {
167     cat << EOF
168 version="$version"
169 j2se_version="$j2se_version"
170 maintainer_name="$maintainer_name"
171 maintainer_email="$maintainer_email"
172 date="$( date +%Y/%m/%d )"
173 EOF
174 }
175
176 # jinfos prefix program_base programs
177 jinfos() {
178     prefix="$1"
179     program_base="$2"
180     shift ; shift
181     for program in $*; do
182       echo "$prefix $program $program_base$program" 
183     done
184 }
185
186 j2se_build() {
187     cd "$tmp"
188     echo "Create debian package:"
189     
190     #export DH_VERBOSE=1
191     export DH_COMPAT=7
192     export DH_OPTIONS=--tmpdir="$install_dir"
193
194     echo "    dh_testdir"
195     dh_testdir
196     echo "    dh_testroot"
197     dh_testroot
198     echo "    dh_installchangelogs"
199     dh_installchangelogs
200     # Problem: dh_installchangelogs thinks this is a native package.
201     echo "    dh_installdocs"
202     dh_installdocs
203     # dh_install
204     # dh_link
205     # Conditionally wrapping this as not all JRE/JDKs have man directories
206     if [ -e "$install_dir/$jvm_base$j2se_name/man" ]; then
207         echo "    dh_compress"
208         dh_compress $( find "$install_dir/$jvm_base$j2se_name/man" -type f ! -name "*.gz" )
209     fi
210     echo "    dh_fixperms"
211     dh_fixperms
212     echo "    dh_installdeb"
213     dh_installdeb
214     echo "    dh_shlibdeps"
215     ldpath=
216     for dir in $( find "$install_dir" -type f -name "*.so*" -printf "%h\n" | sort -u ); do
217         if [[ -z "$ldpath" ]]; then
218             ldpath="$dir"
219         else
220             ldpath="$ldpath:$dir"
221         fi
222     done
223     # suppress some warnings
224     dh_shlibdeps -l"$ldpath" 2>&1 | 
225     { grep -v "warning: format of \`NEEDED lib.*\.so' not recognized" >&2 || true; }
226     echo "    dh_gencontrol"
227     dh_gencontrol
228     echo "    dh_md5sums"
229     dh_md5sums
230     echo "    dh_builddeb"
231     dh_builddeb --destdir="$tmp"
232     local deb_filename="$( echo "${j2se_package}_"*.deb )"
233     echo "    copy $deb_filename into directory $working_dir/"
234     cp "$deb_filename" "$working_dir/"
235     if [ -n "$genchanges" ]; then 
236         echo "    dpkg-genchanges"
237         local changes_filename="${deb_filename%.deb}.changes"
238         dpkg-genchanges -b -u. > "$changes_filename"
239         echo "    copy $changes_filename into directory $working_dir/"
240         cp "$changes_filename" "$working_dir/"
241     fi
242     cat << EOF
243
244 The Debian package has been created in the current directory. You can
245 install the package as root (e.g. dpkg -i $deb_filename). 
246
247 EOF
248 }