Build RPM using source directory, not tarball

Solution 1:

This question is a bit old, but in case other people find it in search there is a more correct way to do this that does also allow the creation of an SRPM.

In the prep section, instead of using the setup macro, you should instead just type out yourself what you want it to do, namely copying the source directory from SOURCES to BUILD, instead of unpacking an archive. I found that you also then have to add a cd into your source directory in the build and install sections.

Example snippet

%prep
# Don't use the setup macro anymore, replace it with typed-out commands
#%setup -q -n myapp-%{version}
cd %{_topdir}/BUILD
rm -rf myapp-%{version}
cp -rf %{_topdir}/SOURCES/myapp-%{version} .
cd myapp-%{version}
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .

%patch1 -p1 -b .cert-config
%patch2

%build
cd myapp-%{version}

%install
cd myapp-%{version}

Solution 2:

Yes, you can do that. Do not list any Sources. In the %prep section do not use the %setup macro (which untars the source); rather, just check out the source.

Note that you will not be able to build SRPMs if you do this.

Tags:

Rpm