Commit ca8b5d17 authored by Cédric Pineau's avatar Cédric Pineau

Initial rework of (svn) java-package 0.42

parent 5bc639af
DESTDIR=
.PHONY: default
default: build
.PHONY: build
build:
echo "java-package currently supports the following binary packages:" \
> SUPPORTED
echo >> SUPPORTED
echo "(This list is automatically generated, do not edit)" >> SUPPORTED
echo >> SUPPORTED
grep -h "SUPPORTED$$" $(wildcard lib/*-*.sh) | sed 's/"//g;s/).*//' \
>> SUPPORTED
.PHONY: clean
clean:
rm -f SUPPORTED
.PHONY: install
install:
install -d -m 755 $(DESTDIR)/usr/bin
install -m 755 make-jpkg.out $(DESTDIR)/usr/bin/make-jpkg
install -d -m 755 $(DESTDIR)/usr/share/man/man1
install -m 644 make-jpkg.1 $(DESTDIR)/usr/share/man/man1/
install -d -m 755 $(DESTDIR)/usr/share/java-package
for file in lib/*.sh; do \
install -m 644 $$file $(DESTDIR)/usr/share/java-package/ ; \
done
From old java-pakage :
Move repeated code in install/remove scripts to a single point; apply the DRY (don't repeat yourself) principle.
Change handling of alternatives to allow for multiple directories, i.e. when you have executables in both bin and jre/bin in a JDK.
Remove use of dpkg --print-architecture from plugin alternatives installation in install/remove scripts.
From Matthias Klose <doko@ubuntu.com> :
Support the .jinfo files (update-java-alternatives)
Install into a multiarch location to allow installing the i386 client vm on amd64 and ia64.
java-package
------------
This package can be used to install various non-free external Java packages
under Debian.
It includes the 'make-jpkg' command to do this, see 'man make-jpkg' for more
information about generating java packages.
Supported packages currently include:
* Oracle :
- The J2SE Development Kit (JDK), version 6 (update >= 10), 7
- The J2SE Runtime Environment (JRE), version 6 (update >= 10), 7
- The J2SE API Javadoc, version 6 (update >= 10), 7
Download:
http://www.oracle.com/technetwork/java/javase/downloads
(Choose tar.gz archives, i586 or amd64, do _not_ choose the RPM!)
All other previously supported jvm (Blackdown, IBM, ..) have been removed and
will only be added back on users demand
-- Cédric Pineau <cedric.pineau@gmail.com> Thu, 22 Dec 2011 11:42:13 +0100
This diff is collapsed.
Source: java-package
Section: contrib/misc
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Carlos Laviola <claviola@debian.org>, Arnaud Vandyck <avdyk@debian.org>, Jeroen van Wolffelaar <jeroen@wolffelaar.nl>, Barry Hawkins <barry@alltc.com>, Michael Koch <konqueror@gmx.de>
Build-Depends: debhelper (>= 5)
Standards-Version: 3.7.3
Package: java-package
Architecture: all
Depends: debhelper, fakeroot, unzip, libx11-6, libasound2
Recommends: dpkg-dev, gcc
Description: utility for building Java(TM) 2 related Debian packages
This package provides the capability to create a Debian package from
a Java(TM) 2 distribution by just running make-jpkg <filename>.
.
This program currently works with the following Java(TM) 2 Runtime
Environments and Development Kits:
.
* Oracle(TM) 7 Standard Edition
This is java-package, maintained by Jeroen van Wolffelaar
<jeroen@wolffelaar.nl> and Barry Hawkins <barry@bytemason.org>.
It is based upon the j2se-package application originally
written by Hubert Schmid.
The original source can always be found at:
http://cvs.alioth.debian.org/cgi-bin/cvsweb.cgi/java-package/?cvsroot=pkg-java
Copyright (C) 2005 Barry Hawkins
Copyright (C) 2004-2005 Jeroen van Wolffelaar
Copyright (C) 2003 Hubert Schmid
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA.
On Debian systems, the complete text of the GNU General Public License
can be found in `/usr/share/common-licenses/GPL'.
/usr/bin
/usr/share/java-package
#!/usr/bin/make -f
# debian/rules for java-package
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# Extract source package version number from changelog
VERSION := $(shell head -n 1 $(CURDIR)/debian/changelog | sed 's/.*(//;s/).*//')
B := $(CURDIR)/debian/java-package
build: build-stamp
build-stamp:
dh_testdir
# Add here commands to compile the indep part of the package.
sed s/@VERSION@/$(VERSION)/ make-jpkg > make-jpkg.out
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp SUPPORTED make-jpkg.out debian/semantic.cache
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
install -m 755 make-jpkg.out $(B)/usr/bin/make-jpkg
cp lib/*.sh lib/*-common $(B)/usr/share/java-package/
for dir in $(wildcard oracle-j2*); do \
cp -a $$dir $(B)/usr/share/java-package/; \
done
find $(B) -type d -name .svn | xargs -r rm -r
# Generate SUPPORTED
echo "java-package currently supports the following binary packages:" > SUPPORTED
echo >> SUPPORTED
echo "(This list is automatically generated, do not edit)" >> SUPPORTED
echo >> SUPPORTED
grep -h "SUPPORTED$$" $(wildcard $(CURDIR)/lib/*-*.sh) | sed 's/"//g;s/).*//' >> SUPPORTED
dh_install
binary: binary-indep
binary-arch:
binary-indep: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installman make-jpkg.1
dh_link
# dh_strip
dh_compress
dh_fixperms
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
.PHONY: build clean binary-indep binary install
# read_yn <prompt>
function read_yn() {
local prompt="$1"
while true; do
read -e -n 1 -p "$prompt" reply
case "$reply" in
"" | "y" | "Y")
return 0
;;
"N" | "n")
return 1
;;
esac
done
}
# diskusage <path>: prints size in MB
function diskusage() {
local path="$1"
read size dummy < <( du -sm "$path" )
echo "$size"
}
# diskfree <minimum size in MB>
function diskfree() {
local size="$1"
echo -n "Checking free diskspace:"
(( free = `stat -f -c '%a / 2048 * ( %s / 512 )' $tmp ` ))
if [ "$free" -ge "$size" ]; then
echo " done."
else
cat >&2 << EOF
WARNING: Possibly not enough free disk space in "$tmp".
You need at least $size MB, but only $free MB seems free. Note: You
can specify an alternate directory by setting the environment variable
Press Ctrl+C to interrupt, or return to try to continue anyway.
TMPDIR.
EOF
read
fi
}
# extract_bin <file> <expected_min_size> <dest>
function extract_bin() {
local file="$1"
local expected_min_size="$2"
local dest="$3"
cat << EOF
In the next step, the binary file will be extracted. Probably a
license agreement will be displayed. Please read this agreement
carefully. If you do not agree to the displayed license terms, the
package will not be built.
EOF
read -e -p "Press [Return] to continue: " dummy
echo
local extract_dir="$tmp/extract"
mkdir "$extract_dir"
cd "$extract_dir"
echo
local extract_cmd
case "$archive_path" in
*.tar)
extract_cmd="tar xf";;
*.tar.bz2)
extract_cmd="tar --bzip2 -xf";;
*.tgz|*.tar.gz)
extract_cmd="tar xfz";;
*.zip)
extract_cmd="unzip -q";;
*)
extract_cmd=sh
esac
if ! $extract_cmd "$archive_path"; then
cat << EOF
WARNING: The package installation script exited with an error
value. Usually, this means, that the installation failed for some
reason. But in some cases there is no problem and you can continue
creating the Debian package.
Please check if there are any error messages. Press [Return] to
continue or Ctrl-C to abort.
EOF
read
fi
echo
echo -n "Testing extracted archive..."
local size="$( diskusage "$extract_dir" )"
if [ "$size" -lt "$expected_min_size" ]; then
cat << EOF
Invalid size ($size MB) of extracted archive. Probably you have not
enough free disc space in the temporary directory. Note: You can
specify an alternate directory by setting the environment variable
TMPDIR.
EOF
error_exit
else
cd "$extract_dir"
files=(*)
if [ "${#files[*]}" -ne 1 ]; then
cat << EOF
Expected one file, but found the following ${#files[*]} files:
${files[*]}
EOF
error_exit
fi
mv "$files" "$dest"
echo -e " okay.\n"
fi
}
function read_maintainer_info() {
if [ -z "$maintainer_name" ]; then
if [ -n "$DEBFULLNAME" ]; then
maintainer_name="$DEBFULLNAME"
elif [ -n "$DEBNAME" ]; then
maintainer_name="$DEBNAME"
else
default_name="$(getent passwd $(id -run) | cut -d: -f5| cut -d, -f1)"
cat << EOF
Please enter your full name. This value will be used in the maintainer
field of the created package.
EOF
# gecos can be null
while [ -z "$maintainer_name" ]; do
read -e -p "Full name [$default_name]:" maintainer_name
if [ -z "$maintainer_name" ] && [ -n "$default_name" ]; then
maintainer_name="$default_name"
fi
done
fi
fi
if [ -z "$maintainer_email" ]; then
local default_email=
if [ -n "$DEBEMAIL" ]; then
maintainer_email="$DEBEMAIL"
else
if [ -r "/etc/mailname" ]; then
default_email="$( id -run )@$( cat /etc/mailname )"
else
default_email="$( id -run )@$( hostname --fqdn )"
fi
cat << EOF
Please enter a valid email address or press return to accept the
default value. This address will be used in the maintainer field of
the created package.
EOF
read -e -p "Email [$default_email]: " maintainer_email
if [ -z "$maintainer_email" ]; then
maintainer_email="$default_email"
fi
fi
fi
}
# provide the architecture for evaluation by plugins
function get_architecture() {
echo
export DEB_BUILD_ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
export DEB_BUILD_GNU_TYPE=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE)
echo "Detected Debian build architecture: ${DEB_BUILD_ARCH:-N/A}"
echo "Detected Debian GNU type: ${DEB_BUILD_GNU_TYPE:-N/A}"
}
# Common functions for all install scripts
# install_alternative -- add an alternative
#
# install_alternative program
function install_alternative() {
local program="$1"
update-alternatives \
--install "/usr/bin/$program" "$program" \
"$j2se_base/bin/$program" "$priority" \
--slave "/usr/share/man/man1/$program.1.gz" "$program.1.gz" \
"$j2se_base/man/man1/$program.1.gz"
}
# install_java_plugin -- add an alternative for a browser plugin
#
# install_java_plugin browser_plugin_path java_plugin_path priority
function install_java_plugin() {
[ -d "$1" ] || install -d -m 755 "$1"
update-alternatives \
--install "$1/$2" "$3" "$4" "$5"
}
function j2re_readme() {
j2se_readme
}
function j2re_changelog() {
j2se_changelog
}
function j2re_control() {
j2se_control
cat << EOF
Package: $j2se_package
Architecture: any
Depends: \${shlibs:Depends}
Recommends: netbase, libx11-6 | xlibs, libasound2, libgtk1.2
Provides: java-virtual-machine, java-runtime, java2-runtime, java-runtime-headless, java2-runtime-headless, java-browser-plugin, j2re${j2se_release}
Replaces: ${j2se_package}debian
Description: $j2se_title
The Java(TM) 2 Runtime Environment contains the Java virtual machine,
runtime class libraries, and Java application launcher that are
necessary to run programs written in the Java progamming language
(this includes the Java 2 Plug-In for Netscape and Mozilla
browsers). It is not a development environment and doesn't contain
development tools such as compilers or debuggers. For development
tools, see the Java 2 SDK, Standard Edition.
.
This package has been automatically created with java-package ($version).
EOF
}
function j2re_copyright() {
j2se_copyright
}
function j2re_install_scripts() {
j2se_install_scripts
}
function j2re_info() {
j2se_info
}
function j2re_build() {
j2se_build
}
# build debian package
function j2re_run() {
echo
diskfree "$j2se_required_space"
read_maintainer_info
j2se_package="$j2se_vendor-j2re$j2se_release"
j2se_base="/usr/lib/jvm/j2re$j2se_release-$j2se_vendor"
local target="$install_dir$j2se_base"
install -d -m 755 "$( dirname "$target" )"
extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
rm -rf "$target/.systemPrefs"
j2re_readme > "$debian_dir/README.Debian"
j2re_changelog > "$debian_dir/changelog"
j2re_control > "$debian_dir/control"
j2re_copyright > "$debian_dir/copyright"
j2re_install_scripts
install -d "$target/debian"
j2re_info > "$target/debian/info"
j2re_build
}
function j2sdk_doc_readme() {
j2se_readme
}
function j2sdk_doc_changelog() {
j2se_changelog
}
function j2sdk_doc_control() {
j2se_control
cat << EOF
Package: $j2se_package
Architecture: any
Depends:
Recommends:
Provides:
Replaces:
Description: $j2se_title
The Java(TM) 2 SDK is a development environment for building
applications, applets, and components that can be deployed on the
Java(TM) platform.
.
This package provides the official API documentation published
by Sun Microsystems.
.
This package has been automatically created with java-package ($version).
EOF
}
function j2sdk_doc_copyright() {
j2se_copyright
}
function j2sdk_doc_install_scripts() {
j2se_install_scripts
}
function j2sdk_doc_info() {
j2se_info
}
function j2sdk_doc_doc-base() {
cat << EOF
Document: $j2se_package
Title: $j2se_title
Author: $maintainer_name
Abstract: This is the API Javadoc provided by the vendor
Section: Programming
Format: HTML
Index: /usr/share/doc/j2sdk$j2se_release-$j2se_vendor-doc/index.html
Files: /usr/share/doc/j2sdk$j2se_release-$j2se_vendor-doc/*.html
EOF
}
function j2sdk_doc_build() {
j2se_build
}
# build debian package
function j2sdk_doc_run() {
echo
diskfree "$j2se_required_space"
read_maintainer_info
j2se_package="$j2se_vendor-j2sdk$j2se_release-doc"
j2se_base="/usr/share/doc/j2sdk$j2se_release-$j2se_vendor-doc"
local target="$install_dir$j2se_base"
install -d -m 755 "$( dirname "$target" )"
extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
rm -rf "$target/.systemPrefs"
j2sdk_doc_readme > "$debian_dir/README.Debian"
j2sdk_doc_changelog > "$debian_dir/changelog"
j2sdk_doc_control > "$debian_dir/control"
j2sdk_doc_copyright > "$debian_dir/copyright"
j2sdk_doc_doc-base > "$debian_dir/$j2se_package.doc-base"
j2sdk_doc_install_scripts
install -d "$target/debian"
j2sdk_doc_info > "$target/debian/info"
j2sdk_doc_build
}
function j2sdk_readme() {
j2se_readme
}
function j2sdk_changelog() {
j2se_changelog
}
function j2sdk_control() {
j2se_control
cat << EOF
Package: $j2se_package
Architecture: any
Depends: \${shlibs:Depends}
Recommends: netbase, libx11-6 | xlibs, libasound2, libgtk1.2, libstdc++5
Provides: java-virtual-machine, java-runtime, java2-runtime, java-browser-plugin, java-compiler, java2-compiler, java-runtime-headless, java2-runtime-headless, java-sdk, java2-sdk, j2sdk$j2se_release, j2re$j2se_release
Replaces: ${j2se_package}debian
Description: $j2se_title
The Java(TM) 2 SDK is a development environment for building
applications, applets, and components that can be deployed on the
Java(TM) platform.
.
The Java(TM) 2 SDK software includes tools useful for developing and
testing programs written in the Java programming language and running
on the Java platform. These tools are designed to be used from the
command line. Except for appletviewer, these tools do not provide a
graphical user interface.
.
This package has been automatically created with java-package ($version).
EOF
}
function j2sdk_copyright() {
j2se_copyright
}
function j2sdk_install_scripts() {
j2se_install_scripts
}
function j2sdk_info() {
j2se_info
}
function j2sdk_build() {
j2se_build
}
# build debian package
function j2sdk_run() {
echo
diskfree "$j2se_required_space"
read_maintainer_info
j2se_package="$j2se_vendor-j2sdk$j2se_release"
j2se_base="/usr/lib/jvm/j2sdk$j2se_release-$j2se_vendor"
local target="$install_dir$j2se_base"
install -d -m 755 "$( dirname "$target" )"
extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
rm -rf "$target/.systemPrefs"
j2sdk_readme > "$debian_dir/README.Debian"
j2sdk_changelog > "$debian_dir/changelog"
j2sdk_control > "$debian_dir/control"
j2sdk_copyright > "$debian_dir/copyright"
j2sdk_install_scripts
install -d "$target/debian"
j2sdk_info > "$target/debian/info"
j2sdk_build
}
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> $( date -R )
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.7.2
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/install-common" >> "$debian_dir/postinst"
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/remove-common" >> "$debian_dir/prerm"
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
# Conditionally wrapping this as not all JRE/JDKs have man directories
if [ -e "$install_dir/$j2se_base/man" ]; then