commit dddaa6f031f85313a4b5057d58396d36c35f9b61
Author: Michael Simacek <msimacek(a)redhat.com>
Date: Mon Nov 25 12:51:09 2013 +0100
[doc] use Java example for minimal spec
Use example HelloWorld project from Introduction for packagers as the
project being packaged in example spec file in order to have something
more realistic with actual sources and build.
doc/introduction_for_developers.txt | 41 ++++++++++++++++++++------
doc/rpm_project/helloworld.spec | 54 +++++++++++++++++++++++++++++++++++
doc/rpm_project/minimal.spec | 44 ----------------------------
3 files changed, 86 insertions(+), 53 deletions(-)
---
diff --git a/doc/introduction_for_developers.txt b/doc/introduction_for_developers.txt
index c5b1f47..bed38f3 100644
--- a/doc/introduction_for_developers.txt
+++ b/doc/introduction_for_developers.txt
@@ -20,12 +20,32 @@ several reasons for it, among others:
that users or administrators can find useful
==== Example RPM Project
-RPM uses `spec` files as recipes for building software packages. A simple
-example of such spec file is below.
+RPM uses `spec` files as recipes for building software packages. We
+will use it to package example project created in previous section. If
+you didn't read it you don't need to; the file listing is available here
+and the rest is not necessary for this section.
+.Directory listing
+[source,shell]
+------
+Makefile
+src
+src/org
+src/org/fedoraproject
+src/org/fedoraproject/helloworld
+src/org/fedoraproject/helloworld/output
+src/org/fedoraproject/helloworld/output/Output.java
+src/org/fedoraproject/helloworld/input
+src/org/fedoraproject/helloworld/input/Input.java
+src/org/fedoraproject/helloworld/HelloWorld.java
+------
+
+We packed the project directory into file `helloworld.tar.gz`.
+
+.Example spec file
[source,spec,numbered]
------
-include::rpm_project/minimal.spec[]
+include::rpm_project/helloworld.spec[]
------
RPM `spec` files contain several basic sections:
@@ -40,18 +60,21 @@ RPM `spec` files contain several basic sections:
* %changelog containing RPM changelog with prescribed format used mostly to
document changes to spec file (not upstream)
-To build RPM from link:rpm_project/minimal.spec[this `spec` file] save it in
+To build RPM from link:rpm_project/helloworld.spec[this `spec` file] save it in
your current directory and run `rpmbuild`:
[source,shell]
------
-$ rpmbuild -bb minimal.spec
+$ rpmbuild -bb helloworld.spec
------
If everything worked OK, this should produce RPM file
-`~/rpmbuild/RPMS/x86_64/minimal-1.0-1.fc18.x86_64.rpm`. You can use `rpm` or
-`yum` commands to install this package and it will add `/bin/minimalistic` shell
-script to your system. Above `spec` file doesn't specify any build or runtime
-dependencies and lacks several other common parts for simplification.
+`~/rpmbuild/RPMS/x86_64/helloworld-1.0-1.fc18.x86_64.rpm`. You can use
+`rpm -i` or `yum localinstall` commands to install this package and it
+will add `/usr/share/java/helloworld.jar` and `/usr/bin/helloworld`
+wrapper script to your system. Above `spec` file doesn't specify any
+build or runtime dependencies and lacks several other common parts for
+simplification.
+
[NOTE]
======
Paths and filenames might be slightly different depending on your architecture
diff --git a/doc/rpm_project/helloworld.spec b/doc/rpm_project/helloworld.spec
new file mode 100644
index 0000000..be5f136
--- /dev/null
+++ b/doc/rpm_project/helloworld.spec
@@ -0,0 +1,54 @@
+# Comments start with hash sign
+# First part usually consists of metadata such as package name, version, and
+# much more
+Name: helloworld
+Version: 1.0
+Release: 1%{?dist}
+Summary: This is a minimal spec file example
+
+License: GPLv2+
+# Homepage URL of the project
+URL:
http://www.fedoraproject.org
+
+# Our source archive. %{name} expands to 'helloworld' so the resulting
+# tarball name would be 'helloworld.tar.gz'.
+Source0: %{name}.tar.gz
+
+# Packages that contain only architecture independent files, such as shell
+# scripts or regular Java programs (not JNI libraries), should be marked as
'noarch'
+BuildArch: noarch
+
+# Project's build time dependency. We don't really need JUnit, it just
+# serves as and example
+BuildRequires: junit
+
+%description
+Very short description since we have nothing to say.
+
+%prep
+# section for preparation of sources, applying patches
+# or other things which can be done before running the build
+# The macro setup is used to unpack sources
+%setup -q
+
+%build
+# Section for compiling and generally assembling the final pieces.
+# Our Makefile builds the project JAR file
+make {?_smp_flags}
+
+%install
+# Installation into directory prepared by RPM expressed as %{buildroot}
+install -p -m 644 helloworld.jar %{buildroot}%{_javadir}/helloworld.jar
+
+# We use macro %jpackage_script to generate wrapper script for our JAR
+# Will be explained in later sections
+%jpackage_script org.fedoraproject.helloworld.HelloWorld "" ""
%{name} helloworld true
+
+# List of files that this package installs on the system
+%files
+%{_javadir}/helloworld.jar
+%{_bindir}/helloworld
+
+%changelog
+* Tue Mar 19 2013 Stanislav Ochotnicky <sochotnicky(a)redhat.com> - 1.0-1
+- This is first version