INN commit: trunk (5 files)

INN Commit rra at isc.org
Fri May 1 09:11:23 UTC 2015


    Date: Friday, May 1, 2015 @ 02:11:23
  Author: iulius
Revision: 9832

Improve DESTDIR support and non-root installs

DESTDIR and non-root installs are now properly supported and documented
in INSTALL.  The "make install", "make update" and "make cert" steps
properly obey DESTDIR.  Besides, it is no longer a requirement that
the installation step be done by the superuser, as long as the user
executing the install has supplied a DESTDIR value that points to a
writable directory, *and* the person or process performing the install
corrects the file ownerships when INN is installed on the system on
which it's going to run.

chown and chgrp commands are now executed during install only if the
current user is root.  INSTALL also documents how to disable them,
if needed, with the CHOWNPROG and CHGRPPROG environment variables.

makedbz is executed only if the current user is root or the news user.

innupgrade is now executed also when DESTDIR is in use.

Thanks to James Ralston for most of the patch.

see #29

Modified:
  trunk/Makefile
  trunk/Makefile.global.in
  trunk/doc/pod/install.pod
  trunk/doc/pod/news.pod
  trunk/site/Makefile

---------------------+
 Makefile            |   51 ++++++++++++++++++++++---------------------
 Makefile.global.in  |   12 ----------
 doc/pod/install.pod |   59 +++++++++++++++++++++++++++++++++++++++++---------
 doc/pod/news.pod    |   11 +++++++++
 site/Makefile       |   19 +++++++++++-----
 5 files changed, 100 insertions(+), 52 deletions(-)

Modified: Makefile
===================================================================
--- Makefile	2015-04-23 19:07:39 UTC (rev 9831)
+++ Makefile	2015-05-01 09:11:23 UTC (rev 9832)
@@ -90,7 +90,7 @@
 install: directories
 	@for D in $(ALLDIRS) ; do \
 	    echo '' ; \
-	    cd $$D && $(MAKE) install || exit 1 ; cd .. ; \
+	    cd $$D && $(MAKE) D="$(DESTDIR)" install || exit 1 ; cd .. ; \
 	done
 	@echo ''
 	@echo 'If this is a first-time installation, a minimal active file and'
@@ -102,45 +102,46 @@
 directories:
 	@chmod +x support/install-sh
 	for D in $(INSTDIRS) ; do \
-	    support/install-sh $(OWNER) -m 0755 -d $(D)$$D ; \
+	    support/install-sh $(OWNER) -m 0755 -d $(DESTDIR)$$D ; \
 	done
-	support/install-sh $(OWNER) -m 0750 -d $(D)$(PATHRUN)
+	support/install-sh $(OWNER) -m 0750 -d $(DESTDIR)$(PATHRUN)
 
 update: 
 	@chmod +x support/install-sh
 	@for D in $(UPDATEDIRS) ; do \
 	    echo '' ; \
-	    cd $$D && $(MAKE) install || exit 1 ; cd .. ; \
+	    cd $$D && $(MAKE) D="$(DESTDIR)" install || exit 1 ; cd .. ; \
 	done
-	if [ -z "$D" ] ; then \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(PATHAUTHPASSWD) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(PATHBIN) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(PATHDOC) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(PATHETC) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade ${PATHFILTER} ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(MAN1) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(MAN3) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(MAN5) ; \
-	    $(PERL) -Tw $(PATHBIN)/innupgrade $(MAN8) ; \
-	fi
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(PATHAUTHPASSWD)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(PATHBIN)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(PATHDOC)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(PATHETC)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)${PATHFILTER}
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(MAN1)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(MAN3)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(MAN5)
+	$(PERL) -Tw $(PATHBIN)/innupgrade $(DESTDIR)$(MAN8)
 
 install-root:
 	@chmod +x support/install-sh
-	support/install-sh $(OWNER) -m 0755 -d $(D)$(PATHBIN)
-	cd backends && $(MAKE) install-root || exit 1 ; cd ..
+	support/install-sh $(OWNER) -m 0755 -d $(DESTDIR)$(PATHBIN)
+	cd backends && $(MAKE) D="$(DESTDIR)" install-root || exit 1 ; cd ..
 
 ##  Install a certificate for TLS/SSL support.
 cert:
 	umask 077 ; \
 	$(SSLBIN) req -new -x509 -nodes \
-	    -out $(D)$(PATHETC)/cert.pem -days 366 \
-	    -keyout $(D)$(PATHETC)/key.pem
-	chown $(RUNASUSER) $(D)$(PATHETC)/cert.pem
-	chgrp $(RUNASGROUP) $(D)$(PATHETC)/cert.pem
-	chmod 640 $(D)$(PATHETC)/cert.pem
-	chown $(RUNASUSER) $(D)$(PATHETC)/key.pem
-	chgrp $(RUNASGROUP) $(D)$(PATHETC)/key.pem
-	chmod 600 $(D)$(PATHETC)/key.pem
+	    -out $(DESTDIR)$(PATHETC)/cert.pem -days 366 \
+	    -keyout $(DESTDIR)$(PATHETC)/key.pem
+	@ME=`$(WHOAMI)` ; \
+	if [ x"$$ME" = xroot ] ; then \
+	    chown $(RUNASUSER) $(DESTDIR)$(PATHETC)/cert.pem ; \
+	    chgrp $(RUNASGROUP) $(DESTDIR)$(PATHETC)/cert.pem ; \
+	    chown $(RUNASUSER) $(DESTDIR)$(PATHETC)/key.pem ; \
+	    chgrp $(RUNASGROUP) $(DESTDIR)$(PATHETC)/key.pem ; \
+	fi
+	chmod 640 $(DESTDIR)$(PATHETC)/cert.pem
+	chmod 600 $(DESTDIR)$(PATHETC)/key.pem
 
 
 ##  Cleanup targets.  clean deletes all compilation results but leaves the

Modified: Makefile.global.in
===================================================================
--- Makefile.global.in	2015-04-23 19:07:39 UTC (rev 9831)
+++ Makefile.global.in	2015-05-01 09:11:23 UTC (rev 9832)
@@ -21,18 +21,6 @@
 VERSION		= 2.6.0
 VERSION_EXTRA	= prerelease
 
-##  If you want to install INN relative to a root directory other than /,
-##  set DESTDIR to the path to the root directory of the file system.  This
-##  won't affect any of the paths compiled into INN; it's used primarily
-##  when building a software distribution, where software has to be
-##  installed into some file system that will later be mounted as / on the
-##  final system.  DESTDIR doesn't need a trailing slash, as all the
-##  installation paths already start with / because they're absolute paths
-##  determined by configure.
-
-DESTDIR		=
-D		= $(DESTDIR)
-
 ##  The absolute path to the top of the build directory, used to find the
 ##  libraries built as part of INN.  Using relative paths confuses libtool
 ##  when linking the test suite.

Modified: doc/pod/install.pod
===================================================================
--- doc/pod/install.pod	2015-04-23 19:07:39 UTC (rev 9831)
+++ doc/pod/install.pod	2015-05-01 09:11:23 UTC (rev 9832)
@@ -466,19 +466,54 @@
 
     make install
 
-Normally, you will need to run this command as root so that INN can create
-the directories it needs, change ownerships (if you did not compile as the
-news user) and install a setuid program needed to raise resource limits
-and allow B<innd> to bind to ports under 1024.  This step will install INN
-under the install directory (F</usr/local/news>, known as I<pathnews> in
-F<inn.conf>, unless you specified something else to the configure script).
+Under most circumstances, you will need to run the C<make install>
+command as root, so that INN can create the directories it needs,
+change ownerships (if you did not compile as the news user) and install
+a setuid program needed to raise resource limits and allow B<innd> to
+bind to ports under 1024.  This step will install INN under the install
+directory (F</usr/local/news>, known as I<pathnews> in F<inn.conf>,
+unless you specified something else to the configure script).
 
-Exceptionally, if you are installing INN into a directory writable by the
-news user, you can run C<make install> as the configured news user.  The
-resulting INN installation won't be able to use ports below 1024
+Exceptionally, if you are installing INN into a directory writable by
+the news user, you can run C<make install> as the configured news user.
+The resulting INN installation won't be able to use ports below 1024
 (including the default NNTP port of 119) unless you then run C<make
 install-root> as root, which will install only the setuid helper program.
 
+If you are building INN on a different system than the one on which it
+will eventually run, and you therefore want INN to install its files
+in a virtual root directory and not into the actual filesystem of the
+build machine, you can pass the virtual root directory to the install
+step via the DESTDIR variable.  You then just need to type:
+
+    make DESTDIR=/tmp/inn-root install
+
+In the above example, all of INN's directories and files would
+be installed under the F</tmp/inn-root> directory instead of
+the normal F</> (root) directory.  Just replace C</tmp/inn-root>
+with whatever directory you wish to install INN in (the result
+will be in F</tmp/inn-root/usr/local/news> if the default value of
+F</usr/local/news> for I<pathnews> has not been changed).  This won't
+affect any of the paths compiled into INN; it's used primarily in some
+situations like building a software distribution, where software has to
+be installed into some file system that will later be mounted as F</>
+on the final system.  Using DESTDIR permits to build INN, install
+it into a virtual root directory, and package the resulting files
+in a single step, without manual intervention, by a non-root user.
+It is possible to build and install INN in this way, but you must set
+a DESTDIR value for the install step, and additionally, you must tell
+the installation process that it should omit executing C<chown> and
+C<chgrp> commands (which will fail if the installation step is being
+executed by a non-root user).  To do this, type:
+
+    CHOWNPROG=set CHGRPPROG=set make DESTDIR=/tmp/inn-root install
+
+WARNING:  if you install INN in this manner, none of the resulting
+directories and files in the virtual root directory will be owned by
+the correct users and groups.  It is YOUR responsibility to ensure the
+resulting directories and files are packaged with the users, groups,
+and modes which INN wanted them to be installed with!
+
 Please note that INN's shared library interface is not stable and may
 change drastically in future releases.  For this reason, it's also not
 properly versioned and won't be until some degree of stability is
@@ -503,6 +538,10 @@
 
 as root in order to do this.
 
+You can also type C<make DESTDIR=/tmp/inn-root cert> as either root
+(preferred) or a non-root user.  All of the warnings and caveats
+mentioned above apply.
+
 You are now ready for the really fun part:  configuring your copy of INN!
 
 =head1 Choosing an Article Storage Format
@@ -1386,7 +1425,7 @@
 
     cd <pathdb in inn.conf>
     touch history
-    makedbz -i
+    makedbz -i -o
 
 (Note that if you install INN with C<make install>, you do not need to
 run these commands:  the installation takes care of creating the

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2015-04-23 19:07:39 UTC (rev 9831)
+++ doc/pod/news.pod	2015-05-01 09:11:23 UTC (rev 9832)
@@ -163,6 +163,17 @@
 
 =item *
 
+DESTDIR and non-root installs are now properly supported and documented
+in INSTALL.  The C<make install>, C<make update> and C<make cert>
+steps properly obey DESTDIR.  Besides, it is no longer a requirement
+that the installation step be done by the superuser, as long as the
+user executing the install has supplied a DESTDIR value that points
+to a writable directory, I<and> the person or process performing the
+install corrects the file ownerships when INN is installed on the system
+on which it's going to run.  Thanks to James Ralston for this support.
+
+=item *
+
 When building INN with S<Berkeley DB>, Cyrus SASL, S<Kerberos
 v5>, OpenSSL, or zlib support, no longer add standard locations to
 compiler and linker include flags.  Such default paths are now added

Modified: site/Makefile
===================================================================
--- site/Makefile	2015-04-23 19:07:39 UTC (rev 9831)
+++ site/Makefile	2015-05-01 09:11:23 UTC (rev 9832)
@@ -142,16 +142,25 @@
 $D$(PATH_NEWSGROUPS):	; $(CP_DATA) newsgroups.minimal $@
 $D$(PATH_ACTIVE_TIMES):
 	touch $@
-	chown $(RUNASUSER) $@
-	chgrp $(RUNASGROUP) $@
+	@ME=`$(WHOAMI)` ; \
+	if [ x"$$ME" = xroot ] ; then \
+	    chown $(RUNASUSER) $@ ; \
+	    chgrp $(RUNASGROUP) $@ ; \
+	fi
 	chmod $(FILEMODE) $@
 $D$(PATH_HISTORY):
 	touch $@
-	chown $(RUNASUSER) $@
-	chgrp $(RUNASGROUP) $@
+	@ME=`$(WHOAMI)` ; \
+	if [ x"$$ME" = xroot ] ; then \
+	    chown $(RUNASUSER) $@ ; \
+	    chgrp $(RUNASGROUP) $@ ; \
+	fi
 	chmod $(FILEMODE) $@
+	@ME=`$(WHOAMI)` ; \
 	if [ -z "$D" ] ; then \
-	    $(PATHBIN)/makedbz -i -o ; \
+	    if [ x"$$ME" = xroot ] || [ x"$$ME" = x"$(RUNASUSER)" ] ; then \
+	        $(PATHBIN)/makedbz -i -o ; \
+	    fi ; \
 	fi
 
 bootstrap:



More information about the inn-committers mailing list