【问题标题】:RPM Packaging - No SOURCES files included in RPMRPM 打包 - RPM 中不包含 SOURCES 文件
【发布时间】:2018-01-11 16:54:30
【问题描述】:

我有二进制文件,我想放在/etc/myapp/bin/app下

这是我的 SPECS/app.spec 文件

%define _topdir     /root/rpmbuild
%define name        my-app
%define release     2
%define version     2.1
%define buildroot   %{_topdir}/%{name}-%{version}

Name:           %{name}
Summary:        Sample Application
License:        Private
Version:        %{version}
Release:        %{release}
Group:          Applications/Tools
BuildArch:      x86_64
BuildRoot:      %{buildroot}
URL:            https://www.my-app.com
Source0:        %{_topdir}/SOURCES/%{name}-%{version}.tar.gz

%description
My App Desc

%prep
%setup -q

%build

%install
ls
cp etc/my-app/bin/app /etc/my-app/bin
cp etc/init.d/my-app /etc/init.d

chmod +x /etc/my-app/bin/app
chmod +x /etc/init.d/my-app


%files
%defattr(-,root,root)


%post
/etc/init.d/my-app start
/sbin/chkconfig --add /etc/my-app/bin/app


%preun
#last removal
service %{name} stop > /dev/null 2>&1
rm -rf /etc/my-app
rm -f /var/log/my-app
/sbin/chkconfig --del %{name}


%clean
rm -rf $RPM_BUILD_ROOT

%changelog
 # end mhash spec

然后我做

rpmbuild -ba /root/rpmbuild/SPEC/app.spec

这会构建 3 个文件

/root/rpmbuild/SRPMS/x86_64/my-app-2.1-2.src.rpm /root/rpmbuild/RPMS/x86_64/my-app-2.1-2.x86_64.rpm /root/rpmbuild/RPMS/x86_64/my-app-debuginfo-2.1-2.x86_64.rpm

.rpm 文件的大小仅为 4kb,而 src 包本身为 13MB。

我在这里错过了什么?我在这上面花了三天时间。任何凝胶都会受到高度评价。

【问题讨论】:

    标签: rpm rpmbuild rpm-spec


    【解决方案1】:

    要停止构建debuginfo 包,您需要在spec 文件的顶部使用以下语法,

      %define debug_package %{nil}
    

    spec 文件中有几个问题。您没有在安装部分使用%{buildroot}。

    %install
    # Create configuration directory for my-app
    %{__mkdir_p} -m 0755 %{buildroot}/etc/my-app
    
    # Use install that provides option for file permission
    install -m 755 etc/my-app/bin %{buildroot}/etc/my-app/bin
    install -m 644 etc/init.d/my-app %{buildroot}/etc/init.d/my-app
    

    确保包拥有它的文件,否则你会得到 rpm 构建错误。

    %files
    %defattr(-,root,root)
    %dir /etc/my-app
    /etc/my-app/bin
    /etc/init.d/my-app
    

    【讨论】:

    • 谢谢。我在同一天发现 %files 是空的。对我有用的是 %undefine _missing_build_ids_terminate_build 到 .spec 文件。感谢github.com/tpokorra/lbs-mono-fedora/issues/3
    • 很高兴知道。目录可能不会显示在检查中,因此请确保您的 pacakge 正确拥有该目录。
    • 是的。我正在为这些文件设置权限。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    相关资源
    最近更新 更多