File: j2se.sh

package info (click to toggle)
java-package 0.24
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 224 kB
  • ctags: 42
  • sloc: sh: 1,149; makefile: 71
file content (177 lines) | stat: -rw-r--r-- 3,978 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
function j2se_readme() {
    cat << EOF
Package for $j2se_title
---

This package has been automatically created with java-package ($version). 
All files from the original distribution should have been installed in
the directory $j2se_base. Please take a look at this directory for
further information.

EOF
}

function j2se_changelog() {
    cat << EOF
$j2se_package ($j2se_version) unstable; urgency=low

  * This package was created with java-package ($version).

 -- $maintainer_name <$maintainer_email>  $( 822-date )

EOF
}

function j2se_control() {
    cat << EOF
Source: $j2se_package
Section: non-free/devel
Priority: optional
Maintainer: $maintainer_name <$maintainer_email>
Build-Depends: debhelper (>= 4.0.0)
Standards-Version: 3.6.0

EOF
}

function j2se_copyright() {
    cat << EOF
----------------------------------------------------------------------

This file contains a copy of all copyright files found in the original
distribution. The original copyright files and further information can
be found in the directory $j2se_base and its
subdirectories.

----------------------------------------------------------------------
EOF
    ( 
	cd "$install_dir"
	find * -type f -iname copyright |
	while read file; do
	    cat << EOF

File: /$file

----------------------------------------------------------------------

EOF
	    cat "$file"
	    cat << EOF

----------------------------------------------------------------------
EOF
	done
    )
}

function j2se_install_scripts() {
    cat > "$debian_dir/postinst" << EOF
#!/bin/bash

set -e

if [ "\$1" = configure ]; then
EOF
	cat "$lib_dir/$j2se_package/install" >> "$debian_dir/postinst"

	cat >> "$debian_dir/postinst" << EOF
fi

#DEBHELPER#

exit 0
EOF
	chmod 755 "$debian_dir/postinst"
    
	cat > "$debian_dir/prerm" << EOF
#!/bin/bash

set -e

case "\$1" in
	remove | deconfigure)
EOF
	cat "$lib_dir/$j2se_package/remove" >> "$debian_dir/prerm"

	cat >> "$debian_dir/prerm" << EOF
	;;
esac

#DEBHELPER#

exit 0
EOF
	chmod 755 "$debian_dir/prerm"
}

function j2se_info() {
    cat << EOF
version="$version"
j2se_version="$j2se_version"
maintainer_name="$maintainer_name"
maintainer_email="$maintainer_email"
date="$( date +%Y/%m/%d )"
EOF
}

function j2se_build() {
    cd "$tmp"
    echo "Create debian package:"
    
    #export DH_VERBOSE=1
    export DH_COMPAT=4
    export DH_OPTIONS=--tmpdir="$install_dir"

    echo "    dh_testdir"
    dh_testdir
    echo "    dh_testroot"
    dh_testroot
    echo "    dh_installchangelogs"
    dh_installchangelogs
    # Problem: dh_installchangelogs thinks this is a native package.
    echo "    dh_installdocs"
    dh_installdocs
    # dh_install
    # dh_link
    echo "    dh_compress"
    dh_compress $( find "$install_dir/$j2se_base/man" -type f ! -name "*.gz" )
    echo "    dh_fixperms"
    dh_fixperms
    echo "    dh_installdeb"
    dh_installdeb
    echo "    dh_shlibdeps"
    ldpath=
    for dir in $( find "$install_dir" -type f -name "*.so*" -printf "%h\n" | sort -u ); do
	if [[ -z "$ldpath" ]]; then
	    ldpath="$dir"
	else
	    ldpath="$ldpath:$dir"
	fi
    done
    # suppress some warnings
    dh_shlibdeps -l"$ldpath" 2>&1 | 
    { grep -v "warning: format of lib.*\.so not recognized" >&2 || true; }
    echo "    dh_gencontrol"
    dh_gencontrol
    echo "    dh_md5sums"
    dh_md5sums
    echo "    dh_builddeb"
    dh_builddeb --destdir="$tmp"
    local deb_filename="$( echo "${j2se_package}_"*.deb )"
    echo "    copy $deb_filename into directory $working_dir/"
    cp "$deb_filename" "$working_dir/"
    if [ -n "$genchanges" ]; then 
	echo "    dpkg-genchanges"
	local changes_filename="${deb_filename%.deb}.changes"
	dpkg-genchanges -b -u. > "$changes_filename"
	echo "    copy $changes_filename into directory $working_dir/"
	cp "$changes_filename" "$working_dir/"
    fi
    cat << EOF

The Debian package has been created in the current directory. You can
install the package as root (e.g. dpkg -i $deb_filename). 

EOF
}