RPM build fails on install section

2019-07-29 22:00发布

I am trying to build my first rpm package, which is one simple executable (mysh).

My spec file:

Summary: bla <br>
Name: mysh <br>
Version: 1.0 <br>
Release: 1 <br>
Group: Applications <br>
Source: mysh-1.0.tar.gz <br>
URL: http://www.google.com <br>
Vendor: tadas sofware inc. <br>
Packager: tadas <br>
License: GPL 

%description <br>
a very good program!

%prep <br>
rm -rf $RPM_BUILD_DIR/mysh-1.0 <br>
zcat $RPM_SOURCE_DIR/mysh-1.0.tar.gz | tar -xvf -

%build <br>
make 

%install <br>
cp mysh /usr/local/bin/mysh

%files <br>
/usr/local/bin/mysh

It fails with the following error:

cd: 8: can't cd to /home/tadzys/rpm/BUILDROOT/mysh-1.0-1.x86_64

Of course this file doesn't exist there. I've tried copying it there still there same error. Not sure if my install section should put anything to BUILDROOT folder.

I am on Ubuntu 11.04.

1条回答
虎瘦雄心在
2楼-- · 2019-07-29 22:05

When you refer to directories in the target machine within the %install section, you need to reference everything relative to $RPM_BUILD_ROOT (or %{buildroot}):

%install
cp mysh $RPM_BUILD_ROOT/usr/local/bin/mysh

The %files section does not need to be updated, however.

Also, you should consider using the install command when copying files around. It's similar to cp, but install allows you to set the permission bits for the target file:

%install
install -m 755 mysh $RPM_BUILD_ROOT/usr/local/bin/mysh
查看更多
登录 后发表回答