Re: %files directive with relocation in %install

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bob Proulx wrote:
Wesley Leggette wrote:

I have the following setup in the binary tarball I use with rpmbuild:

/usr/local/bin/foo
/usr/local/lib/libfoo.so
/usr/local/etc/init.d/foo
/usr/local/etc/foo/foo.conf

In the spec file I have:

What is your BuildRoot: set to?  Hopefully it is set to something
similar to:

  BuildRoot: %{_tmppath}/%{name}-%{version}-build

Well, I have the following in .rpmmacros:

%_topdir    @RPMBUILDDIR@       <-- set by Makefile to staging directory
%_builddir  %{_topdir}/build
%_rpmdir    %{_topdir}/rpms
%_sourcedir %{_topdir}/sources
%_specdir   %{_sourcedir}
%_srcrpmdir %{_topdir}/srpms
%_tmppath   %{_topdir}/tmp


Because if not then you will be packaging files from your live
filesystem and installing to your live filesystem neither of which are
good.

Prefix: /usr/local

Is your package really relocatable?  Can I relocate the installation
to a new prefix without making any other changes to your files?  Few
packages handle that correctly.  If so then Prefix: is appropriate.
If not then probably defining _prefix is better.

  %define _prefix /usr/local

Okay, that seems like a good idea. My package is (probably) not relocatable. I set rpaths in the libraries and binaries.



In which case change prefix to _prefix throughout the file.

  s/%{prefix}/%{_prefix}/g

%install

if test -d %{buildroot}%{prefix}/etc
  mkdir -p %{buildroot}/etc
  mv %{buildroot}%{prefix}/etc/* %{buildroot}/etc/
  rm -rf %{buildroot}%{prefix}/etc
fi

Extra persnickety here because that looks pretty good.  But I would be
slightly, slightly safer and change the rm -rf there to rmdir.  You
have already moved all of the files so an rmdir should pass.  But
really you should be able to simply move the directory.

  if test -d %{buildroot}%{prefix}/etc
    mv %{buildroot}%{prefix}/etc %{buildroot}/
  fi

Cool.



%files
%{prefix}/*
%config /etc/foo/foo.conf

Will such a setup work?

I think it should work.

Okay. But since that references files *after* %install, should I instead do this:

%file
%{_prefix}/*
/etc/*
%config /etc/foo/foo.conf


Also, I should mention that I am attempting to use this same spec file for multiple configurations, some of which do not contain any files that go in /etc. Will including '/etc/*' in the %files section cause any problems if there are actually no files there?



On the other hand, can I do this:

%files
/*
%config /etc/foo/foo.conf

That would package up the /usr and /usr/local and /usr/local/bin
etc. directories and make them owned by your package.  That would be a
bad thing.  (Just the directories without the other contents.  But
just the same they should not be owned by your package.)

Does that mean that (given the first example) /usr/local/bin is owned by my package?


Wesley

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux