]> git.sven.stormbind.net Git - sven/java-package.git/blob - lib/javase.sh
Use dpkg-buildpackage to build the guest package.
[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 "$package_dir"
50     find * -type f -iname copyright ! -path debian/copyright |
51     while read file; do
52         cat << EOF
53
54 File: $jvm_base$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
75 override_dh_compress:
76         dh_compress \$(shell find $j2se_name/man/ -type f ! -name '*.gz' -printf '${jvm_base##/}/%p\n')
77
78 override_dh_shlibdeps:
79         dh_shlibdeps --exclude=fxavcodecplugin -l\$(shell find $j2se_name -type f -name '*.so*' -printf '${jvm_base##/}/%h\n' | sort -u | tr '\n' ':' | sed 's/:\$\$//')
80 EOF
81 }
82
83 j2se_install_scripts() {
84     cat > "$debian_dir/postinst" << EOF
85 #!/bin/bash
86
87 set -e
88
89 if [ "\$1" = configure ]; then
90
91     # Common functions for all install scripts
92
93     # install_alternatives program_base programs
94     install_alternatives() {
95         program_base="\$1"
96         shift
97         for program in \$*; do
98           if [[ -f "\$program_base/\$program" ]]; then
99             update-alternatives \\
100             --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
101             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
102           fi
103         done
104     }
105
106     # install_alternatives_no_man program_base programs
107     install_no_man_alternatives() {
108         program_base="\$1"
109         shift
110         for program in \$*; do
111           if [[ -f "\$program_base/\$program" ]]; then
112             update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
113           fi
114         done
115     }
116
117     # install_browser_plugin link_path link_name plugin_name plugin
118     install_browser_plugin() {
119         local link_path="\$1"
120         local link_name="\$2"
121         local plugin_name="\$3"
122         local plugin="\$4"
123         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
124         if [[ -f "\$plugin" ]]; then
125           update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
126         fi
127     }
128
129 EOF
130     eval "$j2se_install" >> "$debian_dir/postinst"
131
132     cat >> "$debian_dir/postinst" << EOF
133 fi
134
135 #DEBHELPER#
136
137 exit 0
138 EOF
139     chmod 755 "$debian_dir/postinst"
140
141     cat > "$debian_dir/prerm" << EOF
142 #!/bin/bash
143
144 set -e
145
146 case "\$1" in
147     remove | deconfigure)
148
149     # Common functions for all remove scripts
150
151     # remove_alternatives program_base programs
152     remove_alternatives() {
153         program_base="\$1"
154         shift
155         for program in \$*; do
156           update-alternatives --remove "\$program" "\$program_base/\$program"
157         done
158     }
159
160     # remove_browser_plugin plugin_name plugin
161     remove_browser_plugin() {
162         local plugin_name="\$1"
163         local plugin="\$2"
164         update-alternatives --remove "\$plugin_name" "\$plugin"
165     }
166
167 EOF
168     eval "$j2se_remove" >> "$debian_dir/prerm"
169
170     cat >> "$debian_dir/prerm" << EOF
171     ;;
172 esac
173
174 #DEBHELPER#
175
176 exit 0
177 EOF
178     chmod 755 "$debian_dir/prerm"
179 }
180
181 j2se_info() {
182     cat << EOF
183 version="$version"
184 j2se_version="$j2se_version"
185 maintainer_name="$maintainer_name"
186 maintainer_email="$maintainer_email"
187 date="$( date +%Y/%m/%d )"
188 EOF
189 }
190
191 # jinfos prefix program_base programs
192 jinfos() {
193     prefix="$1"
194     program_base="$2"
195     shift ; shift
196     for program in $*; do
197       echo "$prefix $program $program_base$program" 
198     done
199 }
200
201 j2se_build() {
202     cd "$package_dir"
203     echo "Create debian package:"
204
205     dpkg-buildpackage -b -uc -us
206     cd "$tmp"
207     local deb_filename="$( echo "${j2se_package}_"*.deb )"
208     echo "    copy $deb_filename into directory $working_dir/"
209     cp "$deb_filename" "$working_dir/"
210     if [ -n "$genchanges" ]; then
211         echo "    dpkg-genchanges"
212         local changes_filename="${deb_filename%.deb}.changes"
213         echo "    copy $changes_filename into directory $working_dir/"
214         cp "$changes_filename" "$working_dir/"
215     fi
216     cat << EOF
217
218 The Debian package has been created in the current directory.
219 You can install the package as root with:
220
221     dpkg -i $deb_filename
222
223 EOF
224 }