RPM打包 - RPM

时间:2018-01-11 16:54:30

标签: rpm rpmbuild rpm-spec

我想在/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。

我在这里想念的是什么?我已经花了三天时间......任何凝胶都会受到高度关注。

1 个答案:

答案 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