在第二次安装rpm

时间:2017-07-25 22:04:06

标签: linux symlink rpmbuild

非常奇怪的是在这里唠叨。我正在建立一个rpm包,这是我的spec文件:

[root@localhost rpmbuild]# cat SPECS/generated.spec 
# The name of your package
Name: sotoolkit

# A short summary of your package
Summary: Toolkit

# The version of your package
Version: 1.5

# The release number of your package
Release: 1

#URL 
URL: https://github.blah blah blah 

# Any license you wish to list
License: GPLv2

# What group this RPM would typically reside in
Group: Development/Tools

# Who packaged this RPM
Packager: Me

# The build architecture of this RPM (noarch/x86_64/i386/etc)
Buildarch: noarch

# You generally should not need to mess with this setting
Buildroot: %{_tmppath}/%{name}

# Change this extension to change the compression level in your RPM
#  tar / tar.gz / tar.bz2
Source0: %{name}.tar.gz

# If you are having trouble building a package and need to disable
#  automatic dependency/provides checking, uncomment this:
AutoReqProv: no

# If this package has prerequisites, uncomment this line and
#  list them here - examples are already listed
#Requires: bash, python >= 2.7

# A more verbose description of your package
%description
Toolkit v.1.5

# You probably do not need to change this
%define debug_package %{nil}

%prep
%setup -q -c

%build

%install
rsync -a . %{buildroot}/
ln -sf /integration/scripts/sotoolkit1.5/start.sh /usr/bin/sotoolkit

%clean
rm -rf %{buildroot}

#%pre

#%post

#%preun

%postun
unlink /usr/bin/sotoolkit

#%trigger

#%triggerin

#%triggerun

%changelog
* Tue Jul 18 2017 L.Popovski <l.pop@blah.com> 
- 1.5-1 

%files
%attr(0644, root, root) "/README"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/changelog"
%attr(0644, root, root) "/integration/scripts/sotoolkit1.5/changelog/fixes1.5.txt"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/check_if_single_or_multinode.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/log"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/multinode"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/firmware_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/fm_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/fs_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/functions_multi"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/multinode/log_tools"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools/collectl_perf.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools/crashdump.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools/timediff.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/log_tools/vsp_collect.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/menu.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/node_tools.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/multinode/other_tools"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/other_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/other_tools/b6200_missing_cluster.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/other_tools/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/other_tools/relaxhw.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/other_tools/syscheck.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/sset_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/multinode/sys_tools.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/multinode/tmp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/replay_last_session.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/singlenode"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/firmware_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/fm_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/fs_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/functions_single"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/guideme.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/singlenode/log_tools"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/log_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/log_tools/crashdump.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/log_tools/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/menu.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/node_tools.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/singlenode/other_tools"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/other_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/other_tools/exp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/other_tools/relaxhw.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/other_tools/syscheck.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/sset_tools.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/singlenode/sys_tools.sh"
%attr(0755, root, root) %dir "/integration/scripts/sotoolkit1.5/singlenode/tmp"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/sotoolkit.sh"
%attr(0755, root, root) "/integration/scripts/sotoolkit1.5/start.sh"
%doc README

奇怪的是:

  1. 在第一次安装RPM时一切正常 - 在/ usr / bin中创建了符号链接
  2. 我卸载了该工具 - 一切正常
  3. 我尝试第二次安装,这次没有创建符号链接!很奇怪 !
  4. 如果我重建rpm并重新安装它 - 它运行正常,我卸载它并且它不会在第二次安装时创建符号链接。
  5. [root @ localhost rpmbuild] #rpm -e sotoolkit-1.5-1.noarch unlink:无法取消链接'/ usr / bin / sotoolkit':没有这样的文件或目录 警告:%postun(sotoolkit-1.5-1.noarch)scriptlet失败,退出状态1 [root @ localhost rpmbuild]#

    使用rpmlint

    检查时,没有发现rpm的错误或警告

    任何可能导致这种情况的想法?

1 个答案:

答案 0 :(得分:1)

我发现了问题:

在%install部分中,我做错了:

ln -sf /integration/scripts/sotoolkit1.5/start.sh /usr/bin/sotoolkit

然后在%postun我错误地做了:

unlink /usr/bin/sotoolkit

相反,正确的做法是在%install:

mkdir -p %{buildroot}/usr/bin/
ln -s /integration/scripts/sotoolkit1.5/start.sh %{buildroot}/usr/bin/sotoolkit

然后将链接添加到%files

/usr/bin/sotoolkit

%postun可以删除,因为符号链接是文件的一部分,如果卸载该工具,将删除。