
Instructions for creating redhat rpms from the XAMSDK zip.
----------------------------------------------------------

IMPORTANT NOTES
---------------
1. you should NEVER build rpm packages when logged in as root. 
If you are reading this document, it is assumed that you have unzipped
the original archive, and have a copy of the zip file somewhere in your
home directory.
2. The publically available zipfile does not ship with 3rd party jar files
required for some the Java_Reference_VIM and the HTTP_Protocol_VIM. 
Refer to the instructions in the relevant README files and copy the required jar
files to ./lib and HTTP_Protocol_VIM/lib as detailed therein.
3. The spec file is regenerated as part of the ant build process.
Please make edits to sniaxam.spec.template to ensure your changes
are propagated to the package build process.

Building from the SNIA distributed zip file
-------------------------------------------

A. Preparation
--------------

1. Login as a non-root user, and copy the XAMSDK.zip to this users home directory.

2. Unzip the file to a scratch area:

unzip -d scratch<zip file>.zip
Patch your tree witht eh third party zip files as noted above.

3. Optional. You may wish to verify that the sources build at this stage, however, you will need a pristine (i.e. free of build artifacts) set of sources for the next step.
Ensure that you clean each subdirectory, or create a second scratch area, patched with
the dependencies as above.

B. BUILDING USING ANT
---------------------

1. Ensure you have patched, pristine sources as noted above.

2. Change directory to the root of the soucre tree/

3. Run the follwing command;

ant -f pkg/Linux/rpm/buildrpm.xml

4. This should create the build sandbox, and build the roms, delivering
them to the directory pkg/Linux/rpm.

C. BUILDING RPMS BY HAND
------------------------

1. Create an rpm build sandbox. In this example ~/rpmbuild is used as the base directory.

2. Create ~/.rpmmacros file if one does not already exist containing the following:
	%_topdir	%(echo $HOME)/rpmbuild
	%debug_package %{nil}
	
3. Create the sandbox directories:

mkdir -p rpmbuild/BUILD rpmbuild/RPMS/i386 rpmbuild/RPMS/i586 rpmbuild/RPMS/i686 rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/SRPMS

for 32 bit platfforms, or

mkdir -p rpmbuild/BUILD rpmbuild/RPMS/ia64 rpmbuild/RPMS/x86_64 rpmbuild/SOURCES rpmbuild/SPECS rpmbuild/SRPMS

for 64 bit platforms.


4. Test your setup:
rpm --eval %_topdir
should return $(HOME)/rpmbuild

5. In the directory containing the original zip file, run the following commands:

unzip -d xamsdk-1.0.0 <zip file>.zip

Patch the build tree with the required .jar dependencies,
as noted above.

TOPDIR=rpm --eval %_topdir
tar cvfz $(TOPDIR)/SOURCES/xamsdk-1.0.0.tar.gz xamsdk-1.0.0

cp xamsdk-1.0.0/pkg/Linux/rpm/xamsdk.spec $(TOPDIR)/SPECS/xamsdk.spec

# optionally
rm -rf xamsdk-1.0.0

6. cd $TOPDIR/SPECS

7. rpmbuild <opts> xamsdk.spec

rpmbuild -bs xamsdk.spec # to build source rpm
rpmbuild -bb xamsdk.spec # to build binary rpm
or
rpmbuild -ba xamsdk.spec # to build both source and binary rpms.

8. If successful, the rpms are created in SRPMS and RPMS/* respectively.

9. The source rpm can be converted to a binary package with

rpmbuild --rebuild xamsdk.spec

10. If you wish to inspect the sources, or build them manually, install the source
rpm (this will not be registered in the rpm database):

rpm -ivh xamsdk-1.0.0-2.src.rpm

This will deposit the source tar.gz in $TOPDIR/SOURCES.


