Ticket #16792: patch-installer.sh.diff
File patch-installer.sh.diff, 13.6 KB (added by Schamschula (Marius Schamschula), 10 years ago) |
---|
-
installer.sh
old new 147 147 exit 1 148 148 ;; 149 149 *) 150 test "${ PREFIX}" = "/" && PREFIX=""150 test "${DESTDIR}${PREFIX}" = "/" && PREFIX="" 151 151 152 if [ "${RKHINST_ACTION}" = "install" ]; then153 RKHTMPVAR=`echo "${PATH}" | grep "${PREFIX}/bin"`154 155 if [ -z "${RKHTMPVAR}" ]; then156 echo ""157 echo "Note: Directory${PREFIX}/bin is not in your PATH"158 echo ""159 fi160 fi152 # if [ "${RKHINST_ACTION}" = "install" ]; then 153 # RKHTMPVAR=`echo "${PATH}" | grep "${DESTDIR}${PREFIX}/bin"` 154 # 155 # if [ -z "${RKHTMPVAR}" ]; then 156 # echo "" 157 # echo "Note: Directory ${DESTDIR}${PREFIX}/bin is not in your PATH" 158 # echo "" 159 # fi 160 # fi 161 161 ;; 162 162 esac 163 163 ;; … … 234 234 235 235 case "$1" in 236 236 /usr/local|custom_*) 237 SYSCONFIGDIR="${PREFIX}/etc "237 SYSCONFIGDIR="${PREFIX}/etc/rkhunter" 238 238 ;; 239 239 RPM) 240 240 if [ $RPM_USING_ROOT -eq 1 ]; then … … 278 278 fi 279 279 280 280 if [ -z "${LIBDIR}" ]; then 281 if [ "${UNAMEM}" = "x86_64" -o "${UNAMEM}" = "ppc64" ]; then 282 LIBDIR="${PREFIX}/lib64" 283 else 284 LIBDIR="${PREFIX}/lib" 285 fi 281 LIBDIR="${PREFIX}/lib" 286 282 fi 287 283 288 284 BINDIR="${PREFIX}/bin" … … 362 358 SHAREDIR="${PREFIX}/share" 363 359 ;; 364 360 *) 365 if [ -d "${PREFIX}/lib64" ]; then 366 LIBDIR="${PREFIX}/lib64" 367 else 368 LIBDIR="${PREFIX}/lib" 369 fi 361 LIBDIR="${PREFIX}/lib" 370 362 371 363 BINDIR="${PREFIX}/bin" 372 364 VARDIR="/var" … … 410 402 RKHINST_MAN_DIR="${PREFIX}/man/man8" 411 403 else 412 404 RKHINST_DB_DIR="${VARDIR}/lib/${APPNAME}/db" 413 RKHINST_TMP_DIR=" ${VARDIR}/lib/${APPNAME}/tmp"414 RKHINST_DOC_DIR="${SHAREDIR}/ doc/${APPNAME}-${APPVERSION}"405 RKHINST_TMP_DIR="/private/tmp" 406 RKHINST_DOC_DIR="${SHAREDIR}/${APPNAME}-${APPVERSION}" 415 407 fi 416 408 417 409 RKHINST_LANG_DIR="${RKHINST_DB_DIR}/i18n" … … 635 627 ;; 636 628 *) 637 629 # Check PREFIX 638 if [ -z "${ PREFIX}" ]; then630 if [ -z "${DESTDIR}${PREFIX}" ]; then 639 631 : 640 elif [ -d "${ PREFIX}" ]; then641 if [ -w "${ PREFIX}" ]; then642 echo " Checking installation directory \"$ PREFIX\": it exists and is writable."632 elif [ -d "${DESTDIR}${PREFIX}" ]; then 633 if [ -w "${DESTDIR}${PREFIX}" ]; then 634 echo " Checking installation directory \"${DESTDIR}$PREFIX\": it exists and is writable." 643 635 644 636 # That's enough for a standalone installation. 645 if [ "${ PREFIX}" = "." ]; then637 if [ "${DESTDIR}${PREFIX}" = "." ]; then 646 638 chown -R ${RKHINST_OWNER} ./files 647 639 648 640 for DIR in `find ./files -type d -name CVS`; do … … 668 660 669 661 PREFIX="${PWD}" 670 662 671 echo "LOGFILE=${PREFIX}/ rkhunter.log" >>rkhunter.conf663 echo "LOGFILE=${PREFIX}/var/log/rkhunter/rkhunter.log" >>rkhunter.conf 672 664 echo "TMPDIR=$PREFIX" >>rkhunter.conf 673 665 echo "DBDIR=$PREFIX" >>rkhunter.conf 674 666 echo "SCRIPTDIR=$PREFIX" >>rkhunter.conf … … 691 683 echo " Checking installation directory \"$PREFIX\": it exists, but it is not writable. Exiting." 692 684 exit 1 693 685 fi 694 elif [ -e "${ PREFIX}" ]; then686 elif [ -e "${DESTDIR}${PREFIX}" ]; then 695 687 echo " Checking installation directory \"$PREFIX\": it is not a directory. Exiting." 696 688 exit 1 697 689 else … … 712 704 713 705 umask 022 714 706 for DIR in ${RKHDIR_LIST}; do 715 if [ -d "${D IR}" ]; then716 if [ -w "${D IR}" ]; then717 echo " Directory ${D IR}: exists and is writable."707 if [ -d "${DESTDIR}${DIR}" ]; then 708 if [ -w "${DESTDIR}${DIR}" ]; then 709 echo " Directory ${DESTDIR}${DIR}: exists and is writable." 718 710 else 719 echo " Directory ${D IR}: exists, but it is not writable. Exiting."711 echo " Directory ${DESTDIR}${DIR}: exists, but it is not writable. Exiting." 720 712 exit 1 721 713 fi 722 714 else 723 mkdir -p ${D IR} >/dev/null 2>&1715 mkdir -p ${DESTDIR}${DIR} >/dev/null 2>&1 724 716 ERRCODE=$? 725 717 726 718 if [ $ERRCODE -eq 0 ]; then 727 echo " Directory ${D IR}: creating: OK"719 echo " Directory ${DESTDIR}${DIR}: creating: OK" 728 720 else 729 echo " Directory ${D IR}: creating: FAILED: Code $ERRCODE"721 echo " Directory ${DESTDIR}${DIR}: creating: FAILED: Code $ERRCODE" 730 722 exit 1 731 723 fi 732 724 fi … … 734 726 umask 027 735 727 736 728 for DIR in ${RKHINST_DIRS_EXCEP}; do 737 if [ -d "${D IR}" ]; then738 if [ -w "${D IR}" ]; then739 echo " Directory ${D IR}: exists and is writable."729 if [ -d "${DESTDIR}${DIR}" ]; then 730 if [ -w "${DESTDIR}${DIR}" ]; then 731 echo " Directory ${DESTDIR}${DIR}: exists and is writable." 740 732 else 741 echo " Directory ${D IR}: exists, but it is not writable. Exiting."733 echo " Directory ${DESTDIR}${DIR}: exists, but it is not writable. Exiting." 742 734 exit 1 743 735 fi 744 736 else 745 mkdir -p ${D IR} >/dev/null 2>&1737 mkdir -p ${DESTDIR}${DIR} >/dev/null 2>&1 746 738 ERRCODE=$? 747 739 748 740 if [ $ERRCODE -eq 0 ]; then 749 echo " Directory ${D IR}: creating: OK"741 echo " Directory ${DESTDIR}${DIR}: creating: OK" 750 742 else 751 echo " Directory ${D IR}: creating: FAILED: Code $ERRCODE"743 echo " Directory ${DESTDIR}${DIR}: creating: FAILED: Code $ERRCODE" 752 744 exit 1 753 745 fi 754 746 fi 755 747 756 case "${D IR}" in748 case "${DESTDIR}${DIR}" in 757 749 */${APPNAME}|*/${APPNAME}/*|*/${APPNAME}-${APPVERSION}) 758 chmod "${RKHINST_MODE_EX}" "${D IR}"750 chmod "${RKHINST_MODE_EX}" "${DESTDIR}${DIR}" 759 751 ;; 760 752 esac 761 753 done … … 769 761 for FILE in ${RKHINST_SCRIPT_FILES} ${RKHINST_DB_FILES} ${RKHINST_MAN_FILES}; do 770 762 case "${FILE}" in 771 763 *.pl|*.sh) 772 cp -f ./files/"${FILE}" "${ RKHINST_SCRIPT_DIR}" >/dev/null 2>&1764 cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_SCRIPT_DIR}" >/dev/null 2>&1 773 765 ERRCODE=$? 774 766 775 767 if [ $ERRCODE -eq 0 ]; then 776 768 echo " Installing ${FILE}: OK" 777 chmod "${RKHINST_MODE_EX}" "${ RKHINST_SCRIPT_DIR}/${FILE}"769 chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_SCRIPT_DIR}/${FILE}" 778 770 else 779 771 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 780 772 exit 1 781 773 fi 782 774 ;; 783 775 *.dat) 784 if [ "${FILE}" = "mirrors.dat" -a -f "${ RKHINST_DB_DIR}/mirrors.dat" ]; then785 RKHTMPVAR=`egrep '^(local|remote)=' ${ RKHINST_DB_DIR}/mirrors.dat 2>/dev/null`776 if [ "${FILE}" = "mirrors.dat" -a -f "${DESTDIR}${RKHINST_DB_DIR}/mirrors.dat" ]; then 777 RKHTMPVAR=`egrep '^(local|remote)=' ${DESTDIR}${RKHINST_DB_DIR}/mirrors.dat 2>/dev/null` 786 778 787 779 if [ -n "${RKHTMPVAR}" ]; then 788 780 echo " Installing ${FILE}: Locally modified - not overwritten" … … 790 782 fi 791 783 fi 792 784 793 cp -f ./files/"${FILE}" "${ RKHINST_DB_DIR}" >/dev/null 2>&1785 cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_DB_DIR}" >/dev/null 2>&1 794 786 ERRCODE=$? 795 787 796 788 if [ $ERRCODE -eq 0 ]; then 797 789 echo " Installing ${FILE}: OK" 798 chmod "${RKHINST_MODE_RW}" "${ RKHINST_DB_DIR}/${FILE}"790 chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_DB_DIR}/${FILE}" 799 791 else 800 792 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 801 793 exit 1 802 794 fi 803 795 ;; 804 796 *.8) 805 cp -f ./files/"${FILE}" "${ RKHINST_MAN_DIR}" >/dev/null 2>&1797 cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_MAN_DIR}" >/dev/null 2>&1 806 798 ERRCODE=$? 807 799 808 800 if [ $ERRCODE -eq 0 ]; then 809 801 echo " Installing ${FILE}: OK" 810 chmod "${RKHINST_MODE_RWR}" "${ RKHINST_MAN_DIR}/${FILE}"802 chmod "${RKHINST_MODE_RWR}" "${DESTDIR}${RKHINST_MAN_DIR}/${FILE}" 811 803 else 812 804 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 813 805 exit 1 … … 819 811 820 812 # Application documents 821 813 for FILE in ${RKHINST_DOC_FILES}; do 822 cp -f ./files/"${FILE}" "${ RKHINST_DOC_DIR}" >/dev/null 2>&1814 cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_DOC_DIR}" >/dev/null 2>&1 823 815 ERRCODE=$? 824 816 825 817 if [ $ERRCODE -eq 0 ]; then 826 818 echo " Installing ${FILE}: OK" 827 chmod "${RKHINST_MODE_RWR}" "${ RKHINST_DOC_DIR}/${FILE}"819 chmod "${RKHINST_MODE_RWR}" "${DESTDIR}${RKHINST_DOC_DIR}/${FILE}" 828 820 else 829 821 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 830 822 exit 1 … … 836 828 ERRCODE=0 837 829 838 830 for FILE in `find ./files/i18n -type f`; do 839 cp "${FILE}" "${ RKHINST_LANG_DIR}" >/dev/null 2>&1831 cp "${FILE}" "${DESTDIR}${RKHINST_LANG_DIR}" >/dev/null 2>&1 840 832 ERRCODE=$? 841 833 842 834 test $ERRCODE -ne 0 && break … … 854 846 ERRCODE=0 855 847 856 848 for FILE in `find ./files/signatures -type f`; do 857 cp "${FILE}" "${ RKHINST_SIG_DIR}" >/dev/null 2>&1849 cp "${FILE}" "${DESTDIR}${RKHINST_SIG_DIR}" >/dev/null 2>&1 858 850 ERRCODE=$? 859 851 860 852 test $ERRCODE -ne 0 && break … … 871 863 for FILE in ${RKHINST_BIN_FILES}; do 872 864 case "${RKHINST_LAYOUT}" in 873 865 RPM|DEB|TGZ|TXZ) 874 cp -f ./files/"${FILE}" "${ RKHINST_BIN_DIR}/${FILE}" >/dev/null 2>&1866 cp -f ./files/"${FILE}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}" >/dev/null 2>&1 875 867 ERRCODE=$? 876 868 877 869 if [ $ERRCODE -eq 0 ]; then 878 870 echo " Installing ${FILE}: OK" 879 chmod "${RKHINST_MODE_EX}" "${ RKHINST_BIN_DIR}/${FILE}"871 chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}" 880 872 else 881 873 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 882 874 exit 1 883 875 fi 884 876 ;; 885 877 *) 886 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}"878 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}" 887 879 ERRCODE=$? 888 880 889 881 if [ $ERRCODE -eq 0 ]; then 890 882 echo " Installing ${FILE}: OK" 891 chmod "${RKHINST_MODE_EX}" "${ RKHINST_BIN_DIR}/${FILE}"883 chmod "${RKHINST_MODE_EX}" "${DESTDIR}${RKHINST_BIN_DIR}/${FILE}" 892 884 else 893 885 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 894 886 exit 1 … … 902 894 for FILE in ${RKHINST_ETC_FILE}; do 903 895 test $OVERWRITE -eq 1 && rm -f "${RKHINST_ETC_DIR}/${FILE}" 904 896 905 if [ -f "${ RKHINST_ETC_DIR}/${FILE}" ]; then897 if [ -f "${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" ]; then 906 898 # We need people to make local changes themselves, so 907 899 # give opportunity and alert. Don't use Perl to get value. 908 900 … … 918 910 919 911 NEWFILE="${FILE}.${RANDVAL}" 920 912 921 cp -f "./files/${FILE}" "${ RKHINST_ETC_DIR}/${NEWFILE}" >/dev/null 2>&1913 cp -f "./files/${FILE}" "${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" >/dev/null 2>&1 922 914 ERRCODE=$? 923 915 924 916 if [ $ERRCODE -eq 0 ]; then … … 929 921 exit 1 930 922 fi 931 923 932 echo "" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"924 echo "" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 933 925 934 test -z "${ PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${PREFIX}"926 test -z "${DESTDIR}${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${DESTDIR}${PREFIX}" 935 927 936 echo "INSTALLDIR=${RKHTMPVAR}" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"937 echo "DBDIR=${RKHINST_DB_DIR}" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"938 echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"939 echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"928 echo "INSTALLDIR=${RKHTMPVAR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 929 echo "DBDIR=${RKHINST_DB_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 930 echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 931 echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 940 932 941 933 if [ "$FILE" = "rkhunter.conf" ]; then 942 echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"943 test -f "${RKHINST_ETC_DIR}/${FILE}.local" && echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${ RKHINST_ETC_DIR}/${NEWFILE}"934 echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 935 test -f "${RKHINST_ETC_DIR}/${FILE}.local" && echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}.local" >>"${DESTDIR}${RKHINST_ETC_DIR}/${NEWFILE}" 944 936 fi 945 937 946 938 case "${RKHINST_LAYOUT}" in … … 955 947 ;; 956 948 esac 957 949 else 958 cp -f "./files/${FILE}" "${ RKHINST_ETC_DIR}" >/dev/null 2>&1950 cp -f "./files/${FILE}" "${DESTDIR}${RKHINST_ETC_DIR}" >/dev/null 2>&1 959 951 ERRCODE=$? 960 952 961 953 if [ $ERRCODE -eq 0 ]; then 962 954 echo " Installing ${FILE}: OK" 963 chmod "${RKHINST_MODE_RW}" "${ RKHINST_ETC_DIR}/${FILE}"955 chmod "${RKHINST_MODE_RW}" "${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 964 956 else 965 957 echo " Installing ${FILE}: FAILED: Code $ERRCODE" 966 958 exit 1 967 959 fi 968 960 969 echo "" >>"${ RKHINST_ETC_DIR}/${FILE}"961 echo "" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 970 962 971 963 if [ -n "${RPM_BUILD_ROOT}" -a $RPM_USING_ROOT -eq 0 ]; then 972 echo "INSTALLDIR=${ PREFIX}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}"964 echo "INSTALLDIR=${DESTDIR}${PREFIX}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}" 973 965 echo "DBDIR=${RKHINST_DB_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}" 974 966 echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}" 975 967 echo "TMPDIR=${RKHINST_TMP_DIR}" | sed "s|${RPM_BUILD_ROOT}||g" >>"${RKHINST_ETC_DIR}/${FILE}" … … 992 984 else 993 985 test -z "${PREFIX}" && RKHTMPVAR="/" || RKHTMPVAR="${PREFIX}" 994 986 995 echo "INSTALLDIR=${RKHTMPVAR}" >>"${ RKHINST_ETC_DIR}/${FILE}"996 echo "DBDIR=${RKHINST_DB_DIR}" >>"${ RKHINST_ETC_DIR}/${FILE}"997 echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${ RKHINST_ETC_DIR}/${FILE}"998 echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${ RKHINST_ETC_DIR}/${FILE}"999 echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${ RKHINST_ETC_DIR}/${FILE}"987 echo "INSTALLDIR=${RKHTMPVAR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 988 echo "DBDIR=${RKHINST_DB_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 989 echo "SCRIPTDIR=${RKHINST_SCRIPT_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 990 echo "TMPDIR=${RKHINST_TMP_DIR}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 991 echo "USER_FILEPROP_FILES_DIRS=${RKHINST_ETC_DIR}/${FILE}" >>"${DESTDIR}${RKHINST_ETC_DIR}/${FILE}" 1000 992 fi 1001 993 fi 1002 994 done … … 1274 1266 -o | --overwrite) 1275 1267 OVERWRITE=1 1276 1268 ;; 1269 DESTDIR*) 1270 DESTDIR=`echo "$1" | awk 'BEGIN {FS="="}; {print $2}'` 1271 ;; 1277 1272 *) 1278 1273 echo "Unknown option given: $1" 1279 1274 echo ""