DevHeads.net

How to install a mountpoint directory from an rpm?

Hi,

I need to install a directory (/afs) that will be a mountpoint that a systemd
service (also installed in the rpm) will mount upon.

What's the best way to encode this in the specfile?

I did have:

%files
/afs

but that doesn't upgrade correctly. Someone gave me another way to do it:

%post
%systemd_post afs.mount

# Create /afs directory if it doesn't exist
if [ ! -d /afs ]; then
mkdir /afs
chown root.root /afs
chmod 0755 /afs
[ -x /usr/sbin/restorecon ] && /usr/sbin/restorecon /afs
fi

%files
%ghost %dir /afs

but rpmlint complains about the chown:

kafs-client.x86_64: W: dangerous-command-in-%post chown

The git repo is here:

<a href="http://git.infradead.org/users/dhowells/kafs-client.git/shortlog/refs/heads/next" title="http://git.infradead.org/users/dhowells/kafs-client.git/shortlog/refs/heads/next">http://git.infradead.org/users/dhowells/kafs-client.git/shortlog/refs/he...</a>

The second patch from the top is the one that tries to fix the mountpoint dir
installation issue ("spec: Treat /afs special").

Thanks,
David

Comments

Re: How to install a mountpoint directory from an rpm?

By Robert Marcano at 04/30/2019 - 13:12

On 4/30/19 11:45 AM, David Howells wrote:
Just create it on your %install section

mkdir $RPM_BUILD_ROOT/afs

and continue adding the reference on the %files like:

%file
%dir /afs

Re: How to install a mountpoint directory from an rpm?

By Zbigniew =?utf-... at 04/30/2019 - 13:29

On Tue, Apr 30, 2019 at 01:12:43PM -0400, Robert Marcano wrote:
Nope. New top-level directories are a big thing and need FPC approval:
<a href="https://fedoraproject.org/w/index.php?title=Packaging:Guidelines&amp;oldid=528452#Filesystem_Layout" title="https://fedoraproject.org/w/index.php?title=Packaging:Guidelines&amp;oldid=528452#Filesystem_Layout">https://fedoraproject.org/w/index.php?title=Packaging:Guidelines&amp;oldid=5...</a>
(I can't find the text in the new guidelines, but the new guidelines don't
support searching, so finding anything is PITA, so I'll just assume that
this is still valid...)

Regarding the FPC approval: I don't think it should be granted. There
is no good reason to create a mount point like this under root. It should go
somewhere under /run or /var.

Zbyszek

Re: How to install a mountpoint directory from an rpm?

By Stephen John Smoogen at 04/30/2019 - 13:46

On Tue, 30 Apr 2019 at 13:30, Zbigniew Jędrzejewski-Szmek < ... at in dot waw.pl>
wrote: