Reputation: 407
I have a spec file to build an rpm package, in my %install section I have this:
%install
install -m 700 foo/bar/filesToCopy/. $RPM_BUILD_ROOT/
The filesToCopy folder is a tree exactly how the package file tree should look like. It has all the sub directories a package has such as etc/..., /usr/bin, /usr/share ..., and subsquent files in those.
When building it gives me
install: omitting directory 'foo/bar/filesToCopy/'
error: Bad exit status from /var/tmp/rpm-tmp.sea6XO (%install)
Is there a way I dont have to copy each file individuallly like this:
install -m 700 foo/bar/filesToCopy/usr/bin/file1.ex $RPM_BUILD_ROOT/usr/bin/
...
As everything in filesToCopy/ is the structure as in $RPM_BUILD_ROOT/
UPDATE
I found a solution, I changed the "install -m 700" to a "cp -a"
Upvotes: 8
Views: 6660
Reputation: 30575
It looks like the %install
section is just a shell script.
Try using cp
instead of install
.
%install
cp -a foo/bar/filesToCopy/* $RPM_BUILD_ROOT/
Or, for copying individual directories wholesale:
%install
mkdir -p $RPM_BUILD_ROOT/usr
cp -a foo/bar/filesToCopy/usr/bin $RPM_BUILD_ROOT/usr/
This will preserve permissions from the filesToCopy
directory. If those files are chmod 0755
, they'll be 0755
in the output directory. Same with if they're 0644
— they'll be copied as 0644
. It'll also preserve timestamps and user ownership.*
In my experience, 99.99% of the time, make install
assumes you're installing system programs, so install to the build jail with correct permissions. It's unlikely you'll need a step after this to fix the permissions.
I'd really only use install
if you weren't sure about what the state of the files' permissions are, and must make manual corrections to them on a file-by-file basis.
* cp -a
— short for cp --preserve=all
— will also preserve hard-linked files (if they're copied in the same cp
invocation), character device nodes, FIFOs, sockets, symbolic links, etc. It'll also copy file attributes, ACLs, and SELinux security contexts (IIRC) from the source files to the destination files. Without -a
, cp
can sometimes turn symbolic links into files. User ownership is only copied if possible (i.e. you're root
and can chown
), and silently ignored otherwise.
Upvotes: 0