--- installer.sh.orig	2014-02-23 20:37:15.000000000 -0600
+++ installer.sh	2015-03-16 14:33:48.000000000 -0500
@@ -147,17 +147,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
 			;;
@@ -234,7 +234,7 @@
 
 		case "$1" in
 		/usr/local|custom_*)
-			SYSCONFIGDIR="${PREFIX}/etc"
+			SYSCONFIGDIR="${PREFIX}/etc/rkhunter"
 			;;
 		RPM)
 			if [ $RPM_USING_ROOT -eq 1 ]; then
@@ -278,11 +278,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"
@@ -362,11 +358,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"
@@ -410,8 +402,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"
@@ -635,14 +627,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
@@ -668,7 +660,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 
@@ -691,7 +683,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
@@ -712,21 +704,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
@@ -734,28 +726,28 @@
 	umask 027
 
 	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
@@ -769,20 +761,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"
@@ -790,24 +782,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
@@ -819,12 +811,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
@@ -836,7 +828,7 @@
 	ERRCODE=0
 
 	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=$?
 
 		test $ERRCODE -ne 0 && break
@@ -854,7 +846,7 @@
 	ERRCODE=0
 
 	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=$?
 
 		test $ERRCODE -ne 0 && break
@@ -871,24 +863,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
@@ -902,7 +894,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.
 
@@ -918,7 +910,7 @@
 
 			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
@@ -929,18 +921,18 @@
 				exit 1
 			fi
 
-			echo "" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+			echo "" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 
-			test -z "${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${PREFIX}"
+			test -z "${DESTDIR}${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${DESTDIR}${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}"
-				test -f "${RKHINST_ETC_DIR}/${FILE}.local" && echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${RKHINST_ETC_DIR}/${NEWFILE}"
+				echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
+				test -f "${RKHINST_ETC_DIR}/${FILE}.local" && echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}"
 			fi
 
 			case "${RKHINST_LAYOUT}" in
@@ -955,21 +947,21 @@
 				;;
 			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}"
 			else
 				echo " Installing ${FILE}: FAILED: Code $ERRCODE"
 				exit 1
 			fi
 
-			echo "" >>"${RKHINST_ETC_DIR}/${FILE}"
+			echo "" >>"${DESTDIR}${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 "INSTALLDIR=${DESTDIR}${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}"
@@ -992,11 +984,11 @@
 			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
@@ -1274,6 +1266,9 @@
 	-o | --overwrite)
 		OVERWRITE=1
 		;;
+	DESTDIR*)
+		DESTDIR=`echo "$1" | awk 'BEGIN {FS="="}; {print $2}'`
+		;;
 	*)
 		echo "Unknown option given: $1"
 		echo ""
