Difference between pages "Build rpm packages with the rpmbuild command" and "BAsh Operator"

From Linuxintro
(Difference between pages)
imported>ThorstenStaerk
 
imported>ThorstenStaerk
(Redirected page to Bash operators)
 
Line 1: Line 1:
This article is about how to [[build rpm packages]] with the rpmbuild command and a SPEC file. The example is based on SuSE 11.3 x86_64. However, other distributions should work same or similar.
+
#REDIRECT [[Bash operators]]
 
 
= The program =
 
Here is how we create our program, hello world:
 
<pre>
 
cd
 
mkdir hello
 
cd hello
 
cat >main.c <<EOF
 
#include <stdio.h>
 
 
 
int main()
 
{
 
  printf("hello world");
 
}
 
EOF
 
</pre>
 
 
 
= The Makefile =
 
To [[build]] our program, we need a [[makefile]]. Here is how we create it:
 
<pre>
 
cat >Makefile <<EOF
 
all:hello
 
 
 
hello: main.c
 
        gcc main.c -o hello
 
 
 
install: hello
 
        cp hello /usr/local/bin
 
EOF
 
sed -i "s/        /\t/g" Makefile
 
</pre>
 
 
 
= The SPEC file =
 
<pre>
 
cat >hello.spec<<EOF
 
Summary: hello greets the world
 
Name: hello
 
Version: 1.0
 
Release: 1
 
License: GPL
 
Group: Applications/Sound
 
Source: hello.tar.gz
 
URL: http://www.staerk.de/thorsten/
 
Distribution: SUSE Linux
 
Vendor: -
 
Packager: Thorsten Staerk
 
 
 
%description
 
hello greets the world
 
 
 
%prep
 
%setup
 
 
 
%build
 
make
 
 
 
%install
 
make install
 
mkdir -p /usr/src/packages/BUILDROOT/hello-1.0-1.x86_64/usr/local/bin
 
cp /usr/local/bin/hello $RPM_BUILD_ROOT/usr/local/bin/hello
 
 
 
%files
 
%defattr(-, root, root)
 
"/usr/local/bin/hello"
 
EOF
 
</pre>
 
 
 
= Build the rpm =
 
Now we have the SPEC file and the software. Build it with the command
 
rpmbuild -ba hello.spec
 
You will find your ready RPM under /usr/src/packages/RPMS.
 
 
 
= See also =
 
* http://www.linuxquestions.org/questions/linux-newbie-8/rpm-rebuild-unknown-option-348748/
 
* http://www.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html
 
* http://www.ceylonlinux.com/pdf/rpm_howto.pdf
 
* https://fedoraproject.org/wiki/A_Short_RPM_Tutorial
 
[[todo]]
 

Latest revision as of 06:28, 6 December 2012

Redirect to: