Making INN packaging easier in new 2.6.0 version

Julien ÉLIE julien at trigofacile.com
Sat Apr 25 19:40:01 UTC 2015


Dear packagers reading inn-workers,

Do you have any patch that could be included in upstream to ease
the packaging process of INN?

I have a pending patch to improve how the DESTDIR variable works and
how non-root installs can be done.  The patch is based upon a proposal
from James Ralston in 2001.
I have tested "make install", "make update" and "make cert" with:
- root and non-root user;
- DESTDIR and without;
- "CHOWNPROG=set CHGRPPROG=set" and without.

I reckon it works fine (at least, it can't be worse than before, where
install failed because of lack of rights when trying to run makedbz
or to perform chown/chgrp commands.



Below is the suggested patch for INN 2.6.0; if you have any comments
or wish to have a different behaviour, please tell!




Index: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	(révision 9830)
+++ doc/pod/news.pod	(copie de travail)
@@ -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
Index: doc/pod/install.pod
===================================================================
--- doc/pod/install.pod	(révision 9813)
+++ doc/pod/install.pod	(copie de travail)
@@ -466,19 +466,52 @@
 
     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
 (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 F</tmp/inn-root/>I<pathnews>.  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 +536,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
Index: Makefile.global.in
===================================================================
--- Makefile.global.in	(révision 9813)
+++ Makefile.global.in	(copie de travail)
@@ -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.
Index: Makefile
===================================================================
--- Makefile	(révision 9829)
+++ Makefile	(copie de travail)
@@ -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
Index: site/Makefile
===================================================================
--- site/Makefile	(révision 9829)
+++ site/Makefile	(copie de travail)
@@ -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:




Have a nice week-end,

-- 
Julien ÉLIE

« – Et souvenez-vous ! La seule chose que nous ayons à craindre,
    c'est que le ciel nous tombe sur la tête !
  – …Et souvenez-vous, Romains, la seule chose que nous ayons à
    craindre, c'est les Gaulois ! » (Astérix)


More information about the inn-workers mailing list