Re: %files directive with relocation in %install

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

 



Wesley Leggette wrote:
> Do the files listed with %files refer to files before %install is run, 
> or after?

After.  It refers to files in the buildroot image location.

> 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

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

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

> %files
> %{prefix}/*
> %config /etc/foo/foo.conf
> 
> Will such a setup work?

I think it should work.

> 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.)

After you build your package you should inspect it with rpm and
determine that all of the contents are the contents that you want in
your package.  Nothing more and nothing less.

  rpm -qpl package-*.rpm
  rpm -qplv package-*.rpm

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