简体   繁体   中英

How to install a symlink within an rpm spec file

I've read through several other questions related to this issue, and I can't find a direct answer to my issue. I have to install several symlinks to /etc that point to files I am installing in /opt/myapp, so I need my files to look like this:

/etc/sysconfig/myapp -> /opt/myapp/etc/sysconfig/myapp

Right now my spec file looks like this:

%install
ln -sf %{buildroot}/etc/sysconfig/myapp /opt/myapp/etc/sysconfig/myapp

%files
%attr(0644, root, root) "/etc/sysconfig/myapp"
%dir %attr(0755, root, root) "/opt/myapp/etc/sysconfig"
%config(noreplace) %attr(0644, root, root) "/opt/myapp/etc/sysconfig/myapp"

When I run rpmbuild , I get this:

ln: failed to create symbolic link '/opt/myapp/etc/sysconfig/myapp': No such file or directory

I know this directory does not exist. It gets installed by the %files section, so how do I avoid this error here?

ln takes the target first , so it should be ln -sf /opt/myapp/etc/sysconfig/myapp %{buildroot}/etc/sysconfig/myapp

  • -s to make it a symlink
  • -f because /opt/myapp/etc/sysconfig/myapp doesn't need to exist on the build system

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM