]> git.sven.stormbind.net Git - sven/java-package.git/blobdiff - lib/javase.sh
ensure older pattern only match up to version 8
[sven/java-package.git] / lib / javase.sh
index 4e1766d4fcf503f635de2ebe30e6a2b742d903ac..fd025ca4f1a4afb10fc3fa764f6fa5d57aed8bd4 100644 (file)
@@ -7,29 +7,30 @@ This package has been automatically created with java-package ($version).
 All files from the original distribution should have been installed in
 the directory $jvm_base$j2se_name. Please take a look at this directory for
 further information.
-
 EOF
 }
 
 j2se_changelog() {
     cat << EOF
-$j2se_package ($j2se_version) unstable; urgency=low
+$j2se_package ($j2se_version) $target_distribution; urgency=medium
 
   * This package was created with java-package ($version).
 
  -- $maintainer_name <$maintainer_email>  $( date -R )
-
 EOF
 }
 
 j2se_control() {
+    if test -n "$build_depends"; then
+        build_depends=", $build_depends"
+    fi
     cat << EOF
 Source: $j2se_package
 Section: non-free/devel
 Priority: optional
 Maintainer: $maintainer_name <$maintainer_email>
-Build-Depends: debhelper (>= 9)
-Standards-Version: 3.9.5
+Build-Depends: debhelper (>= 9)${build_depends}
+Standards-Version: 3.9.8
 
 EOF
 }
@@ -46,17 +47,17 @@ subdirectories.
 ----------------------------------------------------------------------
 EOF
     (
-    cd "$install_dir"
-    find * -type f -iname copyright |
+    cd "$package_dir"
+    find * -type f -iname copyright ! -path debian/copyright |
     while read file; do
         cat << EOF
 
-File: /$file
+File: $jvm_base$file
 
 ----------------------------------------------------------------------
 
 EOF
-        cat "$file"
+        iconv -f ISO-8859-15 -t UTF-8 "$file" | sed 's/[ \t]*$//'
         cat << EOF
 
 ----------------------------------------------------------------------
@@ -65,6 +66,49 @@ EOF
     )
 }
 
+j2se_rules() {
+    cat << EOF
+#!/usr/bin/make -f
+
+# Exclude libraries that pull in ALSA or OpenGL which are not needed in normal operation
+EXCLUDE_LIBS = \\
+       --exclude=avplugin \\
+       --exclude=fxavcodecplugin \\
+       --exclude=libjsoundalsa.so \\
+EOF
+    for lib in $exlude_libs; do
+        printf '\t--exclude=%s \\\n' "$lib"
+    done
+    cat << EOF
+       \$(NULL)
+
+%:
+       dh \$@
+
+override_dh_compress:
+       dh_compress \$(shell find $j2se_name/man/ -type f ! -name '*.gz' -printf '${jvm_base##/}/%p\n')
+
+override_dh_shlibdeps:
+       dh_shlibdeps \$(EXCLUDE_LIBS) -l\$(shell find $j2se_name -type f -name '*.so*' -printf '${jvm_base##/}/%h\n' | sort -u | tr '\n' ':' | sed 's/:\$\$//')
+
+override_dh_strip_nondeterminism:
+       # Disable dh_strip_nondeterminism to speed up the build
+EOF
+}
+
+j2se_doc_rules() {
+    cat << EOF
+#!/usr/bin/make -f
+
+%:
+       dh \$@
+
+override_dh_strip_nondeterminism:
+       # Disable dh_strip_nondeterminism to speed up the build
+EOF
+}
+
+
 j2se_install_scripts() {
     cat > "$debian_dir/postinst" << EOF
 #!/bin/bash
@@ -82,7 +126,7 @@ if [ "\$1" = configure ]; then
         for program in \$*; do
           if [[ -f "\$program_base/\$program" ]]; then
             update-alternatives \\
-            --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
+            --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" ${priority_override:-$j2se_priority} \\
             --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
           fi
         done
@@ -94,7 +138,7 @@ if [ "\$1" = configure ]; then
         shift
         for program in \$*; do
           if [[ -f "\$program_base/\$program" ]]; then
-            update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority
+            update-alternatives --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" ${priority_override:-$j2se_priority}
           fi
         done
     }
@@ -107,11 +151,19 @@ if [ "\$1" = configure ]; then
         local plugin="\$4"
         [ -d "\$link_path" ] || install -d -m 755 "\$link_path"
         if [[ -f "\$plugin" ]]; then
-          update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" $j2se_priority
+          update-alternatives --install "\$link_path/\$link_name" "\$plugin_name" "\$plugin" ${priority_override:-$j2se_priority}
         fi
     }
-
 EOF
+    if [ "$create_cert_softlinks" == "true" ];then
+        cat >> "$debian_dir/postinst" << EOF
+    for subdir in lib/security jre/lib/security;do
+        if [ -f $jvm_base$j2se_name/\$subdir/cacerts ]; then
+            ln -sf /etc/ssl/certs/java/cacerts $jvm_base$j2se_name/\$subdir/cacerts
+        fi
+    done
+EOF
+    fi
     eval "$j2se_install" >> "$debian_dir/postinst"
 
     cat >> "$debian_dir/postinst" << EOF
@@ -184,61 +236,36 @@ jinfos() {
 }
 
 j2se_build() {
-    cd "$tmp"
-    echo "Create debian package:"
-
-    #export DH_VERBOSE=1
-    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/$jvm_base$j2se_name/man" ]; then
-        echo "    dh_compress"
-        dh_compress $( find "$install_dir/$jvm_base$j2se_name/man" -type f ! -name "*.gz" )
-    fi
-    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"
+    if [ -n "$build_source" ]; then
+        local source_dir=${j2se_package}-${j2se_version}
+        echo "    copy ${source_dir} into directory $working_dir/"
+        rm -rf "$working_dir/${source_dir}"
+        cp -r "$package_dir" "$working_dir/${source_dir}"
+        cat << EOF
+
+The Debian source package has been created in the current directory.
+You can build the package with:
+
+    cd ${source_dir}
+    dpkg-buildpackage -b -uc -us
+
+EOF
+    else
+        cd "$package_dir"
+        echo "Create debian package:"
+
+        dpkg-buildpackage -b -uc -us
+        cd "$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"
+            echo "    copy $changes_filename into directory $working_dir/"
+            cp "$changes_filename" "$working_dir/"
         fi
-    done
-    # suppress some warnings
-    dh_shlibdeps --exclude=fxavcodecplugin -l"$ldpath" 2>&1 |
-    { grep -v "warning: format of \`NEEDED 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
+        cat << EOF
 
 The Debian package has been created in the current directory.
 You can install the package as root with:
@@ -246,4 +273,43 @@ You can install the package as root with:
     dpkg -i $deb_filename
 
 EOF
+    fi
+}
+
+# build debian package
+j2se_run() {
+    echo
+    diskfree "$j2se_required_space"
+    read_maintainer_info
+    get_distribution
+    case "${j2se_arch}" in
+      i586)
+        j2se_debian_arch=i386
+        ;;
+      amd64|x64)
+        j2se_debian_arch=amd64
+        ;;
+    esac
+    j2se_name="$j2se_package-$j2se_debian_arch"
+    local target="$package_dir/$j2se_name"
+    install -d -m 755 "$( dirname "$target" )"
+    extract_bin "$archive_path" "$j2se_expected_min_size" "$target"
+    if [[ -n "$jce_archive" ]]; then
+      extract_jce "$jce_path" "$target/jre/lib/security"
+    fi
+    rm -rf "$target/.systemPrefs"
+    echo "9" > "$debian_dir/compat"
+    j2se_readme > "$debian_dir/README.Debian"
+    j2se_changelog > "$debian_dir/changelog"
+    eval "$j2se_control" > "$debian_dir/control"
+    j2se_copyright > "$debian_dir/copyright"
+    j2se_rules > "$debian_dir/rules"
+    chmod +x "$debian_dir/rules"
+    j2se_install_scripts
+    install -d "$target/debian"
+    j2se_info > "$target/debian/info"
+    eval "$j2se_jinfo" > "$package_dir/.$j2se_name.jinfo"
+    echo ".$j2se_name.jinfo $jvm_base" > "$debian_dir/install"
+    echo "$j2se_name $jvm_base" >> "$debian_dir/install"
+    j2se_build
 }