I am writing a very simple spec file to install a text file (a .repo file actually). Here is the spec file
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
Using this handy command here is the expanded file contents
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
Why is the directory rpmbuild
showing up twice? It should not be. The directly is simply ~/rpmbuild/...
. The .tar.gz
file it's looking for is in ~/rpmbuild/SOURCES/
. I made this user's rpm environment using rpmdev-setuptree
. Originally, the section %prep
used the macro %setup -p
. In case it's important, the contents of this user's .rpmmacros
file
%_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