Re: %files directive with relocation in %install

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

 



Wesley Leggette wrote:
> Bob Proulx wrote:
> >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

I will take that as a No, BuildRoot has not been set.

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

You really, really want to set BuildRoot: to some temporary imaging
location.  This is where you will install files into using the macro
%makeinstall.  When BuildRoot is set the %files section will
automatically use that base location and no spec file changes are
needed there.  If you are doing %install operations explicitly you
would use $RPM_BUILD_ROOT or %{_buildroot} to access that path.

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

Using rpath is Evil.  Strong opinions exist there and some (misguided)
people actually think rpash is a good thing.  But it truly makes your
binary completely unrelocatable.  In fact you can only really test it
by installing it!  Better to avoid it and simply install your
libraries a) either in standard places b) into places configured by
ld.so.conf or c) found with LD_LIBRARY_PATH.  Some enlightened distros
even have policies forbidding rpash.  (Okay, I will wait for the
flames to roll in on this one.  But I will probably ignore them.)

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

Mixing some files in /usr/local/bin and other files in /etc is not a
good idea.  If you are using /usr/local then I would not use /etc.
But in for a penny, in for a pound.  I would put all of the files in
the package managed locations of /usr/bin and /etc.  You are building
an rpm of the files.  Everything can be managed then.

> 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?

I think that may mean that you will need to use the -f option to
%files to dymacally create a list of files.  That works.

> >>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?

Oops.  Yes.  I should have caught that.  Inspect your rpm and you
should see /usr/local/bin listed in the files list.

  rpm -qpl foo-*.rpm

Better to avoid it.  Use %{_bindir} instead to push past it.

  %file
  %{_bindir}/*

Bob

_______________________________________________
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