gpt4 book ai didi

linux - 第二次安装 rpm 时未创建符号链接(symbolic link)

转载 作者:太空狗 更新时间:2023-10-29 12:24:44 26 4
gpt4 key购买 nike

这里有一些非常奇怪的东西。我正在构建一个 rpm 包,这是我的规范文件:

[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 中创建符号链接(symbolic link)
  2. 我卸载了该工具——一切都恢复正常了
  3. 我尝试第二次安装,但这次没有创建符号链接(symbolic link)!很奇怪 !
  4. 如果我重建 rpm 并再次安装它——它工作得很好,我卸载它并且再次安装它不会在第二次安装时创建符号链接(symbolic link)。

[root@localhost rpmbuild]# rpm -e sotoolkit-1.5-1.noarch取消链接:无法取消链接“/usr/bin/sotoolkit”:没有那个文件或目录警告:%postun(sotoolkit-1.5-1.noarch) scriptlet 失败,退出状态 1[root@localhost rpmbuild]#

使用 rpmlint 检查时没有发现 rpm 的错误或警告

有什么想法会导致这种情况吗?

最佳答案

我发现了问题:

在 %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 可以删除,因为符号链接(symbolic link)是文件的一部分,如果卸载该工具,它将被删除。

关于linux - 第二次安装 rpm 时未创建符号链接(symbolic link),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45314273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com