我想在/etc/myapp/bin/app
%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
/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。
答案 0 :(得分: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