RPM 打包 - RPM 中不包含 SOURCES 文件

RPM Packaging - No SOURCES files included in RPM

我有二进制文件,我想将其放在 /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。

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

要停止构建 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