Make install:
[privoxy.git] / GNUmakefile.in
index b382778..ebea7c1 100644 (file)
@@ -1,6 +1,6 @@
 # Note:  Makefile is built automatically from Makefile.in
 #
-# $Id: GNUmakefile.in,v 1.127 2002/10/18 00:58:07 hal9 Exp $
+# $Id: GNUmakefile.in,v 1.129 2002/10/20 07:15:12 hal9 Exp $
 #
 # Written by and Copyright (C) 2001 the SourceForge
 # Privoxy team. http://www.privoxy.org/
@@ -93,10 +93,12 @@ PROGRAM    = privoxy@EXEEXT@
 CC         = @CC@
 ECHO       = echo
 GZIP_PROG  = gzip
+# Install usage should be compatible with install-sh.
 INSTALL    = @INSTALL@
 INSTALL_P  = -m 0755  
-INSTALL_T  = -m 064
+INSTALL_T  = -m 066
 INSTALL_D  = -m 0755 -d
+INSTALL_R  = 0660
 # install options for superuser install
 #INSTALL_S  = -g @GROUP@ -o @USER@ 
 # id -u is not universal. FIXME: need to set from configure. Breaks on
@@ -118,21 +120,13 @@ TOUCH      = touch
 KILL       = kill
 CHMOD      = chmod
 CHOWN      = chown
-WDUMP      = @WDUMP@ -dump
-JADECAT    = @JADECAT@
-JADEBIN    = @JADEBIN@
 DOC_STATUS = @DOC_STATUS@
 # Note: Please make sure that -d ldp.dsl\#html stays the last option to
 #       $(JADEBIN), because for some targets "-notoc" will be appended
 #       to it (--> "ldp.dsl\#html-notoc"). 
-DB         = $(JADEBIN) $(JADECAT) -i$(DOC_STATUS) -ihtml -t sgml  -D.. -d ldp.dsl\#html
-MAN2HTML   = @MAN2HTML@
-G2H_CMD    = groff -mandoc -Thtml
 TARGET_OS  = @host@
 PERL       = perl
 DOC_DIR    = doc/source
-DOC_TMP    = $(DOC_DIR)/tmp
-DKPREFIX   = @DKPREFIX@
 
 #User Group paras
 USER       = @USER@
@@ -850,22 +844,22 @@ GROUP_T:=$(shell if [ x$(GROUP) = x ] && [ x$(USER) != x ];then \
 install-strip:
        $(MAKE) install STRIP=-s
 
-# FIXME: redhat init script has wrong paths for /usr/local/ install.
-#
-# FIXME: Check USER and GROUP on Slack to make user this works as 
+# FIXME: Test USER and GROUP on Slack to make sure this works as 
 # intended.
 #
 # FIXME: id handling needs help, probably via configure, since 'id -u' is not 
-# universally reliable (eg Solaris). Group handling is weak. If group is null,
-# we blindly assume there is a group that matches $(USER). configure only 
-# tests for the first group outputted from groups command. Perhaps the whole 
-# user/group validation should be done here. In fact, it should probably be
-# tested for and set first thing, ie for a root install.
+# universally reliable (eg Solaris). Group handling could be better. 
+# Perhaps the whole user/group validation should be done here.
 install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
        # Quick test for valid USER.
        if [ -n "$(USER)" ]; then \
                id $(USER) >/dev/null || exit 1;\
        fi
+       # Test for valid group.
+       if [ -n "$(GROUP_T)" ] && [ -n "$(USER)" ] && ! groups $(USER) | $(GREP) "\<$(GROUP_T)\>" >/dev/null; then \
+               $(ECHO) Group $(GROUP_T) for User $(USER) is invalid && exit 1 ;\
+       fi
+       
        $(ECHO) "Creating directories, and preparing Privoxy installation"
        $(CHMOD) 0755 $(MKDIR)
        $(MKDIR) $(SBIN_DEST) $(prefix) $(CONF_DEST) $(CONF_DEST)/templates $(SHARE_DEST) \
@@ -902,6 +896,7 @@ install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
                $(INSTALL) $(INSTALL_T) ChangeLog $$DOC;\
                $(INSTALL) $(INSTALL_T) $(DOK_WEB)/p_doc.css $$DOC;\
        fi
+       # Not all platforms support gzipped man pages.
        $(ECHO) Installing man page to $(MAN_DEST)/privoxy.1
        -$(INSTALL) $(INSTALL_T) privoxy.1  $(MAN_DEST)/privoxy.1
 
@@ -923,10 +918,11 @@ install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
        for i in `find templates -type f`; do \
                $(INSTALL) $(INSTALL_T) $$i $(CONF_DEST)/templates ;\
        done
+
        if [ "`id |sed 's/(.*//' |sed 's/.*=//'`" = "0" ] ;then\
-               if [ x$(USER) = x ]; then \
+               if [ x$(USER) = x ] || [ $(USER) = root ]; then \
                        if [ "`id privoxy`" ]; then \
-                               $(ECHO) "Setting user and group to privoxy";\
+                               $(ECHO) "Warning: Setting user and group to privoxy";\
                                INSTALL_CONF="$(INSTALL_T) -g privoxy -o privoxy" ;\
                                USER=privoxy ;\
                                GROUP_T=privoxy ;\
@@ -954,42 +950,44 @@ install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
        for i in $(CONFIGS); do \
                if [ -s "$(CONF_DEST)/$$i" ] ; then \
                        $(ECHO) Installing $$i as $$i.new ;\
-                       $(INSTALL) $$i $(CONF_DEST)/$$i.new || exit 1;\
+                       $(INSTALL) -m $(INSTALL_R) $$i $(CONF_DEST)/$$i.new || exit 1;\
                        NEW=1;\
                else \
                        if test "$$i" = "config" || test "$$i" = "default.filter"; then \
-                               $(INSTALL)  $$i $(CONF_DEST) || exit 1;\
-                               $(CHMOD) 0640 $(CONF_DEST)/$$i ;\
+                               $(INSTALL) -m $(INSTALL_R) $$i $(CONF_DEST) || exit 1;\
                        else \
-                               $(INSTALL) $$INSTALL_CONF $$i $(CONF_DEST) || exit 1;\
+                               $(INSTALL) -m $(INSTALL_R) $$INSTALL_CONF $$i $(CONF_DEST) || exit 1;\
                        fi;\
                fi ;\
        done ;\
        if [ -n "$$NEW" ]; then \
-               $(CHMOD) 0640 $(CONF_DEST)/*.new || exit 1 ;\
+               $(CHMOD) $(INSTALL_R) $(CONF_DEST)/*.new || exit 1 ;\
                $(ECHO) "Warning: Older config files are preserved. Check new versions for changes!" ;\
        fi ;\
-       ! test -f $(LOG_DEST)/logfile && $(ECHO) Creating logfiles in $(LOG_DEST) || \
+       [ ! -f $(LOG_DEST)/logfile ] && $(ECHO) Creating logfiles in $(LOG_DEST) || \
                $(ECHO) Checking logfiles in $(LOG_DEST) ;\
        $(TOUCH) $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || exit 1 ;\
        if [ x$$USER != x ]; then \
                $(CHOWN) $$USER:$$GROUP_T $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || \
                $(ECHO) "** WARNING ** current install user different from configured user. Logging may fail!!" ;\
        fi ;\
-       $(CHMOD) 0640 $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || exit 1 ;\
-       if [ "$(prefix)" = "/usr/local" ]; then \
+       $(CHMOD) $(INSTALL_R) $(LOG_DEST)/logfile $(LOG_DEST)/jarfile || exit 1 ;\
+       if [ "$(prefix)" = "/usr/local" ] || [ "$(prefix)" = "/usr" ]; then \
                if [ -f /etc/slackware-version ] && [ -d /etc/rc.d/ ] && [ -w /etc/rc.d/ ] ; then \
                $(SED) 's+%PROGRAM%+$(PROGRAM)+' slackware/rc.privoxy.orig | \
                $(SED) 's+%SBIN_DEST%+$(SBIN_DEST)+' | \
                $(SED) 's+%CONF_DEST%+$(CONF_DEST)+' | \
-               $(SED) 's+%USER%+$(USER)+' | \
+               $(SED) 's+%USER%+$$USER+' | \
                $(SED) 's+%GROUP%+$(GROUP_T)+' >slackware/rc.privoxy ;\
                        $(INSTALL) $(INSTALL_P) slackware/rc.privoxy /etc/rc.d/ ;\
                $(ECHO) "Installing for Slackware." ;\
                $(ECHO) "Dont forget to add the rc.privoxy to rc.local if you want it started at every boot" ;\
                elif [ -f /etc/redhat-release ] && [ -d /etc/rc.d/init.d/ ] && [ -w /etc/rc.d/init.d/ ] ; then \
                $(ECHO) "Installing init script to /etc/rc.d/init.d/privoxy" ;\
-                       $(INSTALL) $(INSTALL_P) privoxy.init /etc/rc.d/init.d/privoxy ;\
+                       $(SED) 's,^PRIVOXY_BIN=.*,PRIVOXY_BIN="/usr/local/sbin/$(PROGRAM)",' privoxy.init |\
+                       $(SED) 's,^PRIVOXY_CONF=.*,PRIVOXY_CONF="$(CONF_DEST)/config",' |\
+                       $(SED) "s,^PRIVOXY_USER=.*,PRIVOXY_USER=$$USER," > init.tmp ;\
+                       $(INSTALL) $(INSTALL_P) init.tmp /etc/rc.d/init.d/privoxy && $(RM) init.tmp;\
                        $(MKDIR) /etc/logrotate.d/ ;\
                        $(ECHO) "Installing logrotate script to /etc/logrotate.d/" ;\
                        $(INSTALL) $(INSTALL_P) privoxy.logrotate /etc/logrotate.d/privoxy ;\
@@ -1006,10 +1004,14 @@ install: CONF_DEST LOG_DEST PID_DEST check_doc GROUP_T
        @$(ECHO) "The Privoxy configuration files have been installed in $(CONF_DEST)"
 
 # rmdir is used as a precaution since it will not remove non-empty
-# directories.
+# directories. RH init script creates lock file and pid file.
 uninstall: CONF_DEST LOG_DEST PID_DEST check_doc
        $(ECHO) Starting Privoxy uninstallation
        # KILL privoxy if running
+       -if [ -f /etc/redhat-release ] && [ -d /etc/rc.d/init.d/ ] && [ -w /etc/rc.d/init.d/ ] ; then \
+               /etc/rc.d/init.d/privoxy stop >/dev/null 2>/dev/null ;\
+               chkconfig --del $(PROGRAM) 2>/dev/null;\
+       fi
        -@ test -f $(PID_DEST)/privoxy.pid && $(ECHO) Stopping $(PROGRAM) &&\
           $(KILL) `$(CAT) $(PID_DEST)/privoxy.pid` 
        -@ test -f /var/run/privoxy.pid && $(ECHO) Stopping $(PROGRAM) &&\
@@ -1065,7 +1067,7 @@ uninstall: CONF_DEST LOG_DEST PID_DEST check_doc
        fi
 
        # init scripts and logrotate
-       if [ "$(prefix)" = "/usr/local" ]; then \
+       if [ "$(prefix)" = "/usr/local" ] || [ "$(prefix)" = "/usr" ]; then \
                $(ECHO) Removing $(PROGRAM) init script ;\
                if [ -f /etc/slackware-version ] && [ -d /etc/rc.d/ ]  && [ -w /etc/rc.d/ ] ; then \
                        $(RM) /etc/rc.d/rc.privoxy ;\
@@ -1093,6 +1095,22 @@ coffee:
 ## end:
 
 # $Log: GNUmakefile.in,v $
+# Revision 1.129  2002/10/20 07:15:12  hal9
+# Getting near the end (I hope) of install target updates:
+# - Rewrite RH init script to reflect configured values.
+# - Test for USER=root as well as UID=0
+# - Test for invalid group (probably needs more work).
+# - Add /usr to /usr/local test for when to install init scripts, etc.
+# - More testing on previous changes.
+#
+# Revision 1.128  2002/10/18 05:36:32  hal9
+# More install target fixes:
+# - Quick fix of log ownership on root install (lightly tested). If this goes
+#   true to form, then the fix will break something else :(
+# - Fix what looks like was invalid user on Slack if root install and
+#   we use an existing privoxy user. No way to test this.
+# See FIXMEs.
+#
 # Revision 1.127  2002/10/18 00:58:07  hal9
 # More install/uninstall/install-strip updates:
 # - Don't install gzipped man page (Solaris again).