Tommie Jones
Tommie Jones

Reputation: 1011

rpmbuild %install section removes buildroot code. How do I keep rpmbuild from doing this

I am creating a new rpm for a rails app. However the default behavior of the %install section removes the BUILDROOT directory. I assumed that the %install section would install the files from buildroot. I must be doing something wrong because the buildroot is getting removed in the %install section. What is the proper way to do this?

This is the spec file

Summary: Rails APP API (replaces railsapp rpm)
Name: railsapp-api
Version: 6.0.0
Release: 1
License: GPL
URL: http://www.both.org
Group: System
Packager: Tommie Jones
Requires: bash
BuildRoot: ~/rpmbuild/
%description

A rewrite of railsapp from the HTML version to a Http API version

%prep
        echo "BUILDROOT = $RPM_BUILD_ROOT"
        rm -rf $RPM_BUILD_ROOT
        mkdir -p $RPM_BUILD_ROOT/usr/local/veex/railsapp
        unzip /home/realworx/rpmbuild/SOURCES/rwx-master.zip -d $RPM_BUILD_ROOT/usr/local/veex/
        pushd $RPM_BUILD_ROOT/usr/local/veex/
        rm -rf railsapp
        mv rwx-master railsapp
        pushd $RPM_BUILD_ROOT/usr/local/veex/railsapp
        rm Gemfile.lock
        bundle install
        PWD=`pwd`
        cat > gemrc <<EOGEMRC
gemhome: $PWD/vendor/bundle/ruby/1.8
gempath:
- $PWD/vendor/bundle/ruby/1.8
EOGEMRC
        gem --config-file ./gemrc install bundler
        # Don't need the gemrc any more...
        rm ./gemrc


%files
%attr(0744, root, root) /usr/local/veex/railsapp/*
%install
echo %{buildroot}
echo "HELLO"

%clean
echo NOOP

Below is the log where the %install removes the buildroot.

 (%install): /bin/sh -e /var/tmp/rpm-tmp.aX3U0b
    + umask 022
    + cd /home/railsapp-api/rpmbuild/BUILD
    + '[' /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch '!=' / ']'
    + rm -rf /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
    ++ dirname /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
    + mkdir -p /home/railsapp-api/rpmbuild/BUILDROOT
    + mkdir /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
    + echo /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
    /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch
    + echo HELLO
    HELLO
    + /usr/lib/rpm/check-buildroot
    + /usr/lib/rpm/redhat/brp-ldconfig
    /sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
    + /usr/lib/rpm/brp-compress
    + /usr/lib/rpm/brp-strip /usr/bin/strip
    + /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
    + /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
    + /usr/lib/rpm/brp-python-bytecompile 1
    + /usr/lib/rpm/brp-python-hardlink
    + PYTHON3=/usr/libexec/platform-python
    + /usr/lib/rpm/redhat/brp-mangle-shebangs
    Processing files: railsapp-api-6.0.0-1.noarch
    error: File not found: /home/railsapp-api/rpmbuild/BUILDROOT/railsapp-api-6.0.0-1.noarch/usr/local/veex/railsapp/*

How do I keep %install from removing my buildroot?

Upvotes: 0

Views: 1409

Answers (1)

Chris Maes
Chris Maes

Reputation: 37752

you are misusing the %prep section. In very short how you should use those sections:

  • %prep: to extract your sources, apply patches etc.
  • %build: to compile or build your application (if you need to)
  • %install: to copy the files into $RPM_BUILD_ROOT

So it is logical that $RPM_BUILD_ROOT is emptied at the start of the %isntall section.

Change your code to extract your zip file in %prep, and use the %install section to put the files inside $RPM_BUILD_ROOT.

Upvotes: 2

Related Questions