diff mbox series

[iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd

Message ID 20240311165803.62431-1-mg@max.gautier.name (mailing list archive)
State Changes Requested
Delegated to: David Ahern
Headers show
Series [iproute2-next] Makefile: use systemd-tmpfiles to create /var/lib/arpd | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Max Gautier March 11, 2024, 4:57 p.m. UTC
Only apply on systemd systems (detected in the configure script).
The motivation is to build distributions packages without /var to go
towards stateless systems, see link below (TL;DR: provisionning anything
outside of /usr on boot).

The feature flag can be overridden on make invocation:
`make USE_TMPFILES_D=n DESTDIR=<install_loc> install`

Links: https://0pointer.net/blog/projects/stateless.html
---
 Makefile          |  8 +++++++-
 configure         | 14 ++++++++++++++
 etc/tmpfiles.conf |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 etc/tmpfiles.conf

Comments

Stephen Hemminger March 11, 2024, 7:40 p.m. UTC | #1
On Mon, 11 Mar 2024 17:57:27 +0100
Max Gautier <mg@max.gautier.name> wrote:

> Only apply on systemd systems (detected in the configure script).
> The motivation is to build distributions packages without /var to go
> towards stateless systems, see link below (TL;DR: provisionning anything
> outside of /usr on boot).
> 
> The feature flag can be overridden on make invocation:
> `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> 
> Links: https://0pointer.net/blog/projects/stateless.html

Why does arpd need such hand holding, it is rarely used, maybe should just not be built.
Max Gautier March 11, 2024, 10:28 p.m. UTC | #2
On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> On Mon, 11 Mar 2024 17:57:27 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > Only apply on systemd systems (detected in the configure script).
> > The motivation is to build distributions packages without /var to go
> > towards stateless systems, see link below (TL;DR: provisionning anything
> > outside of /usr on boot).
> > 
> > The feature flag can be overridden on make invocation:
> > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > 
> > Links: https://0pointer.net/blog/projects/stateless.html
> 
> Why does arpd need such hand holding, it is rarely used, maybe should just not be built.

The commit introducing the install of that directory is quite old

> commit e48f73d6a5e90d2f883e15ccedf4f53d26bb6e74
> Author: Olaf Rempel <razzor@kopf-tisch.de>
> Date:   Wed Nov 9 15:25:40 2005 +0100
> 
>     iproute2-2.6.14-051107: missing arpd directory
>     
>     arpd requires a directory (/var/lib/arpd/) to run.
>     see attached patch, which lets iproute create this directroy during install.

For the why, arpd.c, L.671:

dbase = dbopen(dbname, O_CREAT|O_RDWR, 0644, DB_HASH, NULL);
if (dbase == NULL) {
    perror("db_open");
    exit(-1);
}

You think arpd should create its directory itself if it does not exists
?
Stephen Hemminger March 12, 2024, 1:30 a.m. UTC | #3
On Mon, 11 Mar 2024 23:28:31 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> > On Mon, 11 Mar 2024 17:57:27 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > Only apply on systemd systems (detected in the configure script).
> > > The motivation is to build distributions packages without /var to go
> > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > outside of /usr on boot).
> > > 
> > > The feature flag can be overridden on make invocation:
> > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > 
> > > Links: https://0pointer.net/blog/projects/stateless.html  
> > 
> > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.  
> 
> The commit introducing the install of that directory is quite old

The problem is that build environment != runtime environment for embedded systems.
But arpd really is legacy/dead/rotting code at this point.
Max Gautier March 12, 2024, 8:22 a.m. UTC | #4
On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> On Mon, 11 Mar 2024 23:28:31 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:
> > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > Max Gautier <mg@max.gautier.name> wrote:
> > >   
> > > > Only apply on systemd systems (detected in the configure script).
> > > > The motivation is to build distributions packages without /var to go
> > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > outside of /usr on boot).
> > > > 
> > > > The feature flag can be overridden on make invocation:
> > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > 
> > > > Links: https://0pointer.net/blog/projects/stateless.html  
> > > 
> > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.  
> > 
> > The commit introducing the install of that directory is quite old
> 
> The problem is that build environment != runtime environment for embedded systems.

That's the same for anything detected by the configure script, right ?
Hence the override capability.

> But arpd really is legacy/dead/rotting code at this point.

Yeah I can see that, not touched since 2016 (mostly). You would rather
just drop it ?
Stephen Hemminger March 12, 2024, 9:24 p.m. UTC | #5
On Tue, 12 Mar 2024 09:22:20 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> > On Mon, 11 Mar 2024 23:28:31 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:  
> > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > Max Gautier <mg@max.gautier.name> wrote:
> > > >     
> > > > > Only apply on systemd systems (detected in the configure script).
> > > > > The motivation is to build distributions packages without /var to go
> > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > outside of /usr on boot).
> > > > > 
> > > > > The feature flag can be overridden on make invocation:
> > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > 
> > > > > Links: https://0pointer.net/blog/projects/stateless.html    
> > > > 
> > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.    
> > > 
> > > The commit introducing the install of that directory is quite old  
> > 
> > The problem is that build environment != runtime environment for embedded systems.  
> 
> That's the same for anything detected by the configure script, right ?
> Hence the override capability.

Configure is mostly about what packages are missing from the build.
It would be better if arpd was just smarter about where to put its
file.

> 
> > But arpd really is legacy/dead/rotting code at this point.  
> 
> Yeah I can see that, not touched since 2016 (mostly). You would rather
> just drop it ?
>
Max Gautier March 12, 2024, 9:34 p.m. UTC | #6
On Tue, Mar 12, 2024 at 02:24:20PM -0700, Stephen Hemminger wrote:
> On Tue, 12 Mar 2024 09:22:20 +0100
> Max Gautier <mg@max.gautier.name> wrote:
> 
> > On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:
> > > On Mon, 11 Mar 2024 23:28:31 +0100
> > > Max Gautier <mg@max.gautier.name> wrote:
> > >   
> > > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:  
> > > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > >     
> > > > > > Only apply on systemd systems (detected in the configure script).
> > > > > > The motivation is to build distributions packages without /var to go
> > > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > > outside of /usr on boot).
> > > > > > 
> > > > > > The feature flag can be overridden on make invocation:
> > > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > > 
> > > > > > Links: https://0pointer.net/blog/projects/stateless.html    
> > > > > 
> > > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.    
> > > > 
> > > > The commit introducing the install of that directory is quite old  
> > > 
> > > The problem is that build environment != runtime environment for embedded systems.  
> > 
> > That's the same for anything detected by the configure script, right ?
> > Hence the override capability.
> 
> Configure is mostly about what packages are missing from the build.
> It would be better if arpd was just smarter about where to put its
> file.

What do you mean by smarter ? Trying to found an existing directory
rather than a fixed one ?

> 
> > 
> > > But arpd really is legacy/dead/rotting code at this point.  
> > 
> > Yeah I can see that, not touched since 2016 (mostly). You would rather
> > just drop it ?
> > 
>
Stephen Hemminger March 12, 2024, 10:19 p.m. UTC | #7
On Tue, 12 Mar 2024 22:34:59 +0100
Max Gautier <mg@max.gautier.name> wrote:

> On Tue, Mar 12, 2024 at 02:24:20PM -0700, Stephen Hemminger wrote:
> > On Tue, 12 Mar 2024 09:22:20 +0100
> > Max Gautier <mg@max.gautier.name> wrote:
> >   
> > > On Mon, Mar 11, 2024 at 06:30:07PM -0700, Stephen Hemminger wrote:  
> > > > On Mon, 11 Mar 2024 23:28:31 +0100
> > > > Max Gautier <mg@max.gautier.name> wrote:
> > > >     
> > > > > On Mon, Mar 11, 2024 at 12:40:03PM -0700, Stephen Hemminger wrote:    
> > > > > > On Mon, 11 Mar 2024 17:57:27 +0100
> > > > > > Max Gautier <mg@max.gautier.name> wrote:
> > > > > >       
> > > > > > > Only apply on systemd systems (detected in the configure script).
> > > > > > > The motivation is to build distributions packages without /var to go
> > > > > > > towards stateless systems, see link below (TL;DR: provisionning anything
> > > > > > > outside of /usr on boot).
> > > > > > > 
> > > > > > > The feature flag can be overridden on make invocation:
> > > > > > > `make USE_TMPFILES_D=n DESTDIR=<install_loc> install`
> > > > > > > 
> > > > > > > Links: https://0pointer.net/blog/projects/stateless.html      
> > > > > > 
> > > > > > Why does arpd need such hand holding, it is rarely used, maybe should just not be built.      
> > > > > 
> > > > > The commit introducing the install of that directory is quite old    
> > > > 
> > > > The problem is that build environment != runtime environment for embedded systems.    
> > > 
> > > That's the same for anything detected by the configure script, right ?
> > > Hence the override capability.  
> > 
> > Configure is mostly about what packages are missing from the build.
> > It would be better if arpd was just smarter about where to put its
> > file.  
> 
> What do you mean by smarter ? Trying to found an existing directory
> rather than a fixed one ?
> 

Isn't there some environment variable that systemd uses to tell a service
where to put its files? If that is present use that.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 8024d45e..8ce69a35 100644
--- a/Makefile
+++ b/Makefile
@@ -101,10 +101,16 @@  config.mk:
 		sh configure $(KERNEL_INCLUDE); \
 	fi
 
+ifeq ($(USE_TMPFILES_D),y)
+INSTALL_ARPDDIR := install -m 0644 -D etc/tmpfiles.conf $(DESTDIR)$(TMPFILESDIR)/iproute2-arpd.conf
+else
+INSTALL_ARPDDIR := install -m 0755 -d $(DESTDIR)$(ARPDDIR)
+endif
+
 install: all
 	install -m 0755 -d $(DESTDIR)$(SBINDIR)
 	install -m 0755 -d $(DESTDIR)$(CONF_USR_DIR)
-	install -m 0755 -d $(DESTDIR)$(ARPDDIR)
+	$(INSTALL_ARPDDIR)
 	install -m 0755 -d $(DESTDIR)$(HDRDIR)
 	@for i in $(SUBDIRS);  do $(MAKE) -C $$i install; done
 	install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONF_USR_DIR)
diff --git a/configure b/configure
index 928048b3..2e974e75 100755
--- a/configure
+++ b/configure
@@ -432,6 +432,17 @@  check_cap()
 	fi
 }
 
+check_tmpfiles_d()
+{
+    if ${PKG_CONFIG} systemd --exists; then
+        echo "USE_TMPFILES_D ?= y" >>$CONFIG
+        echo "yes"
+        echo 'TMPFILESDIR ?=' "$(${PKG_CONFIG} systemd --variable=tmpfilesdir)" >> $CONFIG
+	else
+		echo "no"
+	fi
+}
+
 check_color()
 {
 	case "$COLOR" in
@@ -615,6 +626,9 @@  check_cap
 echo -n "color output: "
 check_color
 
+echo -n "systemd tmpfiles: "
+check_tmpfiles_d
+
 echo >> $CONFIG
 echo "%.o: %.c" >> $CONFIG
 echo '	$(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG
diff --git a/etc/tmpfiles.conf b/etc/tmpfiles.conf
new file mode 100644
index 00000000..39c6d13c
--- /dev/null
+++ b/etc/tmpfiles.conf
@@ -0,0 +1 @@ 
+d %S/arpd 0755