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
+ read -e -n 1 -p "$prompt" reply
+ case "$reply" in
+ "" | "y" | "Y")
+ return 0
+ ;;
+ "N" | "n")
+ return 1
+ ;;
+ esac
done
}
diskfree() {
local size="$1"
echo -n "Checking free diskspace:"
- (( free = `stat -f -c '%a / 2048 * ( %s / 512 )' $tmp ` ))
+ (( free = `stat -f -c '%a / 2048 * ( %s / 512 )' $tmp ` ))
if [ "$free" -ge "$size" ]; then
- echo " done."
+ echo " done."
else
- cat >&2 << EOF
+ cat >&2 << EOF
WARNING: Possibly not enough free disk space in "$tmp".
TMPDIR.
EOF
- read
+ read
fi
}
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
+ *.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
+ cat << EOF
WARNING: The package installation script exited with an error
value. Usually, this means, that the installation failed for some
continue or Ctrl-C to abort.
EOF
- read
+ read
fi
echo
echo -n "Testing extracted archive..."
local size="$( diskusage "$extract_dir" )"
if [ "$size" -lt "$expected_min_size" ]; then
- cat << EOF
+ cat << EOF
Invalid size ($size MB) of extracted archive. Probably you have not
enough free disc space in the temporary directory. Note: You can
TMPDIR.
EOF
- error_exit
+ error_exit
else
- cd "$extract_dir"
- files=(*)
- if [ "${#files[*]}" -ne 1 ]; then
- cat << EOF
+ 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"
+ error_exit
+ fi
+ mv "$files" "$dest"
+ echo -e " okay.\n"
fi
}
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
+ 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
+ # 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
+ 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
+ read -e -p "Email [$default_email]: " maintainer_email
+ if [ -z "$maintainer_email" ]; then
+ maintainer_email="$default_email"
+ fi
+ fi
fi
}
shift
for program in \$*; do
update-alternatives \\
- --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
- --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
+ --install "/usr/bin/\$program" "\$program" "\$program_base/\$program" $j2se_priority \\
+ --slave "/usr/share/man/man1/\$program.1.gz" "\$program.1.gz" "$jvm_base$j2se_name/man/man1/\$program.1.gz"
done
}
fi
- cat << EOF
+ cat << EOF
Detected product:
Java(TM) Runtime Environment (JRE)
Standard Edition, Version $j2se_release Update $j2se_update
Oracle(TM)
EOF
- if read_yn "Is this correct [Y/n]: "; then
- j2se_found=true
- j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
- j2se_vendor="oracle"
- j2se_title="Java(TM) JRE, Standard Edition, Oracle(TM)"
+ if read_yn "Is this correct [Y/n]: "; then
+ j2se_found=true
+ j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
+ j2se_vendor="oracle"
+ j2se_title="Java(TM) JRE, Standard Edition, Oracle(TM)"
- j2se_install=oracle_j2re_install
- j2se_remove=oracle_j2re_remove
- j2se_jinfo=oracle_j2re_jinfo
- oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
- oracle_jre_bin_jre="javaws policytool"
- oracle_no_man_jre_bin_jre="ControlPanel"
- oracle_jre_lib_hl="jexec"
- j2re_run
- fi
+ j2se_install=oracle_j2re_install
+ j2se_remove=oracle_j2re_remove
+ j2se_jinfo=oracle_j2re_jinfo
+ oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
+ oracle_jre_bin_jre="javaws policytool"
+ oracle_no_man_jre_bin_jre="ControlPanel"
+ oracle_jre_lib_hl="jexec"
+ j2re_run
+ fi
fi
}
oracle_j2re_install() {
- cat << EOF
+ cat << EOF
if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
exit 0
fi
}
oracle_j2re_remove() {
- cat << EOF
+ cat << EOF
if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
exit 0
fi
case "$j2se_release" in
6) # JDK 6
- j2se_expected_min_size=44 #Mb
- ;;
- *) # JDK 7 and higher
- j2se_expected_min_size=290 #Mb
- ;;
+ j2se_expected_min_size=44 #Mb
+ ;;
+ *) # JDK 7 and higher
+ j2se_expected_min_size=290 #Mb
+ ;;
esac
- cat << EOF
+ cat << EOF
Detected product:
Java(TM) Development Kit (JDK) Documentation
Standard Edition, Version $j2se_release Update $j2se_update
Oracle(TM)
EOF
- if read_yn "Is this correct [Y/n]: "; then
- j2se_found=true
- j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
- j2se_vendor="oracle"
- j2se_title="Java(TM) JDK, Standard Edition, Oracle(TM) Documentation"
+ if read_yn "Is this correct [Y/n]: "; then
+ j2se_found=true
+ j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
+ j2se_vendor="oracle"
+ j2se_title="Java(TM) JDK, Standard Edition, Oracle(TM) Documentation"
- j2se_install=oracle_j2sdk_doc_install
- j2se_remove=oracle_j2sdk_doc_remove
- j2sdk_doc_run
- fi
+ j2se_install=oracle_j2sdk_doc_install
+ j2se_remove=oracle_j2sdk_doc_remove
+ j2sdk_doc_run
fi
+ fi
}
j2se_detect_j2sdk_doc_oracle=oracle_j2sdk_doc_detect
oracle_j2sdk_doc_install() {
- cat << EOF
+ cat << EOF
if [ ! -e "$javadoc_base$j2se_name" ]; then
exit 0
fi
}
oracle_j2sdk_doc_remove() {
- cat << EOF
+ cat << EOF
if [ ! -e "$javadoc_base$j2se_name" ]; then
exit 0
fi
Standard Edition, Version $j2se_release Update $j2se_update
Oracle(TM)
EOF
- if read_yn "Is this correct [Y/n]: "; then
- j2se_found=true
- j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
- j2se_vendor="oracle"
- j2se_title="Java(TM) JDK, Standard Edition, Oracle(TM)"
+ if read_yn "Is this correct [Y/n]: "; then
+ j2se_found=true
+ j2se_required_space=$(( $j2se_expected_min_size * 2 + 20 ))
+ j2se_vendor="oracle"
+ j2se_title="Java(TM) JDK, Standard Edition, Oracle(TM)"
- j2se_install=oracle_j2sdk_install
- j2se_remove=oracle_j2sdk_remove
- j2se_jinfo=oracle_j2sdk_jinfo
- oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
- oracle_jre_bin_jre="javaws policytool"
- oracle_no_man_jre_bin_jre="ControlPanel"
- oracle_jre_lib_hl="jexec"
- oracle_bin_jdk="appletviewer extcheck idlj jar jarsigner javac javadoc javah javap jconsole jdb jinfo jmap jps jsadebugd jstack jstat jstatd native2ascii rmic serialver"
- j2sdk_run
- fi
+ j2se_install=oracle_j2sdk_install
+ j2se_remove=oracle_j2sdk_remove
+ j2se_jinfo=oracle_j2sdk_jinfo
+ oracle_jre_bin_hl="java javaws keytool orbd pack200 rmid rmiregistry servertool tnameserv unpack200 policytool"
+ oracle_jre_bin_jre="javaws policytool"
+ oracle_no_man_jre_bin_jre="ControlPanel"
+ oracle_jre_lib_hl="jexec"
+ oracle_bin_jdk="appletviewer extcheck idlj jar jarsigner javac javadoc javah javap jconsole jdb jinfo jmap jps jsadebugd jstack jstat jstatd native2ascii rmic serialver"
+ j2sdk_run
+ fi
fi
}
oracle_j2sdk_install() {
- cat << EOF
+ cat << EOF
if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
exit 0
fi
}
oracle_j2sdk_remove() {
- cat << EOF
+ cat << EOF
if [ ! -e "$jvm_base$j2se_name/debian/info" ]; then
exit 0
fi
echo "Internal error, fakeroot seems to fail faking root" >&2
exit 1
fi
- exec fakeroot "$0" "$@"
+ exec fakeroot "$0" "$@"
fi
# check whether I'm real root, and bail out if so... ugly, but needed
if touch /lib/.test 2>/dev/null; then
- rm -f /lib/.test
- echo "You are real root -- unfortunately, some Java distributions have" >&2
- echo "install scripts that directly manipulate /etc, and may cause some" >&2
- echo "inconsistencies on your system. Instead, you should become a" >&2
- echo "non-root user and run:" >&2
- echo >&2
- echo "fakeroot make-jpkg $@" >&2
- echo >&2
- echo "which will allow no damage to be done to your system files and" >&2
- echo "still permit the Java distribution to successfully extract." >&2
- echo >&2
- echo "Aborting." >&2
- exit 1
+ rm -f /lib/.test
+ echo "You are real root -- unfortunately, some Java distributions have" >&2
+ echo "install scripts that directly manipulate /etc, and may cause some" >&2
+ echo "inconsistencies on your system. Instead, you should become a" >&2
+ echo "non-root user and run:" >&2
+ echo >&2
+ echo "fakeroot make-jpkg $@" >&2
+ echo >&2
+ echo "which will allow no damage to be done to your system files and" >&2
+ echo "still permit the Java distribution to successfully extract." >&2
+ echo >&2
+ echo "Aborting." >&2
+ exit 1
fi
### Parse options
print_usage() {
- cat << EOF
+ cat << EOF
Usage: $program_name [OPTION]... FILE
$program_name builds a Debian package from the given Java binary distribution FILE
# options
while [[ $# -gt 0 && "x$1" == x--* ]]; do
if [[ "x$1" == x--version ]]; then
- echo "make-jpkg $version"
- exit 0
+ echo "make-jpkg $version"
+ exit 0
elif [[ "x$1" == x--help ]]; then
- print_usage
- exit 0
+ print_usage
+ exit 0
elif [[ "x$1" == x--full-name ]]; then
- [ $# -le 1 ] && missing_argument "$1"
- shift
- maintainer_name="$1"
+ [ $# -le 1 ] && missing_argument "$1"
+ shift
+ maintainer_name="$1"
elif [[ "x$1" == x--email ]]; then
- [ $# -le 1 ] && missing_argument "$1"
- shift
- maintainer_email="$1"
+ [ $# -le 1 ] && missing_argument "$1"
+ shift
+ maintainer_email="$1"
elif [[ "x$1" == x--revision ]]; then
- [ $# -le 1 ] && missing_argument "$1"
- shift
- revision="-${1}"
+ [ $# -le 1 ] && missing_argument "$1"
+ shift
+ revision="-${1}"
elif [[ "x$1" == x--changes ]]; then
- genchanges="true"
+ genchanges="true"
else
- unrecognized_option "$1"
+ unrecognized_option "$1"
fi
shift
done
on_exit() {
lastcmd="$_"
if [[ -z "$success" && -z "$failed" ]]; then
- cat >&2 << EOF
+ cat >&2 << EOF
Aborted ($lastcmd).
fi
# remove temporary directory
if [ -n "$tmp" -a -d "$tmp" ]; then
- echo -n "Removing temporary directory: "
- rm -rf "$tmp"
- echo "done"
+ echo -n "Removing temporary directory: "
+ rm -rf "$tmp"
+ echo "done"
fi
}
trap on_exit EXIT
for var in ${!j2se_detect_*}; do
eval "\$$var"
if [[ "$j2se_found" == "true" ]]; then
- break;
+ break;
fi
done
echo