我正在编写一个非常简单的spec文件来安装文本文件(实际上是.repo文件)。这是spec文件
Name: dm_rpm_repos
Version: 1.0
Release: 0
Summary: custom repository file
Group: System Environment/Base
License: GPL
URL: http://internal
Source0: dm_rpm_repos-1.0.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-buildroot
%description
Internal use repository for internal RPMs
%prep
tar -zxvf %{_sourcedir}/dm_rpm_repos-1.0.tar.gz
%install
mkdir -p %{buildroot}
cp -R * %{buildroot}
%clean
rm -rf "$RPM_BUILD_ROOT"
%files
%defattr(-,root,root,-)
/etc/yum.repos.d/dm_rpm_repos.repo
这里使用this handy command是扩展文件内容
Name: dm_rpm_repos
Version: 1.0
Release: 0
Summary: custom repository file
Group: System Environment/Base
License: GPL
URL: http://internal
Source0: dm_rpm_repos-1.0.tar.gz
BuildArch: noarch
BuildRoot: /var/tmp/dm_rpm_repos-buildroot
%description
Internal use repository for internal RPMs
%prep
tar -zxvf /home/rpmbuild/rpmbuild/SOURCES/dm_rpm_repos-1.0.tar.gz
%install
mkdir -p /home/rpmbuild/rpmbuild/BUILDROOT/dm_rpm_repos-1.0-0.x86_64
cp -R * /home/rpmbuild/rpmbuild/BUILDROOT/dm_rpm_repos-1.0-0.x86_64
%clean
rm -rf "$RPM_BUILD_ROOT"
%files
%defattr(-,root,root,-)
/etc/yum.repos.d/dm_rpm_repos.repo
为什么目录rpmbuild
出现两次?它不应该。直接就是~/rpmbuild/...
。它正在寻找的.tar.gz
文件位于~/rpmbuild/SOURCES/
。我使用rpmdev-setuptree
创建了这个用户的rpm环境。最初,%prep
部分使用了宏%setup -p
。如果重要的话,该用户的.rpmmacros
文件的内容
%_topdir %(echo $HOME)/rpmbuild
%_smp_mflags %( \
[ -z "$RPM_BUILD_NCPUS" ] \\\
&& RPM_BUILD_NCPUS="`/usr/bin/nproc 2>/dev/null || \\\
/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
if [ "$RPM_BUILD_NCPUS" -gt 16 ]; then \\\
echo "-j16"; \\\
elif [ "$RPM_BUILD_NCPUS" -gt 3 ]; then \\\
echo "-j$RPM_BUILD_NCPUS"; \\\
else \\\
echo "-j3"; \\\
fi )
%__arch_install_post \
[ "%{buildarch}" = "noarch" ] || QA_CHECK_RPATHS=1 ; \
case "${QA_CHECK_RPATHS:-}" in [1yY]*) /usr/lib/rpm/check-rpaths ;; esac \
/usr/lib/rpm/check-buildroot