RPM - Using the Adempiere SRPM

From ADempiere
Revision as of 21:32, 22 September 2011 by Kkalice (Talk) (Created page with '<div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">Chapter 3. Using the Adempiere SRPM</th></tr><tr><td align="le…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.


Using the Adempiere SRPM

Installing the Source-RPM

Once your package building environment has been set up, you can download and unpack the Adempiere source RPM:

The source files will have been installed in ~/rpmbuild/SOURCES, and the specification file ("Spec" file) in ~/rpmbuild/SPECS/adempiere.spec

Configuring the Build Process

Build behavior is controlled by various parameters which are set at the beginning of the Spec File. See Appendix A for a detailed description.

Adding Customizations

Additional sources and patches can be added to the SOURCES directory to apply extensions and customizations to the Adempiere source code.

As new files are added, the SOURCES directory quickly gets very messy. For this reason, the files distributed with the Source-RPM are prefixed with sXXX_ (for sources) and pXXX_ (for patches), where XXX corresponds to the patch or source number in the Spec File. Users are encouraged to name their sources and patches following the same naming scheme.

Sources and patches must be listed in the Spec File using the Source<number>: filename and Patch<number>: filename pragmas.

Source and patch numbers 0-99 are reserved for the maintainer of the Adempiere source RPM, so you may add source files and patches starting with number 100.

…
…
# Sources
# -------

# standard sources
…
…

# your custom sources come here
# (start with number 100)
Source100:	s100_MMyModel.java
Source101:	s101_myScript.sh


# Patches
# -------

# standard patches
…
…

# your custom patches come here
# (start with number 100)
Patch100:	p100_myPatch1.patch
Patch101:	p101_myPatch2.patch
…
…
			

The sources and patches thus defined in the Spec File's preamble must be installed or applied in the %prep section, which is usually done with the install shell command and %patch macro.

…
…
%prep
…
…
	cd $rpmBuildDir/source/custom

# standard patches
# ----------------
…
…

# install your sources here
# -------------------------
install -pD -m0644 %{SOURCE100} base/src/org/adempiere/model/MMyModel.java
install -pD -m0755 %{SOURCE101} utils/myScript.sh

# apply your patches here
# -----------------------
%patch -P100 -p1
%patch -P101 -p1
…
…
			

The install command works like cp, with the addition that it will create all leading components in the path to the target file if they are missing (-D option), preserve the source file's timestamp (-p option), and set the permission mode of the target file (-m option).

The %patch macro invokes the patch command to apply patches to the source. The patch file number is specified with the -P (upper case P) option, and the -p (lower case p) option tells the patch command how many leading slashes and directories are to be omitted from filenames in the patch file. This will be explained in the next chapter.

For building Adempiere packages, the %patch macro has been extended to accept following additional parameters:

-F fuzz factor

Use the given fuzz factor

-d directory

change to directory before doing anything

-a filename

Apply patch only if filename exists.

If filename starts with a /, it describes an absolute path, otherwise it is relative to RPM_BUILD_DIR.

-x regular expression

requires -a.

Apply patch only if regular expression exists in filename.

If regular expression starts with a !, apply patch only if regular expression does not exist in filename.

Building the RPM packages

Packages are generated using the rpmbuild --sign -b… /path/to/adempiere.spec command, where the --sign option will sign the package using the gpg-signature we created earlier, and the stage up to which the packages are built is defined with the -b… switch:

-bp

build up to "prep" phase only, which means downloading the source and applying patches.

-bc

build up to "build" phase only, which means compiling the source.

-bi

build up to "install" phase only, the resulting files are installed in a directory structure as they would be on the target machine.

-bb

build binary packages (adempiere-….noarch.rpm, adempiere-server-….noarch.rpm, adempiere-client-….noarch.rpm).

-bs

build source package (adempiere-….srpm).

-ba

build all packages (both binary and source).

rpmbuild --sign -ba ~/rpmbuild/SPECS/adempiere.spec

The resulting RPM packages can be found in ~/rpmbuild/RPMS/noarch, and the source RPM in ~/rpmbuild/SRPMS.

When using --sign, rpmbuild will prompt you for a passphrase. Enter the same phrase which was used when the gpg key was generated.