1

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
Community
  • 1
  • 1
Andrew Falanga
  • 2,274
  • 4
  • 26
  • 51
  • What does `rpm -E $'_sourcedir: %{_sourcedir}\nbuildroot: %{buildroot}` output for that user? – Etan Reisner May 14 '15 at 18:44
  • Also as you may have noticed your `BuildRoot` line isn't doing anything (you don't need to specify it anymore on CentOS 6+). And you should be using `%{SOURCE0}` for the source archive instead of find the path to it yourself. – Etan Reisner May 14 '15 at 18:45
  • @EtanReisner you have one `'` in the command you asked me to do. Is that intentional? – Andrew Falanga May 14 '15 at 19:03
  • No, sorry. Close the single quoted string at the end of the command. – Etan Reisner May 14 '15 at 19:04
  • 1
    @EtanReisner Thanks. I have updated my spec file as you indicate. I also know the reason for *rpmbuild* showing twice. It is my own silliness. The path is fine. I named this user *rpmbuild*: very stupid. I'm grateful for your `rpm -E` command. That was a new one for me and, for some reason, made it apparent why the path was like that. The path truly is `/home/rpmbuild/rpmbuild/SOURCES/...`. I'll probably be deleting this question. – Andrew Falanga May 14 '15 at 19:13
  • Hah. I should have noticed that too. =) – Etan Reisner May 14 '15 at 19:14

0 Answers0