#!/bin/sh
set -e

# make-sqldeveloper-package

# (2018-01-11)

# Copyright © 2009-2018 Lazarus Long <lazarus (dot) long (at) sapo (dot) pt>

##########################################################################
#  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 3 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 program.  If not, see <http://www.gnu.org/licenses/>. #
##########################################################################

# Debian package builder and installer for Oracle SQL Developer

#DEBUG=1
#VERBOSE=1

PATH="/usr/bin:/bin:/usr/sbin:/sbin"

if [ ${DEBUG:=0} -ne 0 ] ; then
	trap
	set -x
fi

VERSION="0.5.4"
DESC="Debian package builder and installer for Oracle SQL Developer"
AUTHOR="Lazarus Long"
COPYRIGHT="2009-2018"

ITP=515233
PROGNAME="sqldeveloper"
HOMEPAGE="http://www.oracle.com/technetwork/developer-tools/sql-developer/"


BASENAME="basename"
BUNZIP2="bunzip2"
CAT="cat"
CHMOD="chmod"
CONVERT="convert"
CP="cp"
CUT="cut"
DATE="date"
DEBUILD="debuild"
DPKG="dpkg"
DPKG_ARCHITECTURE="dpkg-architecture"
DPKG_QUERY="dpkg-query"
EXPR="expr"
FILE="file"
FIND="find"
FOLD="fold"
FROMDOS="fromdos"
GETOPT="getopt"
GREP="grep"
GUNZIP="gunzip"
HOSTNAME="hostname"
LN="ln"
LS="ls"
MKDIR="mkdir"
MKTEMP="mktemp"
MV="mv"
OBJDUMP="objdump"
RM="rm"
RMDIR="rmdir"
SED="sed"
TAR="tar"
TOUCH="touch"
TR="tr"
TRUE="true"
UNXZ="unxz"
UNZIP="unzip"
XARGS="xargs"

GREP_OPTS="-E"
MKDIR_OPTS="-p"
SED_OPTS="-e"

DEBFULLNAME=${DEBFULLNAME:=""}
DEBEMAIL=${DEBEMAIL:="${USER}@$(${HOSTNAME})"}
STANDARDS="4.1.3"

USRDIR="usr"
INSTDIR="${USRDIR}/share"
LIBSDIR="${USRDIR}/lib"
CURDIR="${PWD}"
HOSTARCH="$(${DPKG_ARCHITECTURE} -qDEB_HOST_ARCH)"
INVOCATION="$(${BASENAME} "${0}")"

SILENT=0

RM_OPTS_FUNC_TRAP="-rf"

# Cleanup at exit
#
func_exit() {
	if [ ${DEBUG} -ne 0 ] ; then
		trap
		set +x
	fi
}

# Trap interrupt signals
#
func_break() {
	func_exit
}

# Trap events
#
func_trap() {
	trap func_exit 0

	if [ ${DEBUG} -eq 0 ] ; then
		trap func_break HUP INT QUIT ABRT
	fi
}

# Display a header for the program
#
func_header() {
	if [ ${SILENT} -eq 0 ] ; then
		printf "%s %s Copyright © %s %s\n%s\n\n" "${INVOCATION}" "${VERSION}" "${COPYRIGHT}" "${AUTHOR}" "${DESC}"
	fi

	return 0
}

# Display the program version
#
func_version() {
	printf "%s %s\n" "${INVOCATION}" "${VERSION}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "\nCopyright © %s %s\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nWritten by %s.\n" "${COPYRIGHT}" "${AUTHOR}" "${AUTHOR}"
	fi

	return 0
}

# Display the program help
#
func_help() {
	func_header
	HELP_MSG="Usage:\t${INVOCATION} [options] <file>\n\nOptions:\n\t-b|--build-dir <dir>\n\t\tbase directory to build package(s) (autogenerated)\n\t-e|--email <email>\n\t\tlocal maintainer email (use DEBEMAIL or auto-generate)\n\t-i|--install\n\t\tinstall the generated package(s) - needs root privilege (no)\n\t-k|--keep-dir\n\t\tkeep the build directory (no)\n\t-l|--revision <number>\n\t\tlocal revision to append to package version (1)\n\t-m|--maintainer <name>\n\t\tlocal maintainer name (use DEBFULLNAME or leave empty)\n\t-q|--quiet\n\t\tsuppress normal output (no)\n\t-r|--root-command <command>\n\t\tcommand to gain root privilege for package build (fakeroot)\n\t-s|--skip-libraries\n\t\tskip building the shared libraries package(s) (no)\n\t-u|--upstream-version <version>\n\t\tforce the upstream version (autodetected)\n\t-x|--extract-only\n\t\tprepare build tree, do not build package(s) [implies -k|--keep-dir] (no)\n\t-h|--help\n\t\tdisplay this help screen\n\t-v|--version\n\t\tshow the program version (${VERSION})\n\n\t<file>\n\t\tthe \"Oracle SQL Developer for other platforms\" archive\n\t\tfrom <${HOMEPAGE}>"
	printf "%b\n" "${HELP_MSG}"
	return 0
}

# Parse the command line options
#
func_opts() {
	local GETOPT_OPTS="-o hb:e:ikl:m:qr:su:vx -l help,build-dir:,email:,install,keep-dir,revision:,maintainer:,quiet,root-command:,skip-libraries,upstream-version:,version,extract-only -s sh"
	local GETOPT_RUN="$(${GETOPT} ${GETOPT_OPTS} -n ${INVOCATION} -- "${@}")"
	INSTALL=0
	KEEPDIR=0
	NOBUILD=0
	SKIPLIB=0

	if [ ${?} -ne 0 ] ; then
		func_header >&2

		if [ ${SILENT} -eq 0 ] ; then
			printf  "Error parsing command line, terminating...\n" >&2
		else
			printf  "%s: Error parsing command line, terminating...\n" "${INVOCATION}" >&2
		fi

		exit 1
	fi
	eval set -- "${GETOPT_RUN}"

	while $(${TRUE}) ; do
		case "${1}" in
			-h|--help)
				func_help
				exit 0
			;;
			-b|--build-dir)
				WORKDIR="${2}"
				shift 2
			;;
			-e|--email)
				DEBEMAIL="${2}"
				shift 2
			;;
			-i|--install)
				INSTALL=1
				shift
			;;
			-k|--keep-dir)
				KEEPDIR=1
				shift
			;;
			-l|--revision)
				LOCALVER="${2}"
				shift 2
			;;
			-m|--maintainer)
				DEBFULLNAME="${2}"
				shift 2
			;;
			-q|--quiet)
				SILENT=1
				shift
			;;
			-r|--root-command)
				ROOTCMD="${2}"
				shift 2
			;;
			-s|--skip-libraries)
				SKIPLIB=1
				shift
			;;
			-u|--upstream-version)
				UPSTREAMVER="${2}"
				shift 2
			;;
			-v|--version)
				func_version
				exit 0
			;;
			-x|--extract-only)
				KEEPDIR=1
				NOBUILD=1
				shift
			;;
			--)
				shift
				break
			;;
			*)
				func_header >&2

				if [ ${SILENT} -eq 0 ] ; then
					printf  "Unknown option \"%s\" or internal error, terminating...\n" "${1}" >&2
				else
					printf  "%s: Unknown option \"%s\" or internal error, terminating...\n" "${INVOCATION}" "${1}" >&2
				fi

				exit 1
			;;
		esac
	done

	if [ ${#} -lt 1 ] ; then
		func_header >&2

		if [ ${SILENT} -eq 0 ] ; then
			printf "Missing command line parameter, use \"-h\" or \"--help\" for syntax, terminating...\n" >&2
		else
			printf "%s: Missing command line parameter, use \"-h\" or \"--help\" for syntax, terminating...\n" "${INVOCATION}" >&2
		fi

		exit 1
	elif [ ${#} -gt 1 ] ; then
		func_header >&2

		if [ ${SILENT} -eq 0 ] ; then
			printf "Extra command line parameter, use \"-h\" or \"--help\" for syntax, terminating...\n" >&2
		else
			printf "%s: Extra command line parameter, use \"-h\" or \"--help\" for syntax, terminating...\n" "${INVOCATION}" >&2
		fi

		exit 1
	else
		ARCHIVE="${1}"

		if ! [ -f "${ARCHIVE}" ] ; then
			func_header

			if [ ${SILENT} -eq 0 ] ; then
				printf "\"%s\" not found, aborting...\n" "${ARCHIVE}" >&2
			else
				printf "%s: \"%s\" not found, aborting...\n" "${INVOCATION}" "${ARCHIVE}" >&2
			fi

			exit 1
		fi
	fi

	return 0
}

# Indicate active flags
#
func_flags() {
	if [ ${SILENT} -eq 0 ] ; then
		local COUNT=0
		printf "Environment variables are:\n\tDEBFULLNAME=\"%s\"\n\tDEBEMAIL=\"%s\"\nActive flags are:" "${DEBFULLNAME}" "${DEBEMAIL}"

		if [ ${INSTALL} -ne 0 ] ; then
			COUNT=$((${COUNT} + 1))
			printf " -i|--install"
		fi

		if [ ${KEEPDIR} -ne 0 ] ; then
			COUNT=$((${COUNT} + 1))
			printf " -k|--keep-dir"
		fi

		if [ ${SKIPLIB} -ne 0 ] ; then
			COUNT=$((${COUNT} + 1))
			printf " -s|--skip-libraries"
		fi

		if [ ${NOBUILD} -ne 0 ] ; then
			COUNT=$((${COUNT} + 1))
			printf " -x|--extract-only"
		fi

		if [ ${COUNT} -eq 0 ] ; then
			printf " (none)"
		fi

		printf "\n"
	fi

	return 0
}

# Setup the work directory
#
func_workdir() {
	if [ -z "${WORKDIR}" ] ; then
		local MKTEMP_OPTS_FUNC_WORKDIR="-d"

		WORKDIR="$(${MKTEMP} ${MKTEMP_OPTS_FUNC_WORKDIR})" || {
			if [ ${SILENT} -eq 0 ] ; then
				printf "\nUnable to create the work directory, aborting...\n" >&2
			else
				printf "%s: Unable to create the work directory, aborting...\n" "${INVOCATION}" >&2
			fi

			exit 1
		}

		if [ ${SILENT} -eq 0 ] ; then
			printf "Creating work directory \"%s\" ... " "${WORKDIR}"
		fi
	else
		if [ ${SILENT} -eq 0 ] ; then
			printf "Creating work directory \"%s\" ... " "${WORKDIR}"
		fi

		if ! [ -d "${WORKDIR}" ] ; then
			if [ -e "${WORKDIR}" ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "\n\"%s\" already exists and isn't a directory, aborting...\n" "${WORKDIR}" >&2
				else
					printf "%s: \"%s\" already exists and isn't a directory, aborting...\n" "${INVOCATION}" "${WORKDIR}" >&2
				fi

				exit 1
			fi

			${MKDIR} ${MKDIR_OPTS} "${WORKDIR}"
		else
			local DIRTEST="$(${LS} "${WORKDIR}")"

			if [ ${#DIRTEST} -ne 0 ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "\n\"%s\" is not empty, aborting...\n" "${WORKDIR}" >&2
				else
					printf "%s: \"%s\" is not empty, aborting...\n" "${INVOCATION}" "${WORKDIR}" >&2
				fi

				exit 1
			fi
		fi
	fi

	if [ ${KEEPDIR} -ne 1 ] ; then
		trap "${RM} ${RM_OPTS_FUNC_TRAP} ${WORKDIR}" EXIT HUP INT TRAP TERM
	fi

	WORKDIR="${WORKDIR}/${PROGNAME}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "Creating build installation directory \"%s\" ... " "${WORKDIR}/${INSTDIR}"
	fi

	${MKDIR} ${MKDIR_OPTS} "${WORKDIR}/${INSTDIR}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Extract the archive to the work directory
#
func_extract() {
	if [ ${#} -ne 2 ] ; then
		printf "Usage: func_extract() <archive> <path for extraction>\n"
		return 1
	fi

	local BUNZIP2_OPTS_QUIET="-q ${1}"
	local BUNZIP2_OPTS_STDOUT="-c"
	local FILE_OPTS_FUNC_EXTRACT="-b -"
	local GUNZIP_OPTS_QUIET="${BUNZIP2_OPTS_QUIET}"
	local GUNZIP_OPTS_STDOUT="${BUNZIP2_OPTS_STDOUT}"
	local TAR_OPTS_FUNC_EXTRACT="xaf ${1} -C ${2}"
	local UNXZ_OPTS_QUIET="${BUNZIP2_OPTS_QUIET}"
	local UNXZ_OPTS_STDOUT="${BUNZIP2_OPTS_STDOUT}"
	local UNZIP_OPTS_FUNC_EXTRACT="-Xq ${1} -d ${2}"

	local EXTRACT=""
	local EXTRACT_OPTS=""
	local EXTRACT_OPTS_TST4TAR=""

	if [ ${SILENT} -eq 0 ] ; then
		printf "Extracting upstream archive \"%s\" to \"%s\" ... " "${1}" "${2}"
	fi

	local FILETYPE="$(${FILE} ${FILE_OPTS} "${1}")"

	printf "%s\n" "${FILETYPE}" |${GREP} ${GREP_OPTS} "Zip archive data" >/dev/null 2>&1 && {
		EXTRACT="${UNZIP}"
		EXTRACT_OPTS="${UNZIP_OPTS_FUNC_EXTRACT}"
	} || {
		printf "%s\n" "${FILETYPE}" |${GREP} ${GREP_OPTS} "gzip compressed data" >/dev/null 2>&1 && {
			EXTRACT="${GUNZIP}"
			EXTRACT_OPTS="${GUNZIP_OPTS_QUIET}"
			EXTRACT_OPTS_TST4TAR="${GUNZIP_OPTS_STDOUT}"
		} || {
			printf "%s\n" "${FILETYPE}" |${GREP} ${GREP_OPTS} "bzip2 compressed data" >/dev/null 2>&1 && {
				EXTRACT="${BUNZIP2}"
				EXTRACT_OPTS="${BUNZIP2_OPTS_QUIET}"
				EXTRACT_OPTS_TST4TAR="${BUNZIP2_OPTS_STDOUT}"
			} || {
				printf "%s\n" "${FILETYPE}" |${GREP} ${GREP_OPTS} "XZ compressed data" >/dev/null 2>&1 && {
					EXTRACT="${UNXZ}"
					EXTRACT_OPTS="${UNXZ_OPTS_QUIET}"
					EXTRACT_OPTS_TST4TAR="${UNXZ_OPTS_STDOUT}"
				} || {
					if [ ${SILENT} -eq 0 ] ; then
						printf "\nfunc_extract(): Unknown archive format for \"%s\", aborting...\n" "${1}" >&2
					else
						printf "%s - func_extract(): Unknown archive format for \"%s\" , aborting...\n" "${INVOCATION}" "${1}" >&2
					fi

					exit 1
				}
			}
		}
	}

	if [ ${#EXTRACT_OPTS_TST4TAR} -ne 0 ] ; then
		${EXTRACT} ${EXTRACT_OPTS_TST4TAR} "${1}" |${FILE} ${FILE_OPTS_FUNC_EXTRACT} |${GREP} ${GREP_OPTS} "tar archive" >/dev/null 2>&1 && {
			EXTRACT="${TAR}"
			EXTRACT_OPTS="${TAR_OPTS_FUNC_EXTRACT}"
		}
	fi

	${EXTRACT} ${EXTRACT_OPTS}

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Set the program version and modifies paths accordingly
#
func_upstreamversion() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_upstreamversion() <directory>\n"
		return 1
	fi

	local MV_OPTS_FUNC_UPVER="--strip-trailing-slashes"

	if [ ${SILENT} -eq 0 ] ; then
		printf "Obtaining upstream full version: "
	fi

	if ! [ -d "${1}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\nfunc_upstreamversion(): Directory \"%s\" not found, aborting...\n" "${1}" >&2
		else
			printf "%s - func_upstreamversion(): Directory \"%s\" not found, aborting...\n" "${INVOCATION}" "${1}" >&2
		fi

		exit 1
	fi

	if [ -z "${UPSTREAMVER}" ] ; then
		local CUT_OPTS_FUNC_UPVER="-d = -f 2"
		local TR_OPTS_FUNC_UPVER="-d [[:space:]]"
		local VERSIONFILE="${1}/${INSTDIR}/${PROGNAME}/${PROGNAME}/bin/version.properties"

		if ! [ -e "${VERSIONFILE}" ] ; then
			VERSIONFILE="${1}/${INSTDIR}/${PROGNAME}/jdev/bin/version.properties"

			if ! [ -e "${VERSIONFILE}" ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "\nfunc_upstreamversion(): File \"%s\" not found, aborting...\n" "${VERSIONFILE}" >&2
				else
					printf "%s - func_upstreamversion(): File \"%s\" not found, aborting...\n" "${INVOCATION}" "${VERSIONFILE}" >&2
				fi

				exit 1
			fi
		fi

		UPSTREAMVER="$(${GREP} ${GREP_OPTS} "VER_FULL" "${VERSIONFILE}" |${CUT} ${CUT_OPTS_FUNC_UPVER} |${TR} ${TR_OPTS_FUNC_UPVER})"
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "\"%s\" ... " "${UPSTREAMVER}"
	fi

	UPSTREAMVERMAJ="${UPSTREAMVER%%.*}"
	UPSTREAMVERMIN="${UPSTREAMVER#*.}"
	UPSTREAMVERREV="${UPSTREAMVERMIN#*.}"
	UPSTREAMVERMIN="${UPSTREAMVERMIN%%.*}"
	UPSTREAMVERREV="${UPSTREAMVERREV%%.*}"

	if [ -z "${LOCALVER}" ] ; then
		LOCALVER=1
	fi

	local OLDNAME="${WORKDIR}"
	WORKDIR="${WORKDIR}-${UPSTREAMVER}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "Renaming the work directory \"%s\" to \"%s\" ... " "${OLDNAME}" "${WORKDIR}"
	fi

	${MV} ${MV_OPTS_FUNC_UPVER} "${OLDNAME}" "${WORKDIR}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Special case for SQL Developer first released version
#
func_firstver() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_firstver() <directory>\n"
		return 1
	fi

	if [ ${SILENT} -eq 0 ] ; then
		"Doing some first version special case house keeping ... "
	fi

	local CHMOD_OPTS_FUNC_1STVER="755"
	local MV_OPTS_FUNC_1STVER="--strip-trailing-slashes"
	local RM_OPTS_FUNC_1STVER="-rf"
	local TOUCH_OPTS_FUNC_1STVER="-r"
	local OPTDIR="${1}"

	if ! [ -d "${1}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\nfunc_firstver(): Directory \"%s\" not found, aborting...\n" "${1}" >&2
		else
			printf "%s - func_firstver(): Directory \"%s\" not found, aborting...\n" "${INVOCATION}" "${1}" >&2
		fi

		exit 1
	fi

	if ! [ -f "${1}/${PROGNAME}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\nfunc_firstver(): File \"%s/%s\" not found, this doesn't seem the first version, aborting...\n" "${1}" "${PROGNAME}" >&2
		else
			printf "%s - func_firstver(): File \"%s/%s\" not found, this doesn't seem the first version, aborting...\n" "${INVOCATION}" "${1}" "${PROGNAME}" >&2
		fi

		exit 1
	fi


	printf "%s\n" '#!/bin/sh' >"${OPTDIR}/${PROGNAME}.sh"
	${CAT} ${CAT_OPTS} "${OPTDIR}/${PROGNAME}" >>"${OPTDIR}/${PROGNAME}.sh" && ${CHMOD} ${CHMOD_OPTS_FUNC_1STVER} "${OPTDIR}/${PROGNAME}.sh"
	${TOUCH} ${TOUCH_OPTS_FUNC_1STVER} "${OPTDIR}/${PROGNAME}" "${OPTDIR}/${PROGNAME}.sh"
	${RM} ${RM_OPTS_FUNC_1STVER} "${OPTDIR}/${PROGNAME}"

	# Place holders
	${TOUCH} ${TOUCH_OPTS_FUNC_1STVER} "${OPTDIR}/jdev/lib/ext/README.TXT" "${OPTDIR}/jdev/lib/ext/.placeholder"
	${MV} ${MV_OPTS_FUNC_1STVER} "${OPTDIR}/jdev/lib/ext/README.TXT" "${WORKDIR}/usr/share/doc/${PROGNAME}/extensions.README.TXT"
	${TOUCH} ${TOUCH_OPTS_FUNC_1STVER} "${OPTDIR}/jdev/lib/patches/README.TXT" "${OPTDIR}/jdev/lib/patches/.placeholder"
	${MV} ${MV_OPTS_FUNC_1STVER} "${OPTDIR}/jdev/lib/patches/README.TXT" "${WORKDIR}/usr/share/doc/${PROGNAME}/patches.README.TXT"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Reorganizes the work directory to comply with FHS
#
func_reorganize() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_reorganize() <directory>\n"
		return 1
	fi

	local CUT_OPTS_FN="-d : -f 1"
	local CUT_OPTS_LIB="-d - -f 2-"
	local GREP_OPTS_COUNT="${GREP_OPTS} -c"
	local LN_OPTS_FUNC_REORG="-s"
	local MV_OPTS_FUNC_REORG="--strip-trailing-slashes"
	local OBJDUMP_OPTS_FUNC_REORG="-p"

	if [ ${SILENT} -eq 0 ] ; then
		printf "Reorganizing the work directory \"%s\" to generate FSH compliant package(s) ... " "${1}"
	fi

	local OPTDIR="${1}/${INSTDIR}/${PROGNAME}"

	if ! [ -d "${OPTDIR}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\nfunc_reorganize(): Directory \"%s\" not found, aborting...\n" "${OPTDIR}" >&2
		else
			printf "%s - func_reorganize(): Directory \"%s\" not found, aborting...\n" "${INVOCATION}" "${OPTDIR}" >&2
		fi

		exit 1
	fi

	if [ ${SKIPLIB} -eq 0 ] ; then
		local LIBWORKDIR="${1}/${LIBSDIR}"

		for Library in $(${FIND} "${OPTDIR}" ! \( -type d -o -name "*.jar" \) |${XARGS} ${XARGS_OPTS} ${FILE} ${FILE_OPTS} |${GREP} ${GREP_OPTS} "ELF (32|64)-bit LSB shared object" |${CUT} ${CUT_OPTS_FN}) ; do
			local ARCH="$(${OBJDUMP} ${OBJDUMP_OPTS_FUNC_REORG} ${Library} |${GREP} ${GREP_OPTS} "file format" |${SED} ${SED_OPTS} 's/^.*file format //' |${CUT} ${CUT_OPTS_LIB} |${TR} ${TR_OPTS} - _)"
			local SONAME="$(${OBJDUMP} ${OBJDUMP_OPTS_FUNC_REORG} ${Library} |${GREP} ${GREP_OPTS} "SONAME" |${SED} ${SED_OPTS} 's/^[[:space:]]*SONAME[[:space:]]*//')"
			SONAME=${SONAME##*/}
			local SERIAL="$(printf ${Library##*/} |${SED} ${SED_OPTS} 's/\.so*$//' |${CUT} ${CUT_OPTS_LIB})"
			local SOVERSION=""

			# Hack to avoid expr returning errorlevel 1 when substr finds a '0'
			if [ ${SERIAL} -eq 410 ] ; then
				SOVERSION=".4.1.0"
			elif [ ${SERIAL} -eq 422 ] ; then
				SOVERSION=".4.2.2"
			else
				local SIZE=0

				while [ ${SIZE} -lt ${#SERIAL} ] ; do
					SIZE=$((${SIZE}+1))
					SOVERSION="${SOVERSION}.$(${EXPR} ${EXPR_OPTS} substr ${SERIAL} ${SIZE} 1)"
				done
			fi

			if ! [ -d "${LIBWORKDIR}/${ARCH}-linux-gnu/${PROGNAME}/${UPSTREAMVER}" ] ; then
				${MKDIR} ${MKDIR_OPTS} "${LIBWORKDIR}/${ARCH}-linux-gnu/${PROGNAME}/${UPSTREAMVER}"
			fi

			${MV} ${MV_OPTS_FUNC_REORG} "${Library}" "${LIBWORKDIR}/${ARCH}-linux-gnu/${PROGNAME}/${UPSTREAMVER}/${SONAME}${SOVERSION}" && ${LN} ${LN_OPTS_FUNC_REORG} "${SONAME}${SOVERSION}" "${LIBWORKDIR}/${ARCH}-linux-gnu/${PROGNAME}/${UPSTREAMVER}/${SONAME}"

			if [ "${ARCH}" = "x86_64" ] ; then
				ARCH="amd64"
			fi

			if [ "${ARCH}" != "${HOSTARCH}" ] ; then
				LIBALTARCH="${ARCH}"
			fi

			if [ -f "${1}/libraries.csv" ] ; then
				if [ $(${GREP} ${GREP_OPTS_COUNT} "${SONAME}" "${1}/libraries.csv") -lt 1 ] ; then
					printf "${SONAME};${SOVERSION}\n" >>"${1}/libraries.csv"
				fi
			else
				printf "${SONAME};${SOVERSION}\n" >>"${1}/libraries.csv"
			fi
		done
	fi

	${MV} ${MV_OPTS_FUNC_REORG} "${OPTDIR}" "${1}/${INSTDIR}/${UPSTREAMVER}"
	${MKDIR} ${MKDIR_OPTS} "${OPTDIR}"
	${MV} ${MV_OPTS_FUNC_REORG} "${1}/${INSTDIR}/${UPSTREAMVER}" "${OPTDIR}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Cleans up the work direcory from cruft and binaries from other OS
#
func_cleanup() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_cleanup() <directory>\n"
		return 1
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "Cleaning up work directory \"%s\" for compliant package(s) generation:\n" "${1}"
	fi

	local CHMOD_OPTS_EXEC="755"
	local CHMOD_OPTS_NOEXEC="644"
	local CUT_OPTS_FUNC_CLEAN="-d : -f 1"
	local MV_OPTS_FUNC_CLEAN="--strip-trailing-slashes"
	local RM_OPTS_FUNC_CLEAN="-rf"
	local RMDIR_OPTS_FUNC_CLEAN="-p --ignore-fail-on-non-empty"
	local SED_OPTS_INLINE="-i ${SED_OPTS}"
	local OPTDIR="${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}"
	FUNC_CLEAN_DOCS=""

	if ! [ -d "${OPTDIR}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "func_cleanup(): Directory \"%s\" not found, aborting...\n" "${OPTDIR}" >&2
		else
			printf "%s - func_cleanup(): Directory \"%s\" not found, aborting...\n" "${INVOCATION}" "${OPTDIR}" >&2
		fi

		exit 1
	fi

	# Deletes
	#
	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdeleting foreign binaries"
	fi

	# Binaries from other OSs and Zip archives
	${FIND} "${OPTDIR}" ! \( -type d -o -iname "*.jar" \) |${XARGS} ${XARGS_OPTS} ${FILE} ${FILE_OPTS} |${GREP} ${GREP_OPTS} "PE32\+ executable|PE32 executable|MS-DOS batch|Zip archive data" |${CUT} ${CUT_OPTS_FUNC_CLEAN} |${XARGS} ${XARGS_OPTS} ${RM} ${RM_OPTS_FUNC_CLEAN}
	${FIND} "${OPTDIR}" ! -type d \( -iname "*.bat" \) |${XARGS} ${XARGS_OPTS} ${RM} ${RM_OPTS_FUNC_CLEAN}

	if [ ${SILENT} -eq 0 ] ; then
		printf ", image thumbnails and caches"
	fi

	# Image thumbnails and caches
	${FIND} "${OPTDIR}" ! -type d \( -iname "Thumbs.db" \) |${XARGS} ${XARGS_OPTS} ${RM} ${RM_OPTS_FUNC_CLEAN}

	if [ ${SILENT} -eq 0 ] ; then
		printf ", foreign configuration files"
	fi

	# Configuration files from other OSs
	${RM} ${RM_OPTS_FUNC_CLEAN} "${OPTDIR}/${PROGNAME}/bin/sqldeveloper-Darwin.conf"

	if [ ${SILENT} -eq 0 ] ; then
		printf ", source code"
	fi

	# Source-code
	${RM} ${RM_OPTS_FUNC_CLEAN} "${OPTDIR}/jdev/extensions/oracle.jdeveloper.subversion/svnClientAdapter-src.jar"

	if [ ${SILENT} -eq 0 ] ; then
		printf ", empty directories"
	fi

	# Empty directories
	${FIND} "${OPTDIR}" -type d -empty |${XARGS} ${XARGS_OPTS} ${RMDIR} ${RMDIR_OPTS_FUNC_CLEAN}

	if [ ${SILENT} -eq 0 ] ; then
		printf ", done!\n"
	fi

	# Fixes
	#
	if [ ${SILENT} -eq 0 ] ; then
		printf "\tfixing shebang lines"
	fi

	# Remove spaces and fix path from shebang line
	for f in $(${FIND} "${OPTDIR}" ! \( -type d -o -iname "*.jar" \) |${XARGS} ${XARGS_OPTS} ${FILE} ${FILE_OPTS} |${GREP} ${GREP_OPTS} "ASCII|Perl script" |${CUT} ${CUT_OPTS_FUNC_CLEAN} |${SED} ${SED_OPTS} 's/[[:space:]]/#/g') ; do
		${SED} ${SED_OPTS_INLINE} 's%^ #!%#!%1;s%^#!/usr/bin%#!/bin%1;s%^#!/usr/local%#!/usr%1' "$(printf "${f}\n" |${SED} ${SED_OPTS} 's/#/ /g')"
	done

	if [ ${SILENT} -eq 0 ] ; then
		printf ", executable bit"
	fi

	# Set executable bit
	${FIND} "${OPTDIR}" ! -type d -iname "*.jar" |${XARGS} ${XARGS_OPTS} ${CHMOD} ${CHMOD_OPTS_NOEXEC}
	${FIND} "${OPTDIR}" ! \( -type d -o -iname "*.jar" \) |${XARGS} ${XARGS_OPTS} ${FILE} ${FILE_OPTS} |${GREP} ${GREP_OPTS} "text executable" |${GREP} ${GREP_OPTS} "Perl script|shell script|/bin/ksh"|${CUT} ${CUT_OPTS_FUNC_CLEAN} |${XARGS} ${XARGS_OPTS} ${CHMOD} ${CHMOD_OPTS_EXEC}

	if [ ${SILENT} -eq 0 ] ; then
		printf ", done!\n"
	fi

	# Documentation
	#
	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdocumenting demo files"
	fi

	${MKDIR} ${MKDIR_OPTS} "${WORKDIR}/usr/share/doc/${PROGNAME}-${UPSTREAMVER}"

	# Demo files
	if [ -d "${OPTDIR}/${PROGNAME}/demo" ] ; then
		${MV} ${MV_OPTS_FUNC_CLEAN} "${OPTDIR}/${PROGNAME}/demo" "${WORKDIR}/usr/share/doc/${PROGNAME}-${UPSTREAMVER}"
		FUNC_CLEAN_DOCS="demos ${FUNC_CLEAN_DOCS}"
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf ", theme templates"
	fi

	# Theme files
	if [ -d "${OPTDIR}/ide/themes" ] ; then
		${MKDIR} ${MKDIR_OPTS} "${WORKDIR}/usr/share/doc/${PROGNAME}-${UPSTREAMVER}/themes"
		${MV} ${MV_OPTS_FUNC_CLEAN} "${OPTDIR}/ide/themes/"*.html "${OPTDIR}/ide/themes/"*.png "${WORKDIR}/usr/share/doc/${PROGNAME}-${UPSTREAMVER}/themes"
		FUNC_CLEAN_DOCS="themes ${FUNC_CLEAN_DOCS}"
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf ", application notes"
	fi

	# Application notes
	for note in $( ${FIND} "${OPTDIR}" -maxdepth 1 -mindepth 1 ! -type d \( -iname "readme.*" -o -iname "relnotes.*" \)) ; do
		${MV} ${MV_OPTS_FUNC_CLEAN} "${note}" "${WORKDIR}/usr/share/doc/${PROGNAME}-${UPSTREAMVER}"
		FUNC_CLEAN_DOCS="notes ${FUNC_CLEAN_DOCS}"
	done

	if [ ${SILENT} -eq 0 ] ; then
		printf ", done!\n"
	fi

	if [ "${UPSTREAMVER}" = "1.0.0" ] ; then
		func_firstver ${OPTDIR}
	fi

	return 0
}

# Setup the debian directory
#
func_debianize() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_debianize() <directory>\n"
		return 1
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "Populating the \"%s/debian\" package control directory:\n" "${1}"
	fi

	if ! [ -d "${1}" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "func_debianize(): Directory \"%s\" not found, aborting...\n" "${1}" >&2
		else
			printf "%s - func_debianize(): Directory \"%s\" not found, aborting...\n" "${INVOCATION}" "${1}" >&2
		fi

		exit 1
	fi

	local CUT_OPTS_LIB="-d ; -f"
	local CUT_OPTS_LIBCVER="-d _ -f 2"
	local CHMOD_OPTS_FUNC_DEB="755"
	local DATE_OPTS_FUNC_DEB="-R"
	local DPKG_QUERY_OPTS_VERSION="--showformat=\${Version} --show"
	local FOLD_OPTS_FUNC_DEB="-w 79 -s"
	local GREP_OPTS_COUNT="${GREP_OPTS} -c"
	local GREP_OPTS_LIBCVER="${GREP_OPTS} -m 1"
	local MV_OPTS_FUNC_DEB="--strip-trailing-slashes"
	local OBJDUMP_OPTS_FUNC_DEB="-p"
	local RM_OPTS_FUNC_DEB="-rf"
	local RMDIR_OPTS_FUNC_DEB="-p --ignore-fail-on-non-empty"
	CSVLIBS=0
	LIBJNIDISPATCH=0
	local BINSDIR="${USRDIR}/bin"
	local DEBIAN_WORKDIR="${1}/debian"
	local POSTINST_PRIO=$(printf "%02u%02u%02u" ${UPSTREAMVERMAJ} ${UPSTREAMVERMIN} ${UPSTREAMVERREV})
	POSTINST_PRIO="$(printf "%0${#POSTINST_PRIO}u" "$(${EXPR} ${EXPR_OPTS} ${POSTINST_PRIO} - 1)" )"
	local SDCLI=0
	local SQLCL=0
	${MKDIR} ${MKDIR_OPTS} "${DEBIAN_WORKDIR}"

	if [ -x "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/bin/sdcli" ] ; then
		SDCLI=1
	fi

	if [ -x "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/bin/sql" ] ; then
		SQLCL=1
	fi

	if [ ${SKIPLIB} -eq 0 ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tfinding libraries to build ... "
		fi

		if [ -f "${1}/libraries.csv" ] ; then
			${MV} ${MV_OPTS_FUNC_DEB} "${1}/libraries.csv" "${DEBIAN_WORKDIR}"
			CSVLIBS=1

			if [ $(${GREP} ${GREP_OPTS_COUNT} "libjnidispatch" "${DEBIAN_WORKDIR}/libraries.csv" ) -gt 0 ] ; then
				LIBJNIDISPATCH=1
				local LINE="$(${GREP} ${GREP_OPTS} "libjnidispatch" "${DEBIAN_WORKDIR}/libraries.csv")"
				local JNISONAME="$(printf ${LINE} |${CUT} ${CUT_OPTS_LIB} 1)"
				JNISOVERSION="$(printf ${LINE} |${CUT} ${CUT_OPTS_LIB} 2)"
				JNISOVERSION="${JNISOVERSION#\.}"
				JNILIBNAME="${JNISONAME%\.so}"
			fi
		fi

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdebian/changelog ... "
	fi

	(
	${CAT} <<EOF
${PROGNAME}-${UPSTREAMVER} (${UPSTREAMVER}+${VERSION}-${LOCALVER}) unstable; urgency=low

  * Built with ${INVOCATION} ${VERSION} (Closes: #${ITP})
  * Multiple versions can coexist so "sqldeveloper.[upstream version]" will
    invoke a specific version of Oracle SQL Developer while "sqldeveloper"
    takes advantage of Debian's alternatives system and, when left in auto
    mode, will always invoke the highest version installed
EOF
	) >"${DEBIAN_WORKDIR}/changelog"

	if [ ${SDCLI} -ne 0 ] ; then
		(
		${CAT} <<EOF
  * The same will apply to Oracle CLI for SQL Developer with
    "sdcli.[upstream version]" and "sdcli"
EOF
		) >>"${DEBIAN_WORKDIR}/changelog"
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		(
		${CAT} <<EOF
  * Since version 4.2 Oracle started to bundle Oracle SQL Developer
    Command-Line (SQLcl) with Oracle SQL Developer. When available, and as an
    alternative to the standalone package (see "sqlcl-package"),
    "sql.[upstream version].bundled" will invoke a specific version of SQLcl
    while "sqlcl.bundled" takes advantage of Debian's alternatives system and,
    when left in auto mode, will always invoke the highest bundled version
    installed, and "sqlcl" will invoke the highest version installed (either
    standalone or bundled (in this order)
EOF
		) >>"${DEBIAN_WORKDIR}/changelog"
	fi

	printf "\n -- %s <%s>  %s\n" "${DEBFULLNAME}" "${DEBEMAIL}" "$(${DATE} ${DATE_OPTS_FUNC_DEB})" >>"${DEBIAN_WORKDIR}/changelog"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/compat ... "
	fi

	printf "11\n" >"${DEBIAN_WORKDIR}/compat"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/control ... "
	fi

	(
	${CAT} <<EOF
Source: ${PROGNAME}-${UPSTREAMVER}
Section: non-free/misc
Priority: optional
Maintainer: ${DEBFULLNAME} <${DEBEMAIL}>
Build-Depends: debhelper (>= $(${DPKG_QUERY} ${DPKG_QUERY_OPTS_VERSION} debhelper))
Standards-Version: ${STANDARDS}
Homepage: ${HOMEPAGE}

Package: ${PROGNAME}-${UPSTREAMVER}
Architecture: all
EOF
	) >"${DEBIAN_WORKDIR}/control"

	if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 ] ; then
		printf "Multi-Arch: foreign\n" >>"${DEBIAN_WORKDIR}/control"
	fi

	printf "Depends: \${misc:Depends}, xterm | x-terminal-emulator\n" >>"${DEBIAN_WORKDIR}/control"
	printf "Recommends: " >>"${DEBIAN_WORKDIR}/control"
	[ ${UPSTREAMVERMAJ} -gt 3 ] && {
		[ ${UPSTREAMVERMAJ} -gt 4 ] && {
			printf "java8-sdk | java9-sdk" >>"${DEBIAN_WORKDIR}/control"
		} || {
			[ ${UPSTREAMVERMIN} -gt 0 ] && {
				printf "java8-sdk | java9-sdk" >>"${DEBIAN_WORKDIR}/control"
			} || {
				printf "java7-sdk" >>"${DEBIAN_WORKDIR}/control"
			}
		}
	} || {
		printf "java6-sdk" >>"${DEBIAN_WORKDIR}/control"
		[ ${UPSTREAMVERMAJ} -lt 2 ] && printf " | java5-sdk" >>"${DEBIAN_WORKDIR}/control"
	}

	if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 -a ${LIBJNIDISPATCH} -eq 1 ] ; then
		printf ", ${JNILIBNAME} (= ${JNISOVERSION}+${VERSION})" >>"${DEBIAN_WORKDIR}/control"
	fi

	printf "\n" >>"${DEBIAN_WORKDIR}/control"
	printf "Provides: oracle-sql-client, oracle-sql-client-gui," >>"${DEBIAN_WORKDIR}/control"

	if [ ${SQLCL} -ne 0 ] ; then
		printf " oracle-sql-client-cli," >>"${DEBIAN_WORKDIR}/control"
	fi

	printf "\n %s" "${PROGNAME}" >>"${DEBIAN_WORKDIR}/control"

	if [ ${SQLCL} -ne 0 ] ; then
		printf ", sqlcl.bundled, sqlcl" >>"${DEBIAN_WORKDIR}/control"
	fi

	printf "\n" >>"${DEBIAN_WORKDIR}/control"

	(
	${CAT} <<EOF
Description: Oracle SQL Developer
 Oracle SQL Developer is a free integrated development environment that
 simplifies the development and management of Oracle Database in both
 traditional and Cloud deployments.  SQL Developer offers complete end-to-end
 development of your PL/SQL applications, a worksheet for running queries and
 scripts, a DBA console for managing the database, a reports interface, a
 complete data modeling solution, and a migration platform for moving your
 3rd party databases to Oracle.
 .
 Oracle SQL Developer is a Java application and requires a full Java SDK.  The
 minimum JDK you should use is as follows:
 .
 Oracle SQL Developer versions up to 1.5.5 require a minimum JDK of 1.5.0_06,
 or if you use JDK 1.6 (JDK6.0), the minimum you should use is JDK 1.6.0_03.
 Oracle SQL Developer versions 2.1 up to 3.1 require a minimum JDK of 1.6.0_11.
 Oracle SQL Developer version 3.2 requires a minimum JDK of 1.6.0_04.
 Oracle SQL Developer version 4.0 requires a minimum JDK of 1.7 (JDK7.0).
 Oracle SQL Developer versions 4.1 up to 17.3  require a minimum  JDK  of  1.8
 (JDK8.0).
 .
 Note that JDK1.7 (JDK7.0) or newer is not supported  by  Oracle SQL Developer
 prior to version 4.0 and that JDK1.8 (JDK8.0) or newer is not supported prior
 to version 4.1.
EOF
	) >>"${DEBIAN_WORKDIR}/control"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/rules ... "
	fi

	(
	${CAT} <<EOF
#!/usr/bin/make -f

# verbose mode
#export DH_VERBOSE=1

DEB_HOST_MULTIARCH ?= \$(shell ${DPKG_ARCHITECTURE} -qDEB_HOST_MULTIARCH)

PREPROCESS_FILES := \$(wildcard debian/*.in)

\$(PREPROCESS_FILES:.in=): %: %.in
	${SED} ${SED_OPTS} 's,/@DEB_HOST_MULTIARCH@,\$(DEB_HOST_MULTIARCH:%=/%),g' \$< > \$@

override_dh_auto_clean:
	dh_auto_clean
	${RM} ${RM_OPTS_FUNC_DEB} \$(PREPROCESS_FILES:.in=)

override_dh_auto_install: \$(PREPROCESS_FILES:.in=)
	dh_auto_install

override_dh_builddeb:
	dh_builddeb --destdir="${CURDIR}"

override_dh_shlibdeps:
	dh_shlibdeps -- --warnings=2

override_dh_strip_nondeterminism:

%:
	dh \$@
EOF
	) >"${DEBIAN_WORKDIR}/rules" && ${CHMOD} ${CHMOD_OPTS_FUNC_DEB} "${DEBIAN_WORKDIR}/rules"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.copyright ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Oracle SQL Developer
Upstream-Contact: https://www.oracle.com/corporate/contact/index.html
Source: ${HOMEPAGE}
Disclaimer:
 This package is not part of the Debian GNU/Linux distribution. It falls into
 category 2.2.3 of the Debian Policy Manual ("... not compliant with the DFSG
 or are encumbered by patents or other legal issues that make their
 distribution problematic.").
Comment:
 This package was debianized by ${DEBFULLNAME} <${DEBEMAIL}> on
 $(${DATE} ${DATE_OPTS_FUNC_DEB}).

Files: *
Copyright: Copyright © 2009-2017 Oracle USA, Inc.
License: OracleSQLDeveloper

Files: debian/*
Copyright: Copyright © 2009-2018 Lazarus Long <lazarus.long@sapo.pt>
License: GPL-3+

License: OracleSQLDeveloper
 Oracle SQL Developer License Terms
 Oracle SQL Developer Data Modeler License Terms
 .
 Export Controls on the Programs
 Selecting the "Accept License Agreement" button is a confirmation of
 your agreement that you comply, now and during the trial term, with
 each of the following statements:
 .
 -You are not a citizen, national, or resident of, and are not under
  control of, the government of Cuba, Iran, Sudan, Libya, North Korea,
  Syria, nor any country to which the United States has prohibited export.
 -You will not download or otherwise export or re-export the Programs,
  directly or indirectly, to the above mentioned countries nor to citizens,
  nationals or residents of those countries.
 -You are not listed on the United States Department of Treasury lists
  of Specially Designated Nationals, Specially Designated Terrorists,
  and Specially Designated Narcotic Traffickers, nor are you listed on
  the United States Department of Commerce Table of Denial Orders.
 .
 You will not download or otherwise export or re-export the Programs,
 directly or indirectly, to persons on the above mentioned lists.
 .
 You will not use the Programs for, and will not allow the Programs to
 be used for, any purposes prohibited by United States law, including,
 without limitation, for the development, design, manufacture or production
 of nuclear, chemical or biological weapons of mass destruction.
 .
 EXPORT RESTRICTIONS
 You agree that U.S. export control laws and other applicable export
 and import laws govern your use of the programs, including technical
 data; additional information can be found on Oracle®'s Global Trade
 Compliance web site (http://www.oracle.com/products/export).
 .
 You agree that neither the programs nor any direct product thereof will
 be exported, directly, or indirectly, in violation of these laws, or
 will be used for any purpose prohibited by these laws including, without
 limitation, nuclear, chemical, or biological weapons proliferation.
 .
 Oracle Employees: Under no circumstances are Oracle Employees
 authorized to download software for the purpose of distributing it to
 customers. Oracle products are available to employees for internal
 use or demonstration purposes only. In keeping with Oracle's trade
 compliance obligations under U.S. and applicable multilateral law,
 failure to comply with this policy could result in disciplinary action
 up to and including termination.
 .
 Note: You are bound by the Oracle Technology Network ("OTN") License
 Agreement terms. The OTN License Agreement terms also apply to all
 updates you receive under your Technology Track subscription.
 .
 The OTN License Agreement terms below supersede any shrinkwrap license
 on the OTN Technology Track software CDs and previous OTN License terms
 (including the Oracle Program License as modified by the OTN Program
 Use Certificate).
 .
 Oracle SQL Developer License Agreement
 Oracle SQL Developer Data Modeler License Agreement
 .
 "We," "us," and "our" refers to Oracle America, Inc., for and on behalf of
 itself and its subsidiaries and affiliates under common control. "You" and
 "your" refers to the individual or entity that wishes to use the programs
 from Oracle. "Programs" refers to the Oracle software product you wish to
 download and use and program documentation. "License" refers to your right
 to use the programs under the terms of this agreement. This agreement
 is governed by the substantive and procedural laws of California. You
 and Oracle agree to submit to the exclusive jurisdiction of, and venue
 in, the courts of San Francisco, San Mateo, or Santa Clara counties in
 California in any dispute arising out of or relating to this agreement.
 .
 We are willing to license the programs to you only upon the condition
 that you accept all of the terms contained in this agreement. Read the
 terms carefully and select the "Accept" button at the bottom of the
 page to confirm your acceptance. If you are not willing to be bound
 by these terms, select the "Do Not Accept" button and the registration
 process will not continue.
 .
 LICENSE RIGHTS
 We grant you a nonexclusive, nontransferable limited license to use
 the programs solely for your business operations and any third party
 training as part of such business operations. We may audit your use
 of the programs. Program documentation may be accessed online at
 http://www.oracle.com/technetwork/indexes/documentation/index.html.
 .
 Ownership and Restrictions
 We retain all ownership and intellectual property rights in the
 programs. You may make a sufficient number of copies of the programs
 for the licensed use and one copy of the programs for backup purposes.
 .
 You may not:
 - remove or modify any program markings or any notice of our proprietary
   rights;
 - make the programs available in any manner to any third party, other
   than as specified above;
 - use the programs for any purpose other than as provided above;
 - assign this agreement or give or transfer the programs or an interest
   in them to another individual or entity;
 - cause or permit reverse engineering (unless required by law for
   interoperability), disassembly or decompilation of the programs;
 - disclose results of any program benchmark tests without our prior
   consent.
 .
 Export
 You agree that U.S. export control laws and other applicable
 export and import laws govern your use of the programs,
 including technical data; additional information can be
 found on Oracle's Global Trade Compliance web site located at
 http://www.oracle.com/products/export/index.html?content.html. You
 agree that neither the programs nor any direct product thereof will be
 exported, directly, or indirectly, in violation of these laws, or will
 be used for any purpose prohibited by these laws including, without
 limitation, nuclear, chemical, or biological weapons proliferation.
 .
 Disclaimer of Warranty and Exclusive Remedies
 THE PROGRAMS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. WE
 FURTHER DISCLAIM ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT
 LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 PARTICULAR PURPOSE OR NONINFRINGEMENT.
 .
 IN NO EVENT SHALL WE BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF PROFITS,
 REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER
 IN AN ACTION IN CONTRACT OR TORT, EVEN IF WE HAVE BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES. OUR ENTIRE LIABILITY FOR DAMAGES HEREUNDER
 SHALL IN NO EVENT EXCEED ONE THOUSAND DOLLARS (U.S. \$1,000).
 .
 Trial Programs Included With Orders
 We may include additional programs with an order which may be used for
 trial purposes only. You will have 30 days from the delivery date to
 evaluate these programs. Any use of these programs after the 30 day
 trial period requires you to obtain the applicable license. Programs
 licensed for trial purposes are provided "as is" and we do not provide
 technical support or any warranties for these programs.
 .
 Technical Support
 Our technical support organization does not provide technical support,
 phone support, or updates specifically for the programs licensed under
 this agreement. However, if you have a supported license of an Oracle
 database program, then the technical support organization will provide
 technical support, phone support for the program licensed hereunder in
 conjunction with the Oracle database program license.
 .
 End of Agreement
 You may terminate this agreement by destroying all copies of the
 programs. We have the right to terminate your right to use the programs
 if you fail to comply with any of the terms of this agreement, in which
 case you shall destroy all copies of the programs.
 .
 Relationship Between the Parties
 The relationship between you and us is that of licensee/licensor. Neither
 party will represent that it has any authority to assume or create
 any obligation, express or implied, on behalf of the other party,
 nor to represent the other party as agent, employee, franchisee, or
 in any other capacity. Nothing in this agreement shall be construed
 to limit either party's right to independently develop or distribute
 software that is functionally similar to the other party's products,
 so long as proprietary information of the other party is not included
 in such software.
 .
 Open Source
 Third party technology that may be appropriate or necessary for use with
 the program may be specified in the program documentation. To the extent
 stated in the program documentation, such third party technology is
 licensed to you under the terms of the third party technology license
 agreement specified in the program documentation and not under the
 terms of this agreement. Nothing in this agreement should be construed
 as modifying or limiting your rights to use such third party technology
 under the terms of the specified third party license.
 .
 Entire Agreement
 You agree that this agreement is the complete agreement for the programs
 and licenses, and this agreement supersedes all prior or contemporaneous
 agreements or representations. If any term of this agreement is found
 to be invalid or unenforceable, the remaining provisions will remain
 effective.
 .
 Last updated: 09/17/10 (jlr)
 .
 Should you have any questions concerning this License Agreement, or if
 you desire to contact Oracle for any reason, please write:
 .
 Oracle America, Inc.
 500 Oracle Parkway,
 Redwood City, CA 94065
 .
 Oracle may contact you to ask if you had a satisfactory experience
 installing and using this OTN software download.
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"

	if [ -f "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/extensions/oracle.sqldeveloper.onsd/LICENSE.txt" ] ; then
		(
		${CAT} <<EOF

Files: ${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/extensions/oracle.sqldeveloper.onsd*
Copyright: Copyright © 2009-2017 Oracle USA, Inc.
License: Apache-2.0
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"

		${RM} ${RM_OPTS_FUNC_DEB} "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/extensions/oracle.sqldeveloper.onsd/LICENSE.txt"
	fi

	if [ -d "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.git/license" ] ; then
		(
		${CAT} <<EOF

Files: ${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.git*
Copyright: Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
License: Eclipse-1.0

License: Eclipse-1.0
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"

		for l in ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.git/license/* ; do
			LICFILE="$(${BASENAME} ${l})"

			${CAT} "${l}" | ${FROMDOS} |${SED} ${SED_OPTS} 's/^[[:space:]]*//g' |${FOLD} ${FOLD_OPTS_FUNC_DEB} |${SED} ${SED_OPTS} 's/^$/./g;s/^/ /g' >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"
		done

		${RM} ${RM_OPTS_FUNC_DEB} ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.git/license/*
		${RMDIR} ${RMDIR_OPTS_FUNC_DEB} "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.git/license"
	fi


	if [ -d "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.subversion/licenses" ] ; then
		(
		${CAT} <<EOF

Files: ${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.subversion*
Copyright: Copyright (c) 2004-2009 TMate Software. All rights reserved.
License: Apache-2.0 or TMate

License: TMate
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"

		for l in ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.subversion/licenses/* ; do
			LICFILE="$(${BASENAME} ${l})"

			if [ "${LICFILE}" = "license.txt" ] ; then
				continue
			fi

			${CAT} "${l}" | ${FROMDOS} |${SED} ${SED_OPTS} 's/^[[:space:]]*//g' |${FOLD} ${FOLD_OPTS_FUNC_DEB} |${SED} ${SED_OPTS} 's/^$/./g;s/^/ /g;s/explictly/explicitly/g' >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"
		done

		${RM} ${RM_OPTS_FUNC_DEB} ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.subversion/licenses/*
		${RMDIR} ${RMDIR_OPTS_FUNC_DEB} "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/extensions/oracle.jdeveloper.subversion/licenses"
	fi

	if [ -d "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/svnkit/licenses" ] ; then
		(
		${CAT} <<EOF

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/svnClientAdapter.jar
Copyright: Copyright (c) 2004-2009 TMate Software. All rights reserved.
License: Apache-2.0 or TMate

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/sqljet.jar
Copyright: Copyright (C) 2009-2010 TMate Software Ltd
License: GPL-2 or TMate

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/antlr-runtime.jar
Copyright: Copyright (c) 2003-2008 Terence Parr
License: BSD-3-clause

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/svnjavahl.jar
Copyright: Copyright (c) 2000-2005 CollabNet.  All rights reserved.
License: CollabNet-1

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/sequence.jar
Copyright: Copyright (c) 2000-2008 SyntEvo GmbH, Ainring, GERMANY.
License: SyntEvo

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/trilead.jar
Copyright: Copyright (c) 2007-2008 Trilead AG (http://www.trilead.com)
           Copyright (c) 2005 - 2006 Swiss Federal Institute of Technology
            (ETH Zurich), Department of Computer Science
            (http://www.inf.ethz.ch), Christian Plattner. All rights reserved.
           Copyright (c) 2000 - 2004 The Legion Of The Bouncy Castle
            (http://www.bouncycastle.org)
License: TriLead-ETHZurich-TheLegionOfTheBouncyCastle

Files: ${PROGNAME}/${UPSTREAMVER}/svnkit/svnkit.jar
Copyright: Copyright (c) 2004-2009 TMate Software. All rights reserved.
License: TMate
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"

		for l in ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/svnkit/licenses/* ; do
			LICFILE="$(${BASENAME} ${l})"

			case "${LICFILE}" in
				"COPYING")
					LICNAME="TMate" ;;
				"JAVAHL-LICENSE")
					LICNAME="CollabNet-1" ;;
				"SEQUENCE-LICENSE")
					LICNAME="SyntEvo" ;;
				"TRILEAD-LICENSE")
					LICNAME="TriLead-ETHZurich-TheLegionOfTheBouncyCastle" ;;
				*)
					continue ;;
			esac

			if [ $(${GREP} ${GREP_OPTS_COUNT} "^License: ${LICNAME}$" "${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright") -gt 1 ] ; then
				continue
			fi

			printf "\nLicense: %s\n" "${LICNAME}" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"
			${CAT} "${l}" | ${FROMDOS} |${SED} ${SED_OPTS} 's/^[[:space:]]*//g' |${FOLD} ${FOLD_OPTS_FUNC_DEB} |${SED} ${SED_OPTS} 's/^$/./g;s/^/ /g;s/explictly/explicitly/g' >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.copyright"
		done

		${RM} ${RM_OPTS_FUNC_DEB} ${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/svnkit/licenses/*
		${RMDIR} ${RMDIR_OPTS_FUNC_DEB} "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/svnkit/licenses"
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	if [ $(printf "${FUNC_CLEAN_DOCS}" |${GREP} ${GREP_OPTS_COUNT} "themes" )  -ne 0 ] ; then
	
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s.doc-base ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		(
		${CAT} <<EOF
Document: ${PROGNAME}-${UPSTREAMVER}-creating-themes
Title: Defining Visual Themes
Author: Oracle USA, Inc.
Abstract: The focus of this document is on theme providers - those who are
 defining the visual characteristics of the product by creating or modifying
 theme definitions. A separate document, Implementing Visual Themes is of
 interest to extension developers who want to use the theme engine to allow
 the visual design of their components to be customized.
Section: Programming

Format: HTML
Index: /usr/share/doc/${PROGNAME}-${UPSTREAMVER}/themes/creating_themes.html
FIles: /usr/share/doc/${PROGNAME}-${UPSTREAMVER}/themes/creating_themes.html
EOF
		) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.doc-base"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 -a ${LIBJNIDISPATCH} -eq 1 ] ; then
		for Arch in x86_64 i386 ; do
			local JNISOFILE="${1}/${LIBSDIR}/${Arch}-linux-gnu/${PROGNAME}/${UPSTREAMVER}/${JNISONAME}.${JNISOVERSION}"
			local JNIARCHNAME="${Arch}"

			if [ "${JNIARCHNAME}" = "x86_64" ] ; then
				JNIARCHNAME="amd64"
			fi

			if [ -f "${JNISOFILE}" ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "\tdebian/%s.shlibs.%s ... " "${JNILIBNAME}-${UPSTREAMVER}" "${JNIARCHNAME}"
				fi

				local JNIREALSONAME="$(${OBJDUMP} ${OBJDUMP_OPTS_FUNC_DEB} "${JNISOFILE}" |${GREP} ${GREP_OPTS} "SONAME" |${SED} ${SED_OPTS} 's/^[[:space:]]*SONAME[[:space:]]*//')"
				eval "local JNILIBCVER${JNIARCHNAME}=\"\$(\${OBJDUMP} \${OBJDUMP_OPTS_FUNC_DEB} \"\${JNISOFILE}\" |\${GREP} \${GREP_OPTS_LIBCVER} \"GLIBC\" |\${CUT} \${CUT_OPTS_LIBCVER})\""
				printf "${JNIREALSONAME%\.so} #MINVER# ${JNILIBNAME}-${UPSTREAMVER} (>= ${JNISOVERSION}+${VERSION}-${LOCALVER})\n" >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.shlibs.${JNIARCHNAME}"

				if [ ${SILENT} -eq 0 ] ; then
					printf "done!\n"
				fi
			fi
		done

		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s.changelog ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		(
		${CAT} <<EOF
${PROGNAME}-${UPSTREAMVER} (${JNISOVERSION}+${VERSION}-${LOCALVER}) unstable; urgency=low

  * Built with ${INVOCATION} ${VERSION} (Closes: #${ITP})
  * Since SQL Developer v4.1, Oracle has started to include i386 and amd64
    shared libraries in NetBeans Platform modules. Due to this, converted
    make-sqldeveloper-package to both generate multiple packages and to be
    Multi-Arch compatible

 -- ${DEBFULLNAME} <${DEBEMAIL}>  $(${DATE} ${DATE_OPTS_FUNC_DEB})
EOF
		) >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.changelog"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
			printf "\tdebian/control ... "
		fi

		(
		${CAT} <<EOF

Package: ${JNILIBNAME}-${UPSTREAMVER}
Architecture: amd64 i386
Multi-Arch: same
Section: non-free/libs
Pre-Depends: \${misc:Pre-Depends}
Depends: \${misc:Depends}, libc6 (>= ${JNILIBCVERi386}) [i386] | libc6 (>= ${JNILIBCVERamd64}) [amd64]
Recommends: ${PROGNAME}-${UPSTREAMVER} (= ${UPSTREAMVER}+${VERSION}-${LOCALVER})
Provides: ${JNILIBNAME}
Homepage: http://www.netbeans.org
Description: NetBeans Platform JNI dispatch library
 This package is part of, and intended to work with, the Oracle SQL Developer
 package.
 .
 Oracle SQL Developer is a free graphical tool that enhances productivity and
 simplifies database development tasks.  With SQL Developer, you can browse
 database objects, run SQL statements and SQL scripts, and edit and debug
 PL/SQL statements.  You can also run any number of provided reports, as well
 as create and save your own.  You can connect to and migrate 3rd party
 databases to an Oracle database.
 .
 Oracle SQL Developer is a Java application and requires a full Java SDK.
 .
 This is the NetBeans Platform JNI dispatch library used to connect Oracle SQL
 Developer with the NetBeans Platform and IDE, which is already included in
 Oracle SQL Developer.
EOF
		) >>"${DEBIAN_WORKDIR}/control"

		if [ ${SILENT} -eq 0 ] ; then
			printf "updated!\n"
			printf "\tdebian/%s.copyright ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		(
		${CAT} <<EOF
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: NetBeans Platform
Upstream-Contact: http://www.netbeans.org
Source: http://netbeans.org/features/platform/download.html
Disclaimer:
 This package is not part of the Debian GNU/Linux distribution. It falls into
 category 2.2.3 of the Debian Policy Manual ("... not compliant with the DFSG
 or are encumbered by patents or other legal issues that make their
 distribution problematic.").
Comment:
 This package was debianized by ${DEBFULLNAME} <${DEBEMAIL}> on
 $(${DATE} ${DATE_OPTS_FUNC_DEB}).

Files: *
Copyright: Copyright © 1997-2010 Oracle and/or its affiliates
License: CDDL-1.0 or GPL-2 with Classpath exception

Files: debian/*
Copyright: Copyright © 2009-2018 Lazarus Long <lazarus.long@sapo.pt>
License: GPL-3+

License: CDDL-1.0
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
 .
 Version 1.0
 1. Definitions.
 .
 1.1. “Contributor” means each individual or entity that creates or 
 contributes to the creation of Modifications.
 .
 1.2. “Contributor Version” means the combination of the Original Software, 
 prior Modifications used by a Contributor (if any), and the Modifications made 
 by that particular Contributor.
 .
 1.3. “Covered Software” means (a) the Original Software, or (b) 
 Modifications, or (c) the combination of files containing Original Software 
 with files containing Modifications, in each case including portions thereof.
 .
 1.4. “Executable” means the Covered Software in any form other than Source 
 Code.
 .
 1.5. “Initial Developer” means the individual or entity that first makes 
 Original Software available under this License.
 .
 1.6. “Larger Work” means a work which combines Covered Software or 
 portions thereof with code not governed by the terms of this License.
 .
 1.7. “License” means this document.
 .
 1.8. “Licensable” means having the right to grant, to the maximum extent 
 possible, whether at the time of the initial grant or subsequently acquired, 
 any and all of the rights conveyed herein.
 .
 1.9. “Modifications” means the Source Code and Executable form of any of 
 the following:
 .
   A. Any file that results from an addition to, deletion from or 
   modification of the contents of a file containing Original Software or 
   previous Modifications;
 .
   B. Any new file that contains any part of the Original Software or 
   previous Modification; or
 .
   C. Any new file that is contributed or otherwise made available under the 
   terms of this License.
 .
 1.10. “Original Software” means the Source Code and Executable form of 
 computer software code that is originally released under this License.
 .
 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter 
 acquired, including without limitation, method, process, and apparatus claims, 
 in any patent Licensable by grantor.
 .
 1.12. “Source Code” means (a) the common form of computer software code in 
 which modifications are made and (b) associated documentation included in or 
 with such code.
 .
 1.13. “You” (or “Your”) means an individual or a legal entity 
 exercising rights under, and complying with all of the terms of, this License. 
 For legal entities, “You” includes any entity which controls, is 
 controlled by, or is under common control with You. For purposes of this 
 definition, “control” means (a) the power, direct or indirect, to cause 
 the direction or management of such entity, whether by contract or otherwise, 
 or (b) ownership of more than fifty percent (50%) of the outstanding shares or 
 beneficial ownership of such entity.
 .
 2. License Grants.
 .
 2.1. The Initial Developer Grant.
 .
 Conditioned upon Your compliance with Section 3.1 below and subject to third
 party intellectual property claims, the Initial Developer hereby grants You a
 world-wide, royalty-free, non-exclusive license:
 .
   (a) under intellectual property rights (other than patent or trademark) 
   Licensable by Initial Developer, to use, reproduce, modify, display,
   perform, sublicense and distribute the Original Software (or portions
   thereof), with or without Modifications, and/or as part of a Larger Work;
   and
 .
   (b) under Patent Claims infringed by the making, using or selling of 
   Original Software, to make, have made, use, practice, sell, and offer for 
   sale, and/or otherwise dispose of the Original Software (or portions
   thereof).
 .
   (c) The licenses granted in Sections 2.1(a) and (b) are effective on the 
   date Initial Developer first distributes or otherwise makes the Original 
   Software available to a third party under the terms of this License.
 .
   (d) Notwithstanding Section 2.1(b) above, no patent license is granted: 
   (1) for code that You delete from the Original Software, or (2) for 
   infringements caused by: (i) the modification of the Original Software, or 
   (ii) the combination of the Original Software with other software or
    devices.
 .
 2.2. Contributor Grant.
 .
 Conditioned upon Your compliance with Section 3.1 below and subject to third 
 party intellectual property claims, each Contributor hereby grants You a 
 world-wide, royalty-free, non-exclusive license:
 .
   (a) under intellectual property rights (other than patent or trademark) 
   Licensable by Contributor to use, reproduce, modify, display, perform, 
   sublicense and distribute the Modifications created by such Contributor (or 
   portions thereof), either on an unmodified basis, with other Modifications,
   as Covered Software and/or as part of a Larger Work; and
 .
   (b) under Patent Claims infringed by the making, using, or selling of 
   Modifications made by that Contributor either alone and/or in combination
   with its Contributor Version (or portions of such combination), to make,
   use, sell, offer for sale, have made, and/or otherwise dispose of: (1)
   Modifications made by that Contributor (or portions thereof); and (2) the
   combination of Modifications made by that Contributor with its Contributor
   Version (or portions of such combination).
 .
   (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on 
   the date Contributor first distributes or otherwise makes the Modifications 
   available to a third party.
 .
   (d) Notwithstanding Section 2.2(b) above, no patent license is granted: 
   (1) for any code that Contributor has deleted from the Contributor Version; 
   (2) for infringements caused by: (i) third party modifications of
   Contributor Version, or (ii) the combination of Modifications made by that
   Contributor with other software (except as part of the Contributor Version)
   or other devices; or (3) under Patent Claims infringed by Covered Software
   in the absence of Modifications made by that Contributor.
 .
 3. Distribution Obligations.
 .
 3.1. Availability of Source Code.
 .
 Any Covered Software that You distribute or otherwise make available in 
 Executable form must also be made available in Source Code form and that 
 Source Code form must be distributed only under the terms of this License. You 
 must include a copy of this License with every copy of the Source Code form of 
 the Covered Software You distribute or otherwise make available. You must 
 inform recipients of any such Covered Software in Executable form as to how 
 they can obtain such Covered Software in Source Code form in a reasonable 
 manner on or through a medium customarily used for software exchange.
 .
 3.2. Modifications.
 .
 The Modifications that You create or to which You contribute are governed by 
 the terms of this License. You represent that You believe Your Modifications 
 are Your original creation(s) and/or You have sufficient rights to grant the 
 rights conveyed by this License.
 .
 3.3. Required Notices.
 .
 You must include a notice in each of Your Modifications that identifies You as 
 the Contributor of the Modification. You may not remove or alter any 
 copyright, patent or trademark notices contained within the Covered Software, 
 or any notices of licensing or any descriptive text giving attribution to any 
 Contributor or the Initial Developer.
 .
 3.4. Application of Additional Terms.
 .
 You may not offer or impose any terms on any Covered Software in Source Code 
 form that alters or restricts the applicable version of this License or the 
 recipients’ rights hereunder. You may choose to offer, and to charge a fee 
 for, warranty, support, indemnity or liability obligations to one or more 
 recipients of Covered Software. However, you may do so only on Your own 
 behalf, and not on behalf of the Initial Developer or any Contributor. You 
 must make it absolutely clear that any such warranty, support, indemnity or 
 liability obligation is offered by You alone, and You hereby agree to 
 indemnify the Initial Developer and every Contributor for any liability 
 incurred by the Initial Developer or such Contributor as a result of warranty, 
 support, indemnity or liability terms You offer.
 .
 3.5. Distribution of Executable Versions.
 .
 You may distribute the Executable form of the Covered Software under the terms 
 of this License or under the terms of a license of Your choice, which may 
 contain terms different from this License, provided that You are in compliance 
 with the terms of this License and that the license for the Executable form 
 does not attempt to limit or alter the recipient’s rights in the Source Code 
 form from the rights set forth in this License. If You distribute the Covered 
 Software in Executable form under a different license, You must make it 
 absolutely clear that any terms which differ from this License are offered by 
 You alone, not by the Initial Developer or Contributor. You hereby agree to 
 indemnify the Initial Developer and every Contributor for any liability 
 incurred by the Initial Developer or such Contributor as a result of any such 
 terms You offer.
 .
 3.6. Larger Works.
 .
 You may create a Larger Work by combining Covered Software with other code not 
 governed by the terms of this License and distribute the Larger Work as a 
 single product. In such a case, You must make sure the requirements of this 
 License are fulfilled for the Covered Software.
 .
 4. Versions of the License.
 .
 4.1. New Versions.
 .
 Sun Microsystems, Inc. is the initial license steward and may publish revised 
 and/or new versions of this License from time to time. Each version will be 
 given a distinguishing version number. Except as provided in Section 4.3, no 
 one other than the license steward has the right to modify this License.
 .
 4.2. Effect of New Versions.
 .
 You may always continue to use, distribute or otherwise make the Covered 
 Software available under the terms of the version of the License under which 
 You originally received the Covered Software. If the Initial Developer 
 includes a notice in the Original Software prohibiting it from being 
 distributed or otherwise made available under any subsequent version of the 
 License, You must distribute and make the Covered Software available under the 
 terms of the version of the License under which You originally received the 
 Covered Software. Otherwise, You may also choose to use, distribute or 
 otherwise make the Covered Software available under the terms of any 
 subsequent version of the License published by the license steward.
 .
 4.3. Modified Versions.
 .
 When You are an Initial Developer and You want to create a new license for 
 Your Original Software, You may create and use a modified version of this 
 License if You: (a) rename the license and remove any references to the name 
 of the license steward (except to note that the license differs from this 
 License); and (b) otherwise make it clear that the license contains terms 
 which differ from this License.
 .
 5. DISCLAIMER OF WARRANTY.
 .
 COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, 
 WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT 
 LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, 
 MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK 
 AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD 
 ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL 
 DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY 
 SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN 
 ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED 
 HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
 .
 6. TERMINATION.
 .
 6.1. This License and the rights granted hereunder will terminate 
 automatically if You fail to comply with terms herein and fail to cure such 
 breach within 30 days of becoming aware of the breach. Provisions which, by 
 their nature, must remain in effect beyond the termination of this License 
 shall survive.
 .
 6.2. If You assert a patent infringement claim (excluding declaratory judgment 
 actions) against Initial Developer or a Contributor (the Initial Developer or 
 Contributor against whom You assert such claim is referred to as 
 “Participant”) alleging that the Participant Software (meaning the 
 Contributor Version where the Participant is a Contributor or the Original 
 Software where the Participant is the Initial Developer) directly or 
 indirectly infringes any patent, then any and all rights granted directly or 
 indirectly to You by such Participant, the Initial Developer (if the Initial 
 Developer is not the Participant) and all Contributors under Sections 2.1 
 and/or 2.2 of this License shall, upon 60 days notice from Participant 
 terminate prospectively and automatically at the expiration of such 60 day 
 notice period, unless if within such 60 day period You withdraw Your claim 
 with respect to the Participant Software against such Participant either 
 unilaterally or pursuant to a written agreement with Participant.
 .
 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user 
 licenses that have been validly granted by You or any distributor hereunder 
 prior to termination (excluding licenses granted to You by any distributor) 
 shall survive termination.
 .
 7. LIMITATION OF LIABILITY.
 .
 UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING 
 NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY 
 OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF 
 ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, 
 INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT 
 LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, 
 COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR 
 LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH 
 DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH 
 OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT 
 APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE 
 EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS 
 EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
 .
 8. U.S. GOVERNMENT END USERS.
 .
 The Covered Software is a “commercial item,” as that term is defined in 48 
 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as 
 that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial 
 computer software documentation” as such terms are used in 48 C.F.R. 12.212 
 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 
 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered 
 Software with only those rights set forth herein. This U.S. Government Rights 
 clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or 
 provision that addresses Government rights in computer software under this 
 License.
 .
 9. MISCELLANEOUS.
 .
 This License represents the complete agreement concerning subject matter 
 hereof. If any provision of this License is held to be unenforceable, such 
 provision shall be reformed only to the extent necessary to make it 
 enforceable. This License shall be governed by the law of the jurisdiction 
 specified in a notice contained within the Original Software (except to the 
 extent applicable law, if any, provides otherwise), excluding such 
 jurisdiction’s conflict-of-law provisions. Any litigation relating to this 
 License shall be subject to the jurisdiction of the courts located in the 
 jurisdiction and venue specified in a notice contained within the Original 
 Software, with the losing party responsible for costs, including, without 
 limitation, court costs and reasonable attorneys’ fees and expenses. The 
 application of the United Nations Convention on Contracts for the 
 International Sale of Goods is expressly excluded. Any law or regulation which 
 provides that the language of a contract shall be construed against the 
 drafter shall not apply to this License. You agree that You alone are 
 responsible for compliance with the United States export administration 
 regulations (and the export control laws and regulation of any other 
 countries) when You use, distribute or otherwise make available any Covered 
 Software.
 .
 10. RESPONSIBILITY FOR CLAIMS.
 .
 As between Initial Developer and the Contributors, each party is responsible 
 for claims and damages arising, directly or indirectly, out of its utilization 
 of rights under this License and You agree to work with Initial Developer and 
 Contributors to distribute such responsibility on an equitable basis. Nothing 
 herein is intended or shall be deemed to constitute any admission of liability.
EOF
		) >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.copyright"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
			printf "\tdebian/%s.install.in ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		printf "%s/@DEB_HOST_MULTIARCH@/%s/%s* %s/@DEB_HOST_MULTIARCH@/%s/\n" "${LIBSDIR}" "${PROGNAME}/${UPSTREAMVER}" "${JNISONAME}" "${LIBSDIR}" "${PROGNAME}/${UPSTREAMVER}" >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.install.in"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
			printf "\tdebian/%s.lintian-overrides.amd64 ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		(
		${CAT} << EOF
hardening-no-bindnow
hardening-no-fortify-functions
hardening-no-relro
no-upstream-changelog
package-has-unnecessary-activation-of-ldconfig-trigger
unused-shlib-entry-in-control-file
EOF
		) >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides.amd64"


		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
			printf "\tdebian/%s.lintian-overrides.i386 ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		(
		${CAT} << EOF
binary-file-built-without-LFS-support
hardening-no-bindnow
hardening-no-fortify-functions
hardening-no-relro
no-upstream-changelog
pkg-has-shlibs-control-file-but-no-actual-shared-libs
EOF
		) >"${DEBIAN_WORKDIR}/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides.i386"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	for Copyright in "${DEBIAN_WORKDIR}"/*.copyright ; do
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s ... " "$(${BASENAME} "${Copyright}")"
		fi

		if [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "Apache-2") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: Apache-2.0
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at
 .
      http://www.apache.org/licenses/LICENSE-2.0
 .
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 .
 On Debian systems, the full text of the Apache Software License version 2 can
 be found in the file \`/usr/share/common-licenses/Apache-2.0'.
EOF
			) >>"${Copyright}"
		fi

		if [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "GPL-3\+") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: GPL-3+
 This package 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 3 of the License, or (at your option) any later
 version.
 .
 This package 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
 version 3, can be found in \`/usr/share/common-licenses/GPL-3'.
EOF
			) >>"${Copyright}"
		fi

		if [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "GPL-2\+") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: GPL-2+
 This package 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 package 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
 version 2, can be found in \`/usr/share/common-licenses/GPL-2'.
EOF
			) >>"${Copyright}"
		elif [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "GPL-2 with Classpath exception") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: GPL-2 with Classpath exception
 This package 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; specifically version 2 of the License.
 .
 As a special exception, the copyright holders of this library give you
 permission to link this library with independent modules to produce an
 executable, regardless of the license terms of these independent modules, and
 to copy and distribute the resulting executable under terms of your choice,
 provided that you also meet, for each linked independent module, the terms
 and conditions of the license of that module. An independent module is a
 module which is not derived from or based on this library. If you modify this
 library, you may extend this exception to your version of the library, but
 you are not obligated to do so. If you do not wish to do so, delete this
 exception statement from your version.
 .
 This package 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
 version 2, can be found in \`/usr/share/common-licenses/GPL-2'.
EOF
			) >>"${Copyright}"
		elif [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "GPL-2") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: GPL-2
 This package 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; specifically version 2 of the License.
 .
 This package 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
 version 2, can be found in \`/usr/share/common-licenses/GPL-2'.
EOF
			) >>"${Copyright}"
		fi

		if [ $(${GREP} ${GREP_OPTS} "^License:" "${Copyright}" |${GREP} ${GREP_OPTS_COUNT} "BSD-3-clause") -gt 0 ] ; then
			(
			${CAT} <<EOF

License: BSD-3-clause
 All rights reserved.
 .
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:
 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
 3. Neither the name of the University nor the names of its contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.
 .
 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
EOF
			) >>"${Copyright}"
		fi

		if [ ${SILENT} -eq 0 ] ; then
			printf "updated!\n"
		fi
	done

	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdebian/%s.install ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
#!/usr/bin/dh-exec
debian/${PROGNAME}.${UPSTREAMVER}.bash => usr/bin/${PROGNAME}.${UPSTREAMVER}
debian/${PROGNAME}.${UPSTREAMVER}.desktop usr/share/applications
debian/${PROGNAME}.${UPSTREAMVER}.xpm usr/share/pixmaps
${INSTDIR}/* ${INSTDIR}
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.install" && ${CHMOD} ${CHMOD_OPTS_FUNC_DEB} "${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.install"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	if [ ${SDCLI} -ne 0 -o ${SQLCL} -ne 0 ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s.links ... " "${PROGNAME}-${UPSTREAMVER}"
		fi

		if [ ${SDCLI} -ne 0 ] ; then
			printf "%s %s\n" "${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/bin/sdcli" "${BINSDIR}/sdcli.${UPSTREAMVER}" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.links"
		fi

		if [ ${SQLCL} -ne 0 ] ; then
			printf "%s %s\n" "${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/bin/sql" "${BINSDIR}/sql.${UPSTREAMVER}.bundled" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.links"
		fi

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdebian/%s.lintian-overrides ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
codeless-jar
classpath-contains-relative-path
missing-manifest
no-upstream-changelog
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.lintian-overrides"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.manpages ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	printf "debian/${PROGNAME}.${UPSTREAMVER}.1\n" >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.manpages"

	if [ ${SDCLI} -ne 0 ] ; then
		printf "debian/sdcli.${UPSTREAMVER}.1\n" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.manpages"
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		printf "debian/sql.${UPSTREAMVER}.bundled.1\n" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.manpages"
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.NEWS ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
${PROGNAME}-${UPSTREAMVER} (${UPSTREAMVER}+${VERSION}-${LOCALVER}) unstable; urgency=low

    Multiple versions can coexist so "sqldeveloper.[upstream version]" will
    invoke a specific version of Oracle SQL Developer while "sqldeveloper"
    takes advantage of Debian's alternatives system and, when left in auto
    mode, will always invoke the highest version installed.
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.NEWS"

	if [ ${SDCLI} -ne 0 ] ; then
		(
		${CAT} <<EOF
    The same will apply to Oracle CLI for SQL Developer with
    "sdcli.[upstream version]" and "sdcli"
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.NEWS"
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		(
		${CAT} <<EOF
    Since version 4.2 Oracle started to bundle Oracle SQL Developer
    Command-Line (SQLcl) with Oracle SQL Developer. When available, and as an
    alternative to the standalone package (see "sqlcl-package"),
    "sql.[upstream version].bundled" will invoke a specific version of SQLcl
    while "sqlcl.bundled" takes advantage of Debian's alternatives system and,
    when left in auto mode, will always invoke the highest bundled version
    installed, and "sqlcl" will invoke the highest version installed (either
    standalone or bundled, in this order)
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.NEWS"
	fi

	printf "\n -- %s <%s>  %s\n" "${DEBFULLNAME}" "${DEBEMAIL}" "$(${DATE} ${DATE_OPTS_FUNC_DEB})" >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.NEWS"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.postinst ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
#!/bin/sh
set -e

MANSECTION=1
COMPRESS=".gz"
PROG_PRIO=50

PRIO=${POSTINST_PRIO}

INSTBINDIR="/${BINSDIR}"
INSTMANDIR="/${INSTDIR}/man/man\${MANSECTION}"

UPDALT="update-alternatives"

UPDALT_SLAVE="--slave"

RET=0

# Invoke update-alternatives --install on the package
#
func_updalt_install() {
	local RET=0
	local UPDALT_ACTION="--install"

	\${UPDALT} \\
		\${UPDALT_ACTION} \${INSTBINDIR}/${PROGNAME} ${PROGNAME} \${INSTBINDIR}/${PROGNAME}.${UPSTREAMVER} \${PRIO} \\
		\${UPDALT_SLAVE} \${INSTMANDIR}/${PROGNAME}.\${MANSECTION}\${COMPRESS} ${PROGNAME}.\${MANSECTION}\${COMPRESS} \${INSTMANDIR}/${PROGNAME}.${UPSTREAMVER}.\${MANSECTION}\${COMPRESS}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s postinst - unexpected return code \"%d\"\n" "${INVOCATION}" \${RET} >&2
		return \${RET}
	fi
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.postinst"

	if [ ${SDCLI} -ne 0 ] ; then
		(
		${CAT} <<EOF

	\${UPDALT} \\
		\${UPDALT_ACTION} \${INSTBINDIR}/sdcli sdcli \${INSTBINDIR}/sdcli.${UPSTREAMVER} \${PRIO} \\
		\${UPDALT_SLAVE} \${INSTMANDIR}/sdcli.\${MANSECTION}\${COMPRESS} sdcli.\${MANSECTION}\${COMPRESS} \${INSTMANDIR}/sdcli.${UPSTREAMVER}.\${MANSECTION}\${COMPRESS}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s postinst - unexpected return code \"%d\"\n" "${INVOCATION}" \${RET} >&2
		return \${RET}
	fi
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.postinst"
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		(
		${CAT} <<EOF

	\${UPDALT} \\
		\${UPDALT_ACTION} \${INSTBINDIR}/sql.${UPSTREAMVER} sql.${UPSTREAMVER} \${INSTBINDIR}/sql.${UPSTREAMVER}.bundled \${PRIO} \\
		\${UPDALT_SLAVE} \${INSTMANDIR}/sql.${UPSTREAMVER}.\${MANSECTION}\${COMPRESS} sql.${UPSTREAMVER}.\${MANSECTION}\${COMPRESS} \${INSTMANDIR}/sql.${UPSTREAMVER}.bundled.\${MANSECTION}\${COMPRESS}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s postinst - unexpected return code \"%d\"\n" "${INVOCATION}" \${RET} >&2
		return \${RET}
	fi

	\${UPDALT} \\
		\${UPDALT_ACTION} \${INSTBINDIR}/sqlcl.bundled sqlcl.bundled \${INSTBINDIR}/sql.${UPSTREAMVER}.bundled \${PRIO} \\
		\${UPDALT_SLAVE} \${INSTMANDIR}/sqlcl.bundled.\${MANSECTION}\${COMPRESS} sqlcl.bundled.\${MANSECTION}\${COMPRESS} \${INSTMANDIR}/sql.${UPSTREAMVER}.bundled.\${MANSECTION}\${COMPRESS}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s postinst - unexpected return code \"%d\"\n" "${INVOCATION}" \${RET} >&2
		return \${RET}
	fi

	if [ -f "\${INSTBINDIR}/sqlcl.bundled" ] ; then
		\${UPDALT} \\
			\${UPDALT_ACTION} \${INSTBINDIR}/sqlcl sqlcl \${INSTBINDIR}/sqlcl.bundled \${PROG_PRIO} \\
			\${UPDALT_SLAVE} \${INSTMANDIR}/sqlcl.\${MANSECTION}\${COMPRESS} sqlcl.\${MANSECTION}\${COMPRESS} \${INSTMANDIR}/sqlcl.bundled.\${MANSECTION}\${COMPRESS}

		RET=\${?}

		if [ \${RET} -ne 0 ] ; then
			printf "%s postinst - unexpected return code \"%d\"\n" "${INVOCATION}" \${RET} >&2
			return \${RET}
		fi
	fi
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.postinst"
	fi

	(
	${CAT} <<EOF

	return \${RET}
}

case "\${1}" in
	configure|abort-upgrade|abort-remove|abort-deconfigure)
		func_updalt_install
		RET=\${?}
	;;
	*)
		printf "%s postinst - called with an unknown parameter\"%s\"\n" "make-sqlcl-package" "\${1}" >&2
		RET=1
	;;
esac

exit \${RET}
EOF
	) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.postinst" && ${CHMOD} ${CHMOD_OPTS_FUNC_DEB} "${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.postinst"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.prerm ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
#!/bin/sh
set -e

INSTBINDIR="/usr/bin"

UPDALT="update-alternatives"

RET=0

# Invoke update-alternatives --remove on the package
#
func_updalt_remove() {
	local RET=0
	local UPDALT_ACTION="--remove"

	\${UPDALT} \\
		\${UPDALT_ACTION} ${PROGNAME} \${INSTBINDIR}/${PROGNAME}.${UPSTREAMVER}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s prerm - unexpected return code \"%d\"\n" "make-sqlcl-package" \${RET} >&2
		return \${RET}
	fi
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.prerm"

	if [ ${SDCLI} -ne 0 ] ; then
		(
		${CAT} <<EOF

	\${UPDALT} \\
		\${UPDALT_ACTION} sdcli \${INSTBINDIR}/sdcli.${UPSTREAMVER}

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s prerm - unexpected return code \"%d\"\n" "make-sqlcl-package" \${RET} >&2
		return \${RET}
	fi
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.prerm"
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		(
		${CAT} <<EOF

	\${UPDALT} \\
		\${UPDALT_ACTION} sql.${UPSTREAMVER} \${INSTBINDIR}/sql.${UPSTREAMVER}.bundled

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s prerm - unexpected return code \"%d\"\n" "make-sqlcl-package" \${RET} >&2
		return \${RET}
	fi

	\${UPDALT} \\
		\${UPDALT_ACTION} sqlcl.bundled \${INSTBINDIR}/sql.${UPSTREAMVER}.bundled

	RET=\${?}

	if [ \${RET} -ne 0 ] ; then
		printf "%s prerm - unexpected return code \"%d\"\n" "make-sqlcl-package" \${RET} >&2
		return \${RET}
	fi

	if ! [ -f "\${INSTBINDIR}/sqlcl.bundled" ] ; then
		\${UPDALT} \\
			\${UPDALT_ACTION} sqlcl \${INSTBINDIR}/sqlcl.bundled

		RET=\${?}

		if [ \${RET} -ne 0 ] ; then
			printf "%s prerm - unexpected return code \"%d\"\n" "make-sqlcl-package" \${RET} >&2
			return \${RET}
		fi
	fi
EOF
		) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.prerm"
	fi

	(
	${CAT} <<EOF

	return \${RET}
}

case "\${1}" in
	remove|upgrade|deconfigure|failed-upgrade)
		func_updalt_remove
		RET=\${?}
	;;
	*)
		printf "%s prerm - called with an unknown parameter\"%s\"\n" "make-sqlcl-package" "\${1}" >&2
		RET=1
	;;
esac

exit \${RET}
EOF
	) >>"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.prerm" && ${CHMOD} ${CHMOD_OPTS_FUNC_DEB} "${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.prerm"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.README.Debian ... " "${PROGNAME}-${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
${PROGNAME} for Debian
-----------------------

In order to run Oracle SQL Developer you'll need a full working JDK. The
versions that are compatible with SQL Developer are any JDK 1.5.0_06 or above
or JDK 1.6.0_03 or above for SQL Developer versions up to 1.5.5. SQL Developer
versions from 2.1 to 3.1 are compatible with JDK 1.6.0_11 or above and SQL
Developer version 3.2 is compatible with JDK 1.6.0_04 or above. SQL Developer
version 4.0 is compatible with JDK 1.7 (JDK7.0) series and SQL Developer
versions from 4.1 to 17.3 are compatible with JDK 1.8 (JDK8.0) series or
newer.

Note that Oracle SQL Developer prior to version 4.0 is not compatible with JDK
1.7 (JDK7.0) or newer and prior to version 4.1 is not compatible with.JDK 1.8
(JDK8.0) or newer.

There are several ways to obtain a compatible JDK:

- install default-jdk (java), making sure it depends on the required JDK
  version
- install one of the required openjdk-6-jdk, openjdk-7-jdk, openjdk-8-jdk or
  openjdk-9-jdk (java)
- install the meta-package java-sdk, making sure that it installs the required
  JDK version as dependency
- install one of the meta-packages java6-sdk, java7-sdk, java8-sdk or
  java9-sdk, making sure that it installs the required JDK version as
  dependency
- download and run the installer for the version you wish to install from
  Oracle <http://www.oracle.com/technetwork/java/javase/downloads/>
- install java-package (contrib/misc) and generate a Debian package from the
  above installer

After installing a compatible JDK simply launch SQL Developer through the
graphical interface or by invoking /usr/bin/${PROGNAME}/${UPSTREAMVER} and
supply the path where the JDK was installed when prompted.

 -- Lazarus Long <lazarus.long@sapo.pt>  $(${DATE} ${DATE_OPTS_FUNC_DEB})
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}-${UPSTREAMVER}.README.Debian"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.1 ... " "${PROGNAME}.${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
.\\" ${PROGNAME}.${UPSTREAMVER}.1
.\\"
.\\" (2018-01-11)
.\\"
.\\" Copyright © 2009-2018 Lazarus Long <lazarus (dot) long (at) sapo (dot) pt>
.\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"  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 3 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 program.  If not, see <http://www.gnu.org/licenses/>. .\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"
.\\" Debian package builder and installer for Oracle SQL Developer
.\\"
.\\"
.TH SQLDEVELOPER.${UPSTREAMVER} 1 2018-01-11 Oracle "Oracle SQL Developer"
.\\"
.SH NAME
${PROGNAME}.${UPSTREAMVER} \\- Oracle SQL Developer
.\\"
.SH SYNOPSIS
.B ${PROGNAME},${UPSTREAMVER}
.RI [options]\\  [[file]\\ \\...]
.PP
.B ${PROGNAME}
.RI [options]\\  [[file]\\ \\...]
.\\"
.SH DESCRIPTION
\\fB${PROGNAME}.${UPSTREAMVER}\\fP is a \\fIJava\\fP utility that allows one
to develop for and administer \\fIOracle\\fP databases.
.PP
The \\fIOracle SQL Developer\\fP program is governed by the copyright holder
(\\fIOracle USA, Inc.\\fP), it is your responsibility to use it accordingly to
the OTN license, a copy of which is included in "\\fI/usr/share/doc/sqldeveloper\\fP".
.\\"
.SH OPTIONS
.PP
.B The following commands must appear first:
.TP
\\fB\\-verbose\\fP
Show java command line options
.TP
\\fB\\-conf[igure]\\fP \\fI<fname>\\fP
Use the specified configuration file
.PP
.B The following commands must appear last:
.TP
\\fB\\-classic\\fP
Use Classic as the Java VM
.TP
\\fB\\-hotspot\\fP
Use Hotspot client as the Java VM
.TP
\\fB\\-server\\fP
Use Hotspot server as the Java VM
.TP
\\fB\\-client\\fP
Use Hotspot client as the Java VM
.TP
\\fB\\-\\-<directive>=\\fP\\fI<value>\\fP
Override a directive from the configuration file
.TP
\\fB\\-J\\fP\\fI<flag>\\fP
Pass <flag> directly to the runtime system
.TP
\\fB\\-migrate\\fP
Migrate user settings from a previous installation
.PP
.B The following commands must appear by themselves:
.TP
\\fB\\-help\\fP
Show the help screen
.TP
\\fB\\-version\\fP
Display SQL Developer version
.PP
.TP
\\fB[[file] ...]\\fP
One or more SQL files specified with their full pathname(s)
.\\"
.SH AUTHOR
\\fBOracle SQL Developer\\fP is copyright by \\fIOracle USA, Inc.\\fP
.PP
The \\fB${PROGNAME}.${UPSTREAMVER}\\fP wrapper for the Debian package was written by \\fILazarus
Long <lazarus.long@sapo.pt>\\fP.
.PP
This manual page was written by \\fILazarus Long <lazarus.long@sapo.pt>\\fP,
for the Debian project (but may be used by others).
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.1"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	if [ ${SDCLI} -ne 0 ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s.1 ... " "sdcli.${UPSTREAMVER}"
		fi

		(
		${CAT} <<EOF
.\\" sdcli.${UPSTREAMVER}.1
.\\"
.\\" (2018-01-11)
.\\"
.\\" Copyright © 2017-2018 Lazarus Long <lazarus (dot) long (at) sapo (dot) pt>
.\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"  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 3 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 program.  If not, see <http://www.gnu.org/licenses/>. .\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"
.\\" Debian package builder and installer for Oracle SQL Developer
.\\"
.\\"
.TH SDCLI.${UPSTREAMVER} 1 2018-01-11 Oracle "Oracle CLI for SQL Developer"
.\\"
.SH NAME
sdcli.${UPSTREAMVER} \\- Oracle CLI for SQL Developer
.\\"
.SH SYNOPSIS
.B sdcli.${UPSTREAMVER}
.RI [options]\\ <feature>\\ [<command>]\\ [[\\-h|\\-help]|argument\\ \\...]
.\\"
.SH DESCRIPTION
\\fB${PROGNAME}\\fP is a \\fIJava\\fP utility that allows one to develop for
and administer \\fIOracle\\fP databases.
.PP
\\fBsdcli\\fP is a command line utility that exposes several internal\\fIOracle
SQL Developer\\fP commands , to interact either with a new or already existing
\\fI Oracle SQl Developer\\fP instance, for example, on headless systems of for
scripting purposes.
.PP
The \\fIOracle SQL Developer\\fP program is governed by the copyright holder
(\\fIOracle USA, Inc.\\fP), it is your responsibility to use it accordingly to
the OTN license, a copy of which is included in "\\fI/usr/share/doc/sqldeveloper\\fP".
.\\"
.SH OPTIONS
.PP
.B The following options must appear first:
.TP
\\fB\\-verbose\\fP
Show java command line options
.TP
\\fB\\-conf[igure]\\fP \\fI<fname>\\fP
Use the specified configuration file
.PP
.B The following options must appear last:
.TP
\\fB\\-classic\\fP
Use Classic as the Java VM
.TP
\\fB\\-hotspot\\fP
Use Hotspot client as the Java VM
.TP
\\fB\\-server\\fP
Use Hotspot server as the Java VM
.TP
\\fB\\-client\\fP
Use Hotspot client as the Java VM
.TP
\\fB\\-\\-<directive>=\\fP\\fI<value>\\fP
Override a directive from the configuration file
.TP
\\fB\\-J\\fP\\fI<flag>\\fP
Pass <flag> directly to the runtime system
.TP
\\fB\\-migrate\\fP
Migrate user settings from a previous installation
.PP
.B The following features are available:
.TP
\\fBcart\\fP
Database cart batch tasks
.TP
\\fBdba\\fP
Basic batch DBA tasks
.TP
\\fBformat\\fP
Format Task
.TP
\\fBmigration\\fP
Database migration tasks
.TP
\\fBreports\\fP
Basic batch reporting tasks
.TP
\\fBunittest\\fP
Unit testing batch tasks
.TP
\\fButility\\fP
Utility import task
.PP
Feature \\fBCART\\fP usage:
.PP
\\fBcart\\fP \\fI<command>\\fP \\fB-h\\fP|\\fB-help\\fP
.PP
\\fBcart\\fP \\fI<command>\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fBexport\\fP | \\fBcloud\\fP | \\fBcopy\\fP
.PP
Feature \\fBDBA\\fP usage:
.PP
\\fBdba\\fP \\fI<command>\\fP \\fB-h\\fP|\\fB-help\\fP
.PP
\\fBdba\\fP \\fI<command>\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fBdbcopy\\fP
.PP
Feature \\fBFORMAT\\fP usage:
.PP
\\fBformat\\fP
.PP
Feature \\fBMIGRATION\\fP usage:
.PP
\\fBmigration\\fP \\fB-h\\fP|\\fB-help\\fP=\\fI<command> [,<command> ...]\\fP
.PP
\\fBmigration\\fP \\fB-actions=\\fP\\fI<command> [,<command> ...]\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fBcapture\\fP | \\fBconvert\\fP | \\fBdatamove\\fP | \\fBdelcaptured\\fP | \\fBdelconn\\fP | \\fBdelconverted\\fP | \\fBdriver\\fP | \\fBgenerate\\fP | \\fBguide\\fP | \\fBidmap\\fP | \\fBinfo\\fP | \\fBinit\\fP | \\fBlscaptured\\fP | \\fBlsconn\\fP | \\fBlsconverted\\fP | \\fBmkconn\\fP | \\fBqm\\fP | \\fBrunsql\\fP | \\fBscan\\fP | \\fBtranslate\\fP
.PP
Feature \\fBREPORTS\\fP usage:
.PP
\\fBcart\\fP \\fI<command>\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fBgenerate\\fP
.PP
Feature \\fBUNITTEST\\fP usage:
.PP
\\fBunittest\\fP \\fI?\\fP | [\\fI<command>\\fP \\fB?\\fP]
.PP
\\fBunittest\\fP \\fI<command>\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fB-run\\fP | \\fB-exp\\fP | \\fB-imp\\fP
.PP
Feature \\fBUTILITY\\fP usage:
.PP
\\fBcart\\fP \\fI<command>\\fP \\fB-h\\fP|\\fB-help\\fP
.PP
\\fBcart\\fP \\fI<command>\\fP \\fI<arguments>\\fP
.PP
Supported commands: \\fBimport\\fP
.\\"
.SH AUTHOR
\\fBOracle SQL Developer\\fP is copyright by \\fIOracle USA, Inc.\\fP
.PP
This manual page was written by \\fILazarus Long <lazarus.long@sapo.pt>\\fP,
for the Debian project (but may be used by others).
EOF
		) >"${DEBIAN_WORKDIR}/sdcli.${UPSTREAMVER}.1"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	if [ ${SQLCL} -ne 0 ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "\tdebian/%s.1 ... " "sql.${UPSTREAMVER}.bundled"
		fi

		(
		${CAT} <<EOF
.\\" sql.${UPSTREAMVER}.bundled.1
.\\"
.\\" (2018-01-11)
.\\"
.\\" Copyright © 2017-2018 Lazarus Long <lazarus (dot) long (at) sapo (dot) pt>
.\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"  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 3 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 program.  If not, see <http://www.gnu.org/licenses/>. .\\"
.\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\".\\"
.\\"
.\\" Debian package builder and installer for Oracle SQL Developer Command-Line
.\\"
.\\"
.TH SQL.${UPSTREAMVER}.BUNDLED 1 2018-01-11 Oracle "Oracle SQL Developer Command-Line"
.\\"
.SH NAME
sql.${UPSTREAMVER}.bundled \\- Oracle SQL Developer Command-Line
.\\"
.SH SYNOPSIS
.PP
\\fIUsage 1:\\fP
.PP
.B sql.${UPSTREAMVER}.bundled
.RI -H\\  |\\  -V
.PP
.B sqlcl
.RI -H\\  |\\  -V
.PP
\\fIUsage 2:\\fP
.PP
.B sql.${UPSTREAMVER}.bundled
.RI [\\fB<option>\\fP] \\  [{\\fB<logon>\\fP\\  |\\  /nolog}]\\  [\\fB<start>\\fP]
.PP
.B sqlcl
.RI [\\fB<option>\\fP] \\  [{\\fB<logon>\\fP\\  |\\  /nolog}]\\  [\\fB<start>\\fP]
.\\"
.SH DESCRIPTION
\\fBsql.${UPSTREAMVER}.bundled\\fP is a \\fIJava\\fP utility that allows one to develop
for and administer \\fIOracle\\fP databases.
.PP
\\fIOracle SQL Developer Command-Line\\fP (\\fISQLcl\\fP) is a free command
line interface for \\fIOracle Database\\fP. It allows you to interactively or
batch execute \\fISQL\\fP and \\fIPL/SQL\\fP. \\fISQLcl\\fP provides in-line
editing, statement completion, and command recall for a feature-rich
experience, all while also supporting your previously written \\fISQL*Plus\\fP
scripts.
.PP
The \\fIOracle SQL Developer Command-Line \\fP program is governed by the
copyright holder (\\fIOracle USA, Inc.\\fP), it is your responsibility to use
it accordingly to the \\fI\\fBOTN\\fP license\\fP, a copy of which is included
in "\\fI/usr/share/doc/${PROGNAME}-${UPSTREAMVER}\\fP".
.\\"
.SH OPTIONS
.TP
\\fB\\-H\\fP
Displays the SQLcl version and the usage help.
.TP
\\fB\\-V\\fP
Displays the SQLcl version.
.PP
\\fB<option>\\fP is:
.RI [-R\\  <level>]\\  [-S]\\  [-verbose]\\  [-oci]\\  [-L[OGON]]a
.TP
\\fB\\-R\\fP \\fI<level>\\fP
Sets restricted mode to disable \\fISQLcl\\fP commands that interact with the
file system. The level can be \\fB1\\fP, \\fB2\\fP, \\fB3\\fP or \\fB4\\fP. The
most restrictive is -R 4 which disables all user commands interacting with the
file system.
.TP
\\fB-S\\fP
Sets silent mode which suppresses the display of the \\fISQLcl\\fP banner,
prompts, and echoing of commands.
.TP
\\fB-verbose\\fP
Set this to show logging messages inline. By default these messages are
suppressed.
.TP
\\fB-nohistory\\fP
Switch off history logging.
.TP
\\fB-noupdates\\fP
Do not check update site for newer versions available.
.TP
\\fB-oci\\fP
Set this to use an \\fIOracle Instant Client\\fP installation. If this option
is set, then \\fISQLcl\\fP will use the drivers from the first Installation on
the path.
.TP
\\fB-L\\fP[OGON]
Specifies not to reprompt for username or password if the initial connection
does not succeed.
.PP
\\fB<logon>\\fP is:
.RI {<username>[/<password>][@<connect_identifier>]\\  |\\  /}\\  [AS\\  
{SYSDBA\\  |\\  SYSOPER\\  |\\  SYSASM}]
.PP
Specifies the database account \\fBusername\\fP, \\fBpassword\\fP and
\\fBconnect identifier\\fP for the database connection. Without a connect
identifier, \\fISQLcl\\fP connects to the default database.
.PP
The \\fBAS SYSDBA\\fP, \\fBAS SYSOPER\\fP and \\fBAS SYSASM\\fP options are
database administration privileges.
.PP
\\fB<connect_identifier>\\fP can be in the form of \\fINet Service Name\\fP or
\\fIEasy Connect\\fP.
.PP
\\fB@\\fP[\\fB<net_service_name>\\fP\\ |\\ [//]\\fBHost\\fP[\\fB:Port\\fP]/\\fB<service_name>\\fP]
.PP
\\fI<net_service_name>\\fP is a simple name for a service that resolves to a
connect descriptor.
.PP
\\fBExample\\fP: Connect to database using \\fINet Service Name\\fP and the
database net service name is \\fBORCL\\fP.
.PP
\\fBsql.${UPSTREAMVER}.bundled\\fP myusername/mypassword@ORCL
.PP
\\fIHost\\fP specifies the host name or IP address of the database server
computer.
.PP
\\fIPort\\fP specifies the listening port on the database server.
.PP
\\fI<service_name>\\fP specifies the service name of the database you want to
access.
.PP
\\fBExample\\fP: Connect to database using \\fIEasy Connect\\fP and the Service
name is \\fBORCL\\fP.
.PP
\\fBsql.${UPSTREAMVER}.bundled\\fP myusername/mypassword@Host/ORCL
.PP
The \\fB/NOLOG\\fP option starts \\fISQLcl\\fP without connecting to a database.
.PP
\\fB<start>\\fP is:
.RI @<URL>\\ |\\ <filename>[.<ext>]\\  [<parameter>\\  \\...]
.PP
Runs the specified \\fISQLc\\fPl script from a web server (\\fBURL\\fP) or the
local file system (\\fBfilename.ext\\fP) with specified parameters that will be
assigned to substitution variables in the script.
.PP
When \\fISQLcl\\fP starts, and after \\fBCONNECT\\fP commands, the site profile
(e.g. \\fI\$ORACLE_HOME/sqlplus/admin/glogin.sql\\fP) and the user profile (e.g.
\\fIlogin.sql\\fP in the working directory) are run. The files may contain
\\fISQLcl\\fP commands.
.PP
Refer to the \\fISQLDeveloper User's Guide and Reference\\fP for more information.
.\\"
.SH AUTHOR
\\fBOracle SQL Developer Command-Line\\fP is copyright by \\fIOracle USA, Inc.\\fP
.PP
This manual page was written by \\fILazarus Long <lazarus.long@sapo.pt>\\fP,
for the Debian project (but may be used by others).
EOF
		) >"${DEBIAN_WORKDIR}/sql.${UPSTREAMVER}.bundled.1"

		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "\tdebian/%s.bash ... " "${PROGNAME}.${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
#!/bin/sh
set -e

# ${PROGNAME}.${UPSTREAMVER}

# (2018-01-11)

##########################################################################
#  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 3 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 program.  If not, see <http://www.gnu.org/licenses/>. #
##########################################################################

# Launcher for Oracle SQL Developer

# Copyright: © 2009-2018 Lazarus Long <lazarus (dot) long (at) sapo (dot) pt>

PATH="/usr/bin:/bin:/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}:/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/${PROGNAME}/bin:/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/jdev/bin"

BASENAME="basename"
CAT="cat"
CUT="cut"
GREP="grep"
MKDIR="mkdir"
RM="rm"
SED="sed"
TR="tr"
XTERM="x-terminal-emulator"

GREP_OPTS="-E"
MKDIR_OPTS="-p"
RM_OPTS="-f"
TR_OPTS="[[:upper:]] [[:lower:]]"
XTERM_OPTS="-e"

INVOCATION="\$(\${BASENAME} "\${0}")"
SQLDEVHOME="\${HOME}/.${PROGNAME}"
SQLDEVDIR="/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}"
SQLDEVELOPER="\${SQLDEVDIR}/${PROGNAME}.sh"

func_version() {
	CUT_OPTS_FUNC_VER="-d = -f 2"

	VERSIONFILE="\${SQLDEVDIR}/${PROGNAME}/bin/version.properties"
	VERSION="0.0.0"

	if [ -e "\${VERSIONFILE}" ] ; then
		VERSION="\$(\${GREP} \${GREP_OPTS} "VER_FULL" "\${VERSIONFILE}" |\${CUT} \${CUT_OPTS_FUNC_VER})"
	else
		VERSIONFILE="\${SQLDEVDIR}/jdev/bin/version.properties"

		if [ -e "\${VERSIONFILE}" ] ; then
			VERSION="\$(\${GREP} \${GREP_OPTS} "VER_FULL" "\${VERSIONFILE}" |\${CUT} \${CUT_OPTS_FUNC_VER})"
		else
			printf "\${INVOCATION} - func_version(): File \\"%s\\" not found, returning...\\n" "\${VERSIONFILE}" >&2
			return 1
		fi
	fi

	VERSIONMAJ="\${VERSION%%.*}"
	VERSIONMIN="\${VERSION#*.}"
	VERSIONREV="\${VERSIONMIN#*.}"
	VERSIONMIN="\${VERSIONMIN%%.*}"
	VERSIONREV="\${VERSIONREV%%.*}"
}

func_setenv() {
	local WORKPATH="\${HOME}/.instantclient:\${HOME}/.sqldeveloper:/etc/instantclient:"
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.bash"

	if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 -a ${LIBJNIDISPATCH} -eq 1 ] ; then
		local ARCH=${HOSTARCH}

		if [ ${HOSTARCH} = "amd64" ] ; then
			ARCH="x86_64"
		fi

		printf "\tLD_LIBRARY_PATH=\"${LIBSDIR}/${ARCH}-linux-gnu/${PROGNAME}/${UPSTREAMVER}:\${LD_LIBRARY_PATH%%:}:\"\n" >>"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.bash"
	else
		printf "\tLD_LIBRARY_PATH=\${LD_LIBRARY_PATH%%:}:\"\n" >>"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.bash"
	fi

	(
	${CAT} <<EOF
	ORACLE_PATH="\${WORKPATH}\${ORACLE_PATH%:}:"
	SQLPATH="\${WORKPATH}\${SQLPATH%:}:"

	export LD_LIBRARY_PATH ORACLE_PATH SQLPATH
	
	[ \${#ORACLE_HOME} -gt 0 ] && export ORACLE_HOME

	[ \${#TNS_ADMIN} -gt 0 ] && export TNS_ADMIN

	return 0
}

func_checkjdkpath() {
		CUT_OPTS_FUNC_CHKJDK="-f 2-"
		SED_OPTS_FUNC_CHKJDK="-i -e"

	if [ \${VERSIONMAJ} -lt 4 ] ; then
		JDKPATH="\${SQLDEVHOME}/jdk"
	else
		if [ \${VERSIONMAJ} -eq 17  -a \${VERSIONMIN} -lt 3 ] ; then
			JDKPATH="\${SQLDEVHOME}/4.2.0/product.conf"
		else
			JDKPATH="\${SQLDEVHOME}/\${VERSIONMAJ}.\${VERSIONMIN}.\${VERSIONREV}/product.conf"
		fi
	fi

	if ! [ -f "\${JDKPATH}" ] ; then
		\${MKDIR} \${MKDIR_OPTS} "\${SQLDEVHOME}"
		RUN="\${XTERM} \${XTERM_OPTS} \${SQLDEVELOPER}"
	else
		if [ \${VERSIONMAJ} -lt 4 ]  ; then 
			if ! [ -x "\$(\${CAT} \${JDKPATH})/bin/javac" ] ; then
				\${RM} \${RM_OPTS} "\${JDKPATH}"
				RUN="\${XTERM} \${XTERM_OPTS} \${SQLDEVELOPER}"
			else
				RUN="\${SQLDEVELOPER}"
			fi
		else
			if ! [ -x "\$(\${GREP} \${GREP_OPTS} "^SetJavaHome" \${JDKPATH} |\${CUT} \${CUT_OPTS_FUNC_CHKJDK} -d\\  )/bin/javac" ] ; then
				\${SED} \${SED_OPTS_FUNC_CHKJDK} 's/^SetJavaHome.*$//g' "\${JDKPATH}"
				RUN="\${XTERM} \${XTERM_OPTS} \${SQLDEVELOPER}"
			else
				RUN="\${SQLDEVELOPER}"
			fi
		fi
	fi
}

func_help() {
	\${@}
	printf "%b\\n" "The following commands must appear by themselves:\\n-help                  Show this screen\\n-version               Display SQL Developer version"
}

func_parseopts() {
	while [ \${#} -gt 0 ] ; do
		case "\$(printf "%s" \${1} |\${TR} \${TR_OPTS})" in
			-help|--help)
				func_help \${RUN} \${1}
				exit 0
			;;
			-version|--version)
				printf "\\nOracle SQL Developer: Release %s\\n" "\${VERSION}"
				exit 0
			;;
		esac

		shift
	done
}

func_main() {
	func_version
	func_setenv
	func_checkjdkpath
	func_parseopts "\${@}"
	\${RUN} "\${@}"
}

func_main "\${@}"

# EOF sqldeveloper
EOF
	) >>"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.bash" && ${CHMOD} ${CHMOD_OPTS_FUNC_DEB} "${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.bash"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.desktop ... " "${PROGNAME}.${UPSTREAMVER}"
	fi

	(
	${CAT} <<EOF
[Desktop Entry]
Version=1.0
Name=SQL Developer (${UPSTREAMVER})
Exec=/usr/bin/${PROGNAME}.${UPSTREAMVER}
Icon=/usr/share/pixmaps/${PROGNAME}.${UPSTREAMVER}.xpm
Type=Application
Comment=Oracle SQL Developer (${UPSTREAMVER})
X-KDE-StartupNotify=true
Terminal=false
Categories=Database;Office;Development;KDE;Qt
Keywords=Oracle,SQL,Development,DBA,Editor
EOF
	) >"${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.desktop"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
		printf "\tdebian/%s.xpm ... " "${PROGNAME}.${UPSTREAMVER}"
	fi

	${CONVERT} ${CONVERT_OPTS} "${1}/${INSTDIR}/${PROGNAME}/${UPSTREAMVER}/icon.png" "${DEBIAN_WORKDIR}/${PROGNAME}.${UPSTREAMVER}.xpm"

	if [ ${SILENT} -eq 0 ] ; then
		printf "done!\n"
	fi

	return 0
}

# Generate the Debian package
#
func_builddeb() {
	if [ ${#} -ne 1 ] ; then
		printf "Usage: func_builddeb() <directory>\n"
		return 1
	fi

	if [ ${NOBUILD} -ne 0 ] ; then
		return 0
	fi

	if [ ${SILENT} -eq 0 ] ; then
		printf "Building debian package(s) from %s v%s in \"%s\":\n" "${PROGNAME}" "${UPSTREAMVER}" "${CURDIR}"
	fi

	if ! [ -d "${1}/debian" ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "func_builddeb(): Directory \"%s/debian\" not found, aborting...\n" "${1}" >&2
		else
			printf "%s - func_builddeb(): Directory \"%s/debian\" not found, aborting...\n" "${INVOCATION}" "${1}" >&2
		fi

		exit 1
	fi

	local DEBUILD_OPTS="--no-lintian --no-tgz-check"

	if [ -n "${ROOTCMD}" ] ; then
		DEBUILD_OPTS="--rootcmd=${ROOTCMD} ${DEBUILD_OPTS}"
	fi

	local DEBUILD_OPTS_INDEP="${DEBUILD_OPTS} -- binary-indep"
	cd "${WORKDIR}"

	if [ ${SILENT} -eq 0 ] ; then
		printf "\t%s ... " "${PROGNAME}-${UPSTREAMVER}_${UPSTREAMVER}+${VERSION}-${LOCALVER}_all.deb"
	fi

	${DEBUILD} ${DEBUILD_OPTS_INDEP} >/dev/null 2>&1
	local RET=${?}

	if [ ${RET} -eq 0 ] ; then
		if [ ${SILENT} -eq 0 ] ; then
			printf "done!\n"
		fi
	else
		if [ ${SILENT} -eq 0 ] ; then
			printf "FAILED!\n"
		fi

		exit ${RET}
	fi

	if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 -a ${LIBJNIDISPATCH} -eq 1 ] ; then
		if [ "${HOSTARCH}" = "amd64" -o "${HOSTARCH}" = "i386" ] ; then
			if [ ${SILENT} -eq 0 ] ; then
				printf "\t%s ... " "${JNILIBNAME}-${UPSTREAMVER}_${JNISOVERSION}+${VERSION}-${LOCALVER}_${HOSTARCH}.deb"
			fi

			local DEBUILD_OPTS_HOSTARCH="${DEBUILD_OPTS} -- clean,binary-arch"
			local CP_OPTS_FUNC_BUILD="-a"
			local RM_OPTS_FUNC_BUILD="-rf"

			if [ -f "${1}/debian/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides.${HOSTARCH}" ] ; then
				${CP} ${CP_OPTS_FUNC_BUILD} "${1}/debian/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides.${HOSTARCH}" "${1}/debian/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides"
			fi

			${DEBUILD} ${DEBUILD_OPTS_HOSTARCH} >/dev/null 2>&1
			RET=${?}

			if [ ${RET} -eq 0 ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "done!\n"
				fi
			else
				if [ ${SILENT} -eq 0 ] ; then
					printf "FAILED!\n"
				fi

				exit ${RET}
			fi

			if [ -f "${1}/debian/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides" ] ; then
				${RM} ${RM_OPTS_FUNC_BUILD} "${1}/debian/${JNILIBNAME}-${UPSTREAMVER}.lintian-overrides"
			fi
		fi
	fi

	cd "${CURDIR}"

	if [ ${INSTALL} -eq 1 ] ; then
		local DPKG_OPTS_FUNC_BUILD="-i"

		if [ ${SILENT} -eq 0 ] ; then
			printf "Installing generated package(s):\n\t%s\n" "${PROGNAME}-${UPSTREAMVER}_${UPSTREAMVER}-${LOCALVER}_all.deb"
		fi

		${DPKG} ${DPKG_OPTS_FUNC_BUILD} "${CURDIR}/${PROGNAME-${UPSTREAMVER}}_${UPSTREAMVER}+${VERSION}-${LOCALVER}_all.deb"

		if [ ${SKIPLIB} -eq 0 -a ${CSVLIBS} -eq 1 -a ${LIBJNIDISPATCH} -eq 1 ] ; then
			if [ -f "${JNILIBNAME}-${UPSTREAMVER}_${JNISOVERSION}+${VERSION}-${LOCALVER}_${HOSTARCH}.deb" ] ; then
				if [ ${SILENT} -eq 0 ] ; then
					printf "\t%s\n" "${JNILIBNAME}-${UPSTREAMVER}_${JNISOVERSION}+${VERSION}-${LOCALVER}_${HOSTARCH}.deb"
				fi

				${DPKG} ${DPKG_OPTS_FUNC_BUILD} "${CURDIR}/${JNILIBNAME}-${UPSTREAMVER}_${JNISOVERSION}+${VERSION}-${LOCALVER}_${HOSTARCH}.deb"
			fi
		fi
	fi

	return 0
}

# Run the script
#
func_run() {
	func_trap
	func_opts "${@}"
	func_header
	func_flags
	func_workdir
	func_extract "${ARCHIVE}" "${WORKDIR}/${INSTDIR}"
	func_upstreamversion "${WORKDIR}"
	func_reorganize "${WORKDIR}"
	func_cleanup "${WORKDIR}"
	func_debianize "${WORKDIR}"
	func_builddeb "${WORKDIR}"

	return 0
}

func_run "${@}"

# EOF make-sqldeveloper-package
