【问题标题】:rpm subpackage is not created未创建 rpm 子包
【发布时间】:2014-08-13 11:24:34
【问题描述】:

我正在尝试创建 2 个 rpm 包,尽管第二个包要做的操作非常少。 我已经创建了这个规范文件:

%define name        @CPACK_PACKAGE_NAME@ 
%define version     @CPACK_PACKAGE_VERSION@
%define release     @CPACK_PACKAGE_RELEASE@
%define binarydir   @BINARY_DIR@ 
%define packagedir  @PACKAGE_DIR@ 


#component name - used for the rpm name
%{!?name:%{error:*** Name was not specified! ***}}

# passed as a parameter in the build - the release version 
# e.g OverhaulRelease.MajorRelease.MinorRelease
%{!?version:%{error:*** Version was not specified! ***}}

# passed as a parameter in the build - the 5 digit build number 
%{!?release:%{warn:*** Release was not specified, so Dev build ***} %define release 0}

## we need to redfine this here to avoid the pre-compilation of the python code
%define __os_install_post %{nil}

## disable RPM object stripping so the
## Qt GUI binaries don't get truncated
%define __strip /bin/true

# set up some commonly used variables
%define buildroot @CMAKE_BINARY_DIR@/_CPack_Packages/Linux/RPM/@CPACK_PACKAGE_FILE_NAME@
%define prefix %{name}
%define appdir /%{name}
%define _topdir @CMAKE_BINARY_DIR@/_CPack_Packages/Linux/RPM
%define _rpmdir @CMAKE_BINARY_DIR@/_CPack_Packages/Linux/RPM
%define _rpmfilename @CPACK_PACKAGE_FILE_NAME@.rpm
%define _unpackaged_files_terminate_build 0 



## Intro ##

Name:           %{name}
Version:        %{version}
Release:        %{release}
Vendor:         %{company}
URL:            %{url}
Packager:       %{company} 
License:        %{copyright}

# Define the other packages that this rpm depends on here
Requires:       bash

Provides:       %{name}


Summary:        %{name} %{version}_%{release}
Group:          Applications/Communications
BuildRoot:      %{buildroot}

%package -n @CPACK_PACKAGE_NAME@_run

## Intro ##

#Name:           %{name}
Version:        %{version}
Release:        %{release}
Vendor:         %{company}
URL:            %{url}
Packager:       %{company} 
License:        %{copyright}

# Define the other packages that this rpm depends on here
Requires:       bash

Provides:       %{name}

Summary:        %{name} %{version}_%{release}
Group:          Applications/Communications
BuildRoot:      %{buildroot}
#Icon:


%define _rpmfilename @CPACK_PACKAGE_FILE_NAME@_run.rpm

%description -n @CPACK_PACKAGE_NAME@_run

#%prep
#%build

######## clean ########
#%clean

######## pre-install ########
# Define any pre-install steps here
%pre -n @CPACK_PACKAGE_NAME@_run

######## install ########
%install -n @CPACK_PACKAGE_NAME@_run

# Make the required install directories
# there are made in the buildroot in the local repo,
# but translated when the rpm is installed - removing the buildroot


mkdir -p %{buildroot}%{opt_root}
mkdir -p %{buildroot}%{etc_root}
mkdir -p %{buildroot}%{var_root}


# Copy the required installed files to the buildroot dir to collect the 
# files required for installation
# Also, create any required symbolic links here

######## post-install ########
%post -n @CPACK_PACKAGE_NAME@_run

# Set up the symbolic version directory links
# This should eventually be moved to an enable rpm,
# But for now keep it as a single rpm
/bin/ln -s  %{opt_root} %{opt_link}
/bin/ln -s  %{etc_root} %{etc_link}
/bin/ln -s  %{var_root} %{var_link}

# Do other post install commands here, like starting the required process/services etc


######## pre-uninstall ########
%preun -n @CPACK_PACKAGE_NAME@_run

######## post-uninstall ########
%postun -n @CPACK_PACKAGE_NAME@_run

## FILES ##

# Define user attributes and permissions for files
# List the atcual files and paths as they will look on the installed server
# i.e. without the buildroot prefic

%files -n @CPACK_PACKAGE_NAME@_run

%dir %{opt_root}
%dir %{etc_root}
%dir %{var_root}



%package -n @CPACK_PACKAGE_NAME@_ena


#Name:           %{name}_ena
Version:        %{version}
Release:        %{release}
Vendor:         %{company}
URL:            %{url}
Packager:       %{company} 
License:        %{copyright}

# Define the other packages that this rpm depends on here
Requires:       bash

Provides:       %{name}

Summary:        %{name} %{version}_%{release}
Group:          Applications/Communications
BuildRoot:      %{buildroot}
#Icon:


%define _rpmfilename @CPACK_PACKAGE_FILE_NAME@_ena.rpm
%define _unpackaged_files_terminate_build 0 


%description -n @CPACK_PACKAGE_NAME@_ena

#%prep
#%build

######## clean ########
#%clean

######## pre-install ########
# Define any pre-install steps here
%pre -n @CPACK_PACKAGE_NAME@_ena

######## install ########
%install -n @CPACK_PACKAGE_NAME@_ena

mkdir -p %{buildroot}%{var_root}/output
cp    --sparse=never %{binarydir}/stub1 %{buildroot}%{opt_root}/bin/stub1
cp    --sparse=never %{binarydir}/stub2 %{buildroot}%{opt_root}/bin/stub2

######## post-install ########
%post -n @CPACK_PACKAGE_NAME@_ena

# Set up the symbolic version directory links
# This should eventually be moved to an enable rpm,
# But for now keep it as a single rpm
/bin/ln -s  %{opt_root} %{opt_link}
/bin/ln -s  %{etc_root} %{etc_link}
/bin/ln -s  %{var_root} %{var_link}

# Do other post install commands here, like starting the required process/services etc


######## pre-uninstall ########
%preun -n @CPACK_PACKAGE_NAME@_ena

######## post-uninstall ########
%postun -n @CPACK_PACKAGE_NAME@_ena


%files -n @CPACK_PACKAGE_NAME@_ena

所以我在这里有 2 个问题: 1. 这里只生成 2 个 rpm - 主包和第二个,我期待 3 个主包和 2 个子包 2. 在第二个子包中,如果我指定 %install 部分,rpm build 在第二个 %install 中会抛出错误。

很抱歉在这里发布详细的规范:但无法用几句话得到我的问题的确切答案 :)

我哪里错了?

【问题讨论】:

  • 我不认为%build%install 等获得每个包的版本。我相信你只有每个包%package%description%files。我也不相信%package/etc (除非自从我使用的版本以来这已经改变了)。接受-n 参数。
  • 原来是%package/etc。可以将-n 作为参数,所以我对那一点是错误的。但我仍然相信只有这几个部分是重复的子包而不是主要部分。
  • 感谢您的澄清,但如果我想要一些应该作为子包安装一部分的特定操作,我该如何添加它?
  • 构建时的具体操作?像什么?调试版本而不是发布版本?我不相信你能做到这一点(那个具体的例子就是-debug split-symbol 包的用途。
  • 操作我的意思是 mkdir/mv/cp 等等。

标签: rpm rpmbuild rpm-spec


【解决方案1】:

只创建了两个包,因为您只有两个 %files 指令。为您的规范文件中的每个不同的%files 指令创建一个包。我相信 Etan 在 cmets 中回答了您的其他问题。

【讨论】:

    猜你喜欢
    • 2015-09-12
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 2021-01-23
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多