--- installer.sh.orig	2017-06-29 02:51:56.000000000 -0500
+++ installer.sh	2017-06-29 05:57:37.000000000 -0500
@@ -149,17 +149,17 @@
 				exit 1
 				;;
 			*)
-				test "${PREFIX}" = "/" && PREFIX=""
+				test "${DESTDIR}${PREFIX}" = "/" && PREFIX=""
 
-				if [ "${RKHINST_ACTION}" = "install" ]; then
-					RKHTMPVAR=`echo "${PATH}" | grep "${PREFIX}/bin"`
-
-					if [ -z "${RKHTMPVAR}" ]; then
-						echo ""
-						echo "Note: Directory ${PREFIX}/bin is not in your PATH"
-						echo ""
-					fi
-				fi
+# 				if [ "${RKHINST_ACTION}" = "install" ]; then
+# 					RKHTMPVAR=`echo "${PATH}" | grep "${DESTDIR}${PREFIX}/bin"`
+# 
+# 					if [ -z "${RKHTMPVAR}" ]; then
+# 						echo ""
+# 						echo "Note: Directory ${DESTDIR}${PREFIX}/bin is not in your PATH"
+# 						echo ""
+# 					fi
+# 				fi
 				;;
 			esac
 			;;
@@ -236,7 +236,7 @@
 
 		case "$1" in
 		/usr/local|custom_*)
-			SYSCONFIGDIR="${PREFIX}/etc"
+			SYSCONFIGDIR="${PREFIX}/etc/rkhunter"
 			;;
 		RPM)
 			if [ $RPM_USING_ROOT -eq 1 ]; then
@@ -280,11 +280,7 @@
 			fi
 
 			if [ -z "${LIBDIR}" ]; then
-				if [ "${UNAMEM}" = "x86_64" -o "${UNAMEM}" = "ppc64" ]; then
-					LIBDIR="${PREFIX}/lib64"
-				else
-					LIBDIR="${PREFIX}/lib"
-				fi
+				LIBDIR="${PREFIX}/lib"
 			fi
 
 			BINDIR="${PREFIX}/bin"
@@ -364,11 +360,7 @@
 			SHAREDIR="${PREFIX}/share"
 			;;
 		*)
-			if [ -d "${PREFIX}/lib64" ]; then
-				LIBDIR="${PREFIX}/lib64"
-			else
-				LIBDIR="${PREFIX}/lib"
-			fi
+			LIBDIR="${PREFIX}/lib"
 
 			BINDIR="${PREFIX}/bin"
 			VARDIR="/var"
@@ -412,8 +404,8 @@
 		RKHINST_MAN_DIR="${PREFIX}/man/man8"
 	else
 		RKHINST_DB_DIR="${VARDIR}/lib/${APPNAME}/db"
-		RKHINST_TMP_DIR="${VARDIR}/lib/${APPNAME}/tmp"
-		RKHINST_DOC_DIR="${SHAREDIR}/doc/${APPNAME}-${APPVERSION}"
+		RKHINST_TMP_DIR="/private/tmp"
+		RKHINST_DOC_DIR="${SHAREDIR}/${APPNAME}-${APPVERSION}"
 	fi
 
 	RKHINST_LANG_DIR="${RKHINST_DB_DIR}/i18n"
@@ -637,14 +629,14 @@
 		;;
 	*) 
 		# Check PREFIX
-		if [ -z "${PREFIX}" ]; then
+		if [ -z "${DESTDIR}${PREFIX}" ]; then
 			:
-		elif [ -d "${PREFIX}" ]; then
-			if [ -w "${PREFIX}" ]; then
-				echo " Checking installation directory \"$PREFIX\": it exists and is writable."
+		elif [ -d "${DESTDIR}${PREFIX}" ]; then
+			if [ -w "${DESTDIR}${PREFIX}" ]; then
+				echo " Checking installation directory \"${DESTDIR}$PREFIX\": it exists and is writable."
 
 				# That's enough for a standalone installation.
-				if [ "${PREFIX}" = "." ]; then
+				if [ "${DESTDIR}${PREFIX}" = "." ]; then
 					chown -R ${RKHINST_OWNER} ./files 
 
 					for DIR in `find ./files -type d -name CVS`; do
@@ -670,7 +662,7 @@
 
 					PREFIX="${PWD}"
 
-					echo "LOGFILE=${PREFIX}/rkhunter.log" >>rkhunter.conf 
+					echo "LOGFILE=${PREFIX}/var/log/rkhunter/rkhunter.log" >>rkhunter.conf 
 					echo "TMPDIR=$PREFIX" >>rkhunter.conf 
 					echo "DBDIR=$PREFIX" >>rkhunter.conf 
 					echo "SCRIPTDIR=$PREFIX" >>rkhunter.conf 
@@ -693,7 +685,7 @@
 				echo " Checking installation directory \"$PREFIX\": it exists, but it is not writable. Exiting."
 				exit 1
 			fi
-		elif [ -e "${PREFIX}" ]; then
+		elif [ -e "${DESTDIR}${PREFIX}" ]; then
 			echo " Checking installation directory \"$PREFIX\": it is not a directory. Exiting."
 			exit 1
 		else
@@ -714,21 +706,21 @@
 
 	umask 022
 	for DIR in ${RKHDIR_LIST}; do
-		if [ -d "${DIR}" ]; then
-			if [ -w "${DIR}" ]; then
-				echo "  Directory ${DIR}: exists and is writable."
+		if [ -d "${DESTDIR}${DIR}" ]; then
+			if [ -w "${DESTDIR}${DIR}" ]; then
+				echo "  Directory ${DESTDIR}${DIR}: exists and is writable."
 			else
-				echo "  Directory ${DIR}: exists, but it is not writable. Exiting."
+				echo "  Directory ${DESTDIR}${DIR}: exists, but it is not writable. Exiting."
 				exit 1
 			fi
 		else
-			mkdir -p ${DIR} >/dev/null 2>&1
+			mkdir -p ${DESTDIR}${DIR} >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
-				echo "  Directory ${DIR}: creating: OK"
+				echo "  Directory ${DESTDIR}${DIR}: creating: OK"
 			else
-				echo "  Directory ${DIR}: creating: FAILED: Code $ERRCODE"
+				echo "  Directory ${DESTDIR}${DIR}: creating: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 		fi
@@ -736,28 +728,28 @@
 
 	umask 077
 	for DIR in ${RKHINST_DIRS_EXCEP}; do
-		if [ -d "${DIR}" ]; then
-			if [ -w "${DIR}" ]; then
-				echo "  Directory ${DIR}: exists and is writable."
+		if [ -d "${DESTDIR}${DIR}" ]; then
+			if [ -w "${DESTDIR}${DIR}" ]; then
+				echo "  Directory ${DESTDIR}${DIR}: exists and is writable."
 			else
-				echo "  Directory ${DIR}: exists, but it is not writable. Exiting."
+				echo "  Directory ${DESTDIR}${DIR}: exists, but it is not writable. Exiting."
 				exit 1
 			fi
 		else
-			mkdir -p ${DIR} >/dev/null 2>&1
+			mkdir -p ${DESTDIR}${DIR} >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
-				echo "  Directory ${DIR}: creating: OK"
+				echo "  Directory ${DESTDIR}${DIR}: creating: OK"
 			else
-				echo "  Directory ${DIR}: creating: FAILED: Code $ERRCODE"
+				echo "  Directory ${DESTDIR}${DIR}: creating: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 		fi
 
-		case "${DIR}" in
+		case "${DESTDIR}${DIR}" in
 		*/${APPNAME}|*/${APPNAME}/*|*/${APPNAME}-${APPVERSION}) 
-			chmod "${RKHINST_MODE_EX}" "${DIR}"
+			chmod "${RKHINST_MODE_EX}" "${DESTDIR}${DIR}"
 			;;
 		esac
 	done
@@ -772,20 +764,20 @@
 	for FILE in ${RKHINST_SCRIPT_FILES} ${RKHINST_DB_FILES} ${RKHINST_MAN_FILES}; do
 		case "${FILE}" in
 		*.pl|*.sh)
-			cp -f ./files/"${FILE}" "${RKHINST_SCRIPT_DIR}" >/dev/null 2>&1
+			cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_SCRIPT_DIR}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_EX}" "${RKHINST_SCRIPT_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_SCRIPT_DIR}/${FILE}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 			;;
 		*.dat)
-			if [ "${FILE}" = "mirrors.dat" -a -f "${RKHINST_DB_DIR}/mirrors.dat" ]; then
-				RKHTMPVAR=`egrep '^(local|remote)=' ${RKHINST_DB_DIR}/mirrors.dat 2>/dev/null`
+			if [ "${FILE}" = "mirrors.dat" -a -f "${DESTDIR}${RKHINST_DB_DIR}/mirrors.dat" ]; then
+				RKHTMPVAR=`egrep '^(local|remote)=' ${DESTDIR}${RKHINST_DB_DIR}/mirrors.dat 2>/dev/null`
 
 				if [ -n "${RKHTMPVAR}" ]; then
 					echo " Installing ${FILE}: Locally modified - not overwritten"
@@ -793,24 +785,24 @@
 				fi
 			fi
 
-			cp -f ./files/"${FILE}" "${RKHINST_DB_DIR}" >/dev/null 2>&1
+			cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_DB_DIR}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_RW}" "${RKHINST_DB_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_DB_DIR}/${FILE}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 			;;
 		*.8)
-			cp -f ./files/"${FILE}" "${RKHINST_MAN_DIR}" >/dev/null 2>&1
+			cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_MAN_DIR}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_RWR}" "${RKHINST_MAN_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_RWR}" "${DESTDIR}${RKHINST_MAN_DIR}/${FILE}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
@@ -822,12 +814,12 @@
 
 	# Application documents
 	for FILE in ${RKHINST_DOC_FILES}; do
-		cp -f ./files/"${FILE}" "${RKHINST_DOC_DIR}" >/dev/null 2>&1
+		cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_DOC_DIR}" >/dev/null 2>&1
 		ERRCODE=$?
 
 		if [ $ERRCODE -eq 0 ]; then
 			echo " Installing ${FILE}: OK"
-			chmod "${RKHINST_MODE_RWR}" "${RKHINST_DOC_DIR}/${FILE}"
+			chmod "${RKHINST_MODE_RWR}" "${DESTDIR}${RKHINST_DOC_DIR}/${FILE}"
 		else
 			echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 			exit 1
@@ -843,7 +835,7 @@
 	fi
 
 	for FILE in `find ./files/i18n -type f`; do
-		cp "${FILE}" "${RKHINST_LANG_DIR}" >/dev/null 2>&1
+		cp "${FILE}" "${DESTDIR}${RKHINST_LANG_DIR}" >/dev/null 2>&1
 		ERRCODE=$?
 
 		FNAME=`echo ${FILE} | sed 's|^./files/i18n/||'`
@@ -872,7 +864,7 @@
 	fi
 
 	for FILE in `find ./files/signatures -type f`; do
-		cp "${FILE}" "${RKHINST_SIG_DIR}" >/dev/null 2>&1
+		cp "${FILE}" "${DESTDIR}${RKHINST_SIG_DIR}" >/dev/null 2>&1
 		ERRCODE=$?
 
 		FNAME=`echo ${FILE} | sed 's|^./files/signatures/||'`
@@ -896,24 +888,24 @@
 	for FILE in ${RKHINST_BIN_FILES}; do
 		case "${RKHINST_LAYOUT}" in
 		RPM|DEB|TGZ|TXZ)	
-			cp -f ./files/"${FILE}" "${RKHINST_BIN_DIR}/${FILE}" >/dev/null 2>&1
+			cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_EX}" "${RKHINST_BIN_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 			;;
 		*)	
-			sed -e "s|-f /etc/rkhunter.conf|-f $RKHINST_ETC_DIR/rkhunter.conf|g" -e "s|CONFIGFILE=\"/etc|CONFIGFILE=\"$RKHINST_ETC_DIR|g" ./files/"${FILE}" >"${RKHINST_BIN_DIR}/${FILE}"
+			sed -e "s|-f /etc/rkhunter.conf|-f $RKHINST_ETC_DIR/rkhunter.conf|g" -e "s|CONFIGFILE=\"/etc|CONFIGFILE=\"$RKHINST_ETC_DIR|g" ./files/"${FILE}" >"${DESTDIR}${RKHINST_BIN_DIR}/${FILE}"
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_EX}" "${RKHINST_BIN_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
@@ -927,7 +919,7 @@
 	for FILE in ${RKHINST_ETC_FILE}; do
 		test $OVERWRITE -eq 1 && rm -f "${RKHINST_ETC_DIR}/${FILE}"
 
-		if [ -f "${RKHINST_ETC_DIR}/${FILE}" ]; then
+		if [ -f "${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" ]; then
 			# We need people to make local changes themselves, so
 			# give opportunity and alert. Don't use Perl to get value.
 
@@ -943,36 +935,36 @@
 
 			NEWFILE="${FILE}.${RANDVAL}"
 
-			cp -f "./files/${FILE}" "${RKHINST_ETC_DIR}/${NEWFILE}" >/dev/null 2>&1
+			cp -f "./files/${FILE}" "${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE} in no-clobber mode: OK"
-				chmod "${RKHINST_MODE_RW}" "${RKHINST_ETC_DIR}/${NEWFILE}"
+				chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 			else
 				echo " Installing ${FILE} in no-clobber mode: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 
-			echo "" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 
 			test -z "${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${PREFIX}"
 
-			echo "INSTALLDIR=${RKHTMPVAR}" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
-			echo "DBDIR=${RKHINST_DB_DIR}" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
-			echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
-			echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "INSTALLDIR=${RKHTMPVAR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "DBDIR=${RKHINST_DB_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 
 			if [ "$FILE" = "rkhunter.conf" ]; then
-				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 
 				if [ -f "${RKHINST_ETC_DIR}/${FILE}.local" ]; then
-					echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
-					chmod "${RKHINST_MODE_RW}" "${RKHINST_ETC_DIR}/${FILE}.local"
+					echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
+					chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_ETC_DIR}/${FILE}.local"
 				fi
 
 				if [ -d "${RKHINST_ETC_DIR}/rkhunter.d" ]; then
-					echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/rkhunter.d/*.conf" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+					echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/rkhunter.d/*.conf" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 				fi
 			fi
 
@@ -988,12 +980,12 @@
 				;;
 			esac
 		else
-			cp -f "./files/${FILE}" "${RKHINST_ETC_DIR}" >/dev/null 2>&1
+			cp -f "./files/${FILE}" "${DESTDIR}${RKHINST_ETC_DIR}" >/dev/null 2>&1
 			ERRCODE=$?
 
 			if [ $ERRCODE -eq 0 ]; then
 				echo " Installing ${FILE}: OK"
-				chmod "${RKHINST_MODE_RW}" "${RKHINST_ETC_DIR}/${FILE}"
+				chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
 
 				if [ -f "${RKHINST_ETC_DIR}/${FILE}.local" ]; then
 					chmod "${RKHINST_MODE_RW}" "${RKHINST_ETC_DIR}/${FILE}.local"
@@ -1006,34 +998,34 @@
 			echo "" >>"${RKHINST_ETC_DIR}/${FILE}"
 
 			if [ -n "${RPM_BUILD_ROOT}" -a $RPM_USING_ROOT -eq 0 ]; then
-				echo "INSTALLDIR=${PREFIX}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
+				echo "INSTALLDIR=${PREFIX}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
 			elif [ -n "${TGZ_BUILD_ROOT}" -a $TGZ_USING_ROOT -eq 0 ]; then
-				echo "INSTALLDIR=${PREFIX}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
+				echo "INSTALLDIR=${PREFIX}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${TGZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
 			elif [ -n "${TXZ_BUILD_ROOT}" -a $TXZ_USING_ROOT -eq 0 ]; then
-				echo "INSTALLDIR=${PREFIX}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"
+				echo "INSTALLDIR=${PREFIX}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" | sed "s|${TXZ_BUILD_ROOT}||g" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
 			elif [ -n "${DEB_BUILD_ROOT}" ]; then
 				# Debian builds are handled with a patch during the build process.
 				:
 			else
 				test -z "${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${PREFIX}"
 
-				echo "INSTALLDIR=${RKHTMPVAR}" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "DBDIR=${RKHINST_DB_DIR}" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${RKHINST_ETC_DIR}/${FILE}"
-				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${RKHINST_ETC_DIR}/${FILE}"
+				echo "INSTALLDIR=${RKHTMPVAR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "DBDIR=${RKHINST_DB_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}"
 			fi
 		fi
 	done
@@ -1317,6 +1309,9 @@
 	-o | --overwrite)
 		OVERWRITE=1
 		;;
+	DESTDIR*)
+		DESTDIR=`echo "$1" | awk 'BEGIN {FS="="}; {print $2}'`
+		;;
 	*)
 		echo "Unknown option given: $1"
 		echo ""
