【发布时间】: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。
我在这里错过了什么?我在这上面花了三天时间。任何凝胶都会受到高度评价。
【问题讨论】: