You can view this document as one long file by clicking here.
The Ape Base Compile System is a set of bash scripts to leverage both ESP EPM (http://www.epmhome.org/) and MREPO (http://dag.wieers.com/home-made/mrepo/) in maintaining Red Hat based systems that require custom and secluded binaries. If you need "Ape" to be an acronym, then go for "Application Packaging Environment" as christened by Mark Stokan. The original notion for the name was that this system was "aping" the performance of several tasks.
Since there's a lot of information to cover here, some explanation conventions will be handy.
Commonly, `ls` is the file listing command.
[root@localhost:/ape/_compile]$ echo 'This is a shell prompt - bash, sh, csh, cygwin, etc...' This is a shell prompt - bash, sh, csh, cygwin, etc... [root@localhost:/ape/_compile]$ |
[root@localhost:/ape/_compile]$ |Thus the command...
[root@localhost:/ape/_compile]$ ls -ld ./src drwxr-xr-x 14 root root 4096 Mar 15 02:17 ./src [root@localhost:/ape/_compile]$ |Is functionally the equivalent of the command...
[root@localhost:~]$ ls -ld /ape/_compile/src drwxr-xr-x 14 root root 4096 Mar 15 02:17 /ape/_compile/src [root@localhost:~]$ |This convention only applies to *nix shell prompts.
#!/bin/bash
# this will set a variable for use later in compile
export THIS_IS_A_VAR='value'
Relative paths should never be used in scripts or other files unless instructed to do so.
Using Ape User Configuration Variables and Ape Internal System Variables is the preffered method of substituting directory names inside scripts and files.
In order to install Ape Base Compile System via the RPM, you will need these things. If you installed another way that doesn't support dependancies, you should gather and install these tools. In addition to them, there are some optional things that may make usage easier.
It should be noted that you don't need to start a bash prompt per se to run Ape Base Compile System. The scripts run it internally via their shebang.
Other POSIX style shells, such as Bourne, can be used but Bash itself is a requirement of installing the RPM. You are, however, on your own. Substituting the shell is unsupported until further notice. If you wish to substitute shells, you have two options. First, you may pass your script at a shell prompt (`/bin/sh ./scripts/foo-1.0.sh`). This method may not always work, as the shell you are executing may honor the "#!/bin/bash" shebang within the default scripts. Second and simplest, you may change the shebang itself in your script. Since all other scripts are sourced rather than executed, the script should go fine as long as the shell's functionality supports a bash-like instruction set.
Most any application you wish to compile will need this.
Most any application you wish to compile will need this too. If you are not installing the RPM, I would recommend using GCC, but any compiler supported by automake can be used.
There are two ways to get Ape Base Compile System. You can either install the RPM (recommended) or checkout the Subversion repository.
To install the RPM, first download the current release from the SourceForge download page at https://sourceforge.net/project/showfiles.php?group_id=220974. You must browse the site if you wish to find the direct download link for use with `wget`. Then install it in the normal manner.
[root@localhost:~]$ wget http://somemirror.dl.sourceforge.net/sourceforge/apebase/apeBase-1.0-ap20088363.el5.ape.noarch.rpm [root@localhost:~]$ rpm -i apeBase-1.0-ap20088363.el5.ape.noarch.rpm [root@localhost:~]$ |
You're done you lucky RPM user you. Skip on ahead to the Setup section.
There are two ways to install via Subversion. The first is if you wish to merely install and do not plan to develop or contribute to the Ape Base Compile System project. The second is for developers and contributors who wish to do extensive work. I would recommend you perform an RPM installation rather than a Subversion installation unless you plan to develop Ape Base Compile System. If for some reason, you can't use RPM (perhaps OS X), then by all means use the first method of Subversion installation.
We will need to manually create the /ape directory and `svn export` the Ape Base Compile System trunk to create /ape/_compile. Once that is done, manually run the post-installation script.
[root@localhost:~]$ mkdir /ape [root@localhost:~]$ svn export https://apebase.svn.sourceforge.net/svnroot/apebase/trunk /ape/_compile # lots of subversion output ensues... A here/sourceballs/.ape_create_directory Exported revision NN. [root@localhost:~]$ /ape/_compile/util/bin/ape_post_install.sh ## ape_post_install.sh # In directory /ape/_compile/rpms. create symbolic link `redhat' to `centos' create symbolic link `up-mrepo.sh' to `../util/bin/up-mrepo.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/centos. create symbolic link `el4.6' to `el4' ## ape_post_install.sh # In directory /ape/_compile/scripts. create symbolic link `_blank_build_script-copy_to_create_your_own.sh' to `../include/_blank_build_script-copy_to_create_your_own.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/mrepo-www. create symbolic link `apeDocs' to `../../util/docs' ## ape_post_install.sh # Complete. [root@localhost:~]$ |
To upgrade, simply perform the last two steps again.
[root@localhost:~]$ svn export https://apebase.svn.sourceforge.net/svnroot/apebase/trunk /ape/_compile # lots of subversion output ensues... A here/sourceballs/.ape_create_directory Exported revision NN. [root@localhost:~]$ /ape/_compile/util/bin/ape_post_install.sh ## ape_post_install.sh # In directory /ape/_compile/rpms. create symbolic link `redhat' to `centos' create symbolic link `up-mrepo.sh' to `../util/bin/up-mrepo.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/centos. create symbolic link `el4.6' to `el4' ## ape_post_install.sh # In directory /ape/_compile/scripts. create symbolic link `_blank_build_script-copy_to_create_your_own.sh' to `../include/_blank_build_script-copy_to_create_your_own.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/mrepo-www. create symbolic link `apeDocs' to `../../util/docs' ## ape_post_install.sh # Complete. [root@localhost:~]$ |
For minor development, patch files and revised copies are acceptable to submit with bug reports. There is no need to perform a Subversion installation if you are merely patching the project. The subversion trunk always contains the stable release and is not to be developed against. If you wish to develop, please use the latest version number in /branches and coordinate with the other developers to hear news about branch changes.
Similar to the Checkout method, will need to manually create the /ape directory and `svn co` to create /ape/_compile. However, we need to `svn co` instead of `export` and use the path to the branch. Once that is done, manually run the post-installation script.
[root@localhost:~]$ mkdir /ape [root@localhost:~]$ svn co https://apebase.svn.sourceforge.net/svnroot/apebase/branches/*VERSION* /ape/_compile # lots of subversion output ensues... A here/sourceballs/.ape_create_directory Exported revision NN. [root@localhost:~]$ /ape/_compile/util/bin/ape_post_install.sh ## ape_post_install.sh # In directory /ape/_compile/rpms. create symbolic link `redhat' to `centos' create symbolic link `up-mrepo.sh' to `../util/bin/up-mrepo.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/centos. create symbolic link `el4.6' to `el4' ## ape_post_install.sh # In directory /ape/_compile/scripts. create symbolic link `_blank_build_script-copy_to_create_your_own.sh' to `../include/_blank_build_script-copy_to_create_your_own.sh' ## ape_post_install.sh # In directory /ape/_compile/rpms/mrepo-www. create symbolic link `apeDocs' to `../../util/docs' ## ape_post_install.sh # Complete. [root@localhost:~]$ |
Depending on how you want to use Ape Base Compile System, your setup can either be really fast or extensive. Either way, the first thing you'll want to do is set up a system wide config file. To do so, copy the sample to get yourself started.
[root@localhost:~]$ cp /ape/_compile/include/sample.ape_config.sh /ape/_compile/include/ape_config.sh [root@localhost:~]$ |
All of the Ape User Configuration Variables are available in /ape/_compile/include/ape_config.sh. Some that are commonly changed have been provided in the sample file. If /ape/_compile/include/ape_config.sh does not exist, all default values will be used but your script will proceed to run.
If you don't need MREPO to be served via a webserver and already have EPM installed, then you are done. If you need to build EPM or have MREPO served via HTTPD, then proceed.
If you'd like to build ESP EPM, there is already a script ready for you to do so. First set up your ./src directory.
The most essential part of your compile and packaging efforts is the source code for your application. In our example, we'll be getting ready to compile ESP EPM. To place it, we'll download the source package from http://www.epmhome.org/ to our ./sourceballs directory, extract it to the ./src directory and know what we need to chage if anything in our user script. Please be sure to use the appropriate mirror from http://www.epmhome.org/ to download. We will be dealing with a GZipped Tarball in this example. If you have a zip, rar or other type of package, please substitute the `tar` commands below for their appropriate equivalent and read the documentation for that equivalent.
First, grab the source package.
[root@localhost:~]$ wget --directory-prefix=/ape/_compile/sourceballs 'http://ftp.SOME-MIRROR/pub/epm/4.1/epm-4.1-source.tar.gz' --10:24:06-- http://ftp.SOME-MIRROR/pub/epm/4.1/epm-4.1-source.tar.gz Resolving ftp.SOME-MIRROR... 208.256.256.256 Connecting to ftp.SOME-MIRROR|208.256.256.256|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 509728 (498K) [application/x-gzip] Saving to: `/ape/_compile/sourceballs/epm-4.1-source.tar.gz' 100%[=================================================================================================================================================>] 509,728 984K/s in 0.5s 10:24:07 (984 KB/s) - `/ape/_compile/sourceballs/epm-4.1-source.tar.gz' saved [509728/509728] [root@localhost:~]$ |
Now we extract it to /ape/_compile/src/, but first we check to see that everything in the source package is inside of a directory. In this case, the directory is named in the style of "app-version" as Ape Base Compile System will expect it: ("epm-4.1"). If the contents of the source package are at the root of the package, you may wish to alter "--directory /ape/_compile/src" to something like "--directory /ape/_compile/src/app-version" in the second command below.
[root@localhost:~]$ tar --gzip --list --file /ape/_compile/sourceballs/epm-4.1-source.tar.gz | head -n 10 epm-4.1/ epm-4.1/doc/ epm-4.1/doc/3-packaging.html epm-4.1/doc/epmlogo.tif epm-4.1/doc/epm.man epm-4.1/doc/d-relnotes.html epm-4.1/doc/mkepmlist.man epm-4.1/doc/c-reference.html epm-4.1/doc/epminstall.man epm-4.1/doc/Makefile.in [root@localhost:~]$ tar --gzip --extract --directory /ape/_compile/src --file /ape/_compile/sourceballs/epm-4.1-source.tar.gz [root@localhost:~]$ ls -ld /ape/_compile/src/epm-4.1 drwxrwxr-x 5 1110 games 4096 Apr 10 2007 /ape/_compile/src/epm-4.1 [root@localhost:~]$ |
In this case, you'll notice the odd owner and group of /ape/_compile/src/epm-4.1 in the final directory listing (`ls`). These were the permissions from the extracted archive. We shoudl fix them before going on.
[root@localhost:~]$ chown -R root:root /ape/_compile/src/epm-4.1 [root@localhost:~]$ ls -ld /ape/_compile/src/epm-4.1 drwxrwxr-x 5 root root 4096 Apr 10 2007 /ape/_compile/src/epm-4.1 [root@localhost:~]$ |
If you wish to further organize the ./src directory, you can do so. Perhaps you'd like to keep all of your MySQL sources together. In such a case you would create the directory in ./src and adjust your APE_CONF_SOURCE_DIR_NAME variable accordingly in your user script.
A script has already been prodived to both test your installation and build ESP EPM. The script is ./scripts/ape.epm-4.1.sh. Note that you should not copy this script to create one of your own. To create your own script, copy the file ./scripts/_blank_build_script-copy_to_create_your_own.sh.
First, let's look at its help output.
[root@localhost:~]$ /ape/_compile/scripts/ape.epm-4.1.sh -h INFO: User script for the Ape Base Compile System. For information about the Ape Base Compile System, please visit http://apebase.sourceforge.net/. You may also find documentation on this local machine at http://apebase.sourceforge.net:80/apeDocs if the Ape Base Compile System is fully installed. VERSION: 1.02-ap20104400 SVN r73 2008-03-23 09:19:42Z BrynM USAGE: ape.epm-4.1.sh [-a] [-c] [-h] [-i] [-j] [-k] [-m] [-o] [-r [-g]] [-s] [-t] OPTIONS: -a Run `configure`, `make`, `make install` and RPM steps. Essentially shorthand for the combined flags -cmisr. -c Run `configure` step. -i Run `make install` step. This will also perform a removal like -k and activate -s. -j Just run and exit performing only common actions. Primarily only used for debugging script failures.. -h Show usage and exit. -k Remove previous build and exit. -m Run `make` step. -o Show `configure --help` output. -r [-g] Create RPM using EPM (requires the ESP EPM binaries). The -g flag will cause the resulting RPM to be deposited into the appropriate gold directory for the distribution (currently only RHEL based). -s Copy skeleton config files. -t Experimental. Tarball up installed version into a .tar.gz under the current directory. NOTES: Execution order is -c, -m, (implied -k) -i, -s , -r , -t. The options -h, -j, -k and -o will ech stop execution directly after performing their task. Implied -k means that a removal is performed, but this is actually part of the -i step and not an actual usage of the -k process. Some commands produce logs within the "output" directory. RPMs end up in the "rpms" directory in subfolders organized by distro, release and architecture. Tarballs end up in the current working directory. Files copied from the skel directory always end up under the compiled --prefix. You can add additional EPM directives by providing a file to the APE_CONF_USER_EPM_STUB setting. [root@localhost:~]$ |
Now would be a good opportunity to take a quick read of /ape/_compile/scripts/ape.epm-4.1.sh before we use it.
[root@localhost:~]$ less /ape/_compile/scripts/ape.epm-4.1.sh [root@localhost:~]$ # press [q] to exit `less` when you are done reading [root@localhost:~]$ |
If you compare /ape/_compile/scripts/ape.epm-4.1.sh to the default user script /ape/_compile/scripts/_blank_build_script-copy_to_create_your_own.sh, you'll notice that only five variables have changed. The first two are mandatory for any usage of Ape Base Compile System. The final three are optional to use in your own scripts. I use them to bind the installation of EPM to your Ape Base Compile System installation so your preferred APE_CONF_BASE_DEST_PARENT_DIR can stay clean.
# Proper name of package for RPM package naming such as "php" or "mysql".
# package names can only contain letters and numbers. No spaces or punctuation
# such as a dash ("-") or underscore ("_") are allowed.
export APE_CONF_PACKAGE_NAME="epm"
# Version number that we will use for the final directory name of the install.
#
export APE_CONF_VERSION="4.1"
# prefix for proper name of package used in RPM package naming to differentiate
# from packages built by others. Such as "ape" to produce an RPM for "apePhp".
#
export APE_CONF_PACKAGE_NAME_PREFIX="ape"
# whether or not to build a link-to-current script - yes or no
#
#export APE_CONF_SKEL_LINKTO_SCRIPT="no"
export APE_CONF_SKEL_LINKTO_SCRIPT="yes"
# Base install path (the root directory for --prefix)
# Change this if you want your applications to end up in a place other than /ape.
#
export APE_CONF_BASE_DEST_PARENT_DIR="/ape"
Time for the good stuff. Let's run /ape/_compile/scripts/ape.epm-4.1.sh. Though we would be tempted to use the "-a" flag here, EPM doesn't exist yet, so the RPM step will fail. Instead, we will run the script with "-cmis". Note that I've edited out the non- output below for brevity.
[root@localhost:~]$ /ape/_compile/scripts/ape.epm-4.1.sh -cmis ## ape.epm-4.1.sh # Auto enable -k option ## ape.epm-4.1.sh # Auto enable -s option ## ape.epm-4.1.sh # Begining apeEpm from sources in epm-4.1. ## ape.epm-4.1.sh # Target Directory: /ape/epm/4.1 ## ape.epm-4.1.sh # Detected "i386" mode. ## ape.epm-4.1.sh # Lib path (APE_SYS_DETECTED_ARCHITECTURE) is "lib" ## ape.epm-4.1.sh # Using APE_CONF_COMPILE_HOME /ape/_compile ## ape.epm-4.1.sh # Moving to /ape/_compile/src/epm-4.1 ## ape.epm-4.1.sh # Running `/ape/_compile/src/epm-4.1/configure` ## ape.epm-4.1.sh # Configure String: -->( ./configure --prefix=/ape/epm/4.1 2>&1 | tee /ape/_compile/output/configure-apeEpm-4.1-ap167463-i386.log )<-- ## ape.epm-4.1.sh # ape_sys_run_configure result: 0 ## ape.epm-4.1.sh # `make clean` result: 0 ## ape.epm-4.1.sh # ape_sys_run_make result: 0 ## ape.epm-4.1.sh # Removing previous build... ## ape.epm-4.1.sh # ape_sys_run_remove result: 0 ## ape.epm-4.1.sh # ape_sys_run_make_install result: 0 ## ape.epm-4.1.sh # Skipping creation of "/ape/_compile/skels/epm-4.1/bin/link_to_current.epm-4.1.sh" as it would overwrite an existing file ## ape.epm-4.1.sh # ape_sys_run_create_ltcurr_script result: 0 ## ape.epm-4.1.sh # Copying skeleton files from "", "/ape/_compile/skels/epm-4.1" and "". ## ape.epm-4.1.sh # Executing `/usr/bin/rsync --stats --recursive --copy-links --copy-dirlinks --times --human-readable --exclude-from=/ape/_compile/include/skel_exclude.txt /ape/_compile/skels/epm-4.1/ /ape/epm/4.1/ 2>&1`. ## ape.epm-4.1.sh # Skel rsync number of files: 3 ## ape.epm-4.1.sh # ape_sys_run_skel result: 0 ## ape.epm-4.1.sh # Moving back to /ape/_compile [root@localhost:~]$ |
Asuming that all went well, and you didn't get any compile errors, we're ready for the final two steps. We are going to run the link-to-current script /ape/epm/4.1/bin/link_to_current.epm-4.1.sh to make our version the active one. Then we are finally going to roll our intallation into an RPM by running /ape/_compile/scripts/ape.epm-4.1.sh with the "-r" flag.
[root@localhost:~]$ /ape/epm/4.1/bin/link_to_current.epm-4.1.sh ** link_to_current.epm-4.1.sh ** begun for APP "epm" VER "4.1" ** link_to_current.epm-4.1.sh ** CAUTION! Linking version 4.1 to be the current epm version! create symbolic link `/ape/epm/current' to `/ape/epm/4.1' create symbolic link `/ape/bin/epm' to `/ape/epm/current/bin/epm' create symbolic link `/ape/bin/epminstall' to `/ape/epm/current/bin/epminstall' create symbolic link `/ape/bin/mkepmlist' to `/ape/epm/current/bin/mkepmlist' create symbolic link `/ape/bin/link_to_current.epm-4.1.sh' to `/ape/epm/4.1/bin/link_to_current.epm-4.1.sh' ** link_to_current.epm-4.1.sh ** complete. [root@localhost:~]$ /ape/_compile/scripts/ape.epm-4.1.sh -r ## ape.epm-4.1.sh # Begining apeEpm from sources in epm-4.1. ## ape.epm-4.1.sh # Target Directory: /ape/epm/4.1 ## ape.epm-4.1.sh # Detected "i386" mode. ## ape.epm-4.1.sh # Lib path (APE_SYS_DETECTED_ARCHITECTURE) is "lib" ## ape.epm-4.1.sh # Using APE_CONF_COMPILE_HOME /ape/_compile ## ape.epm-4.1.sh # Moving to /ape/_compile/src/epm-4.1 ## ape.epm-4.1.sh # Skipping creation of "/ape/_compile/skels/epm-4.1/bin/link_to_current.epm-4.1.sh" as it would overwrite an existing file ## ape.epm-4.1.sh # ape_sys_run_create_ltcurr_script result: 0 ## ape.epm-4.1.sh # Compiling epm list file "/ape/_compile/epm-extra/epm-4.1.list" ## ape.epm-4.1.sh # Executing "/ape/bin/mkepmlist --prefix /ape/epm/4.1/ /ape/epm/4.1/ >>/ape/_compile/epm-extra/epm-4.1.list" ## ape.epm-4.1.sh # Executing "/ape/bin/epm --output-dir /ape/_compile/util/tmp-build -f rpm apeEpm /ape/_compile/epm-extra/epm-4.1.list 2>&1" ## ape.epm-4.1.sh # Moved `/ape/_compile/util/tmp-build/apeEpm-4.1-ap167464-linux-2.6-intel.rpm' -> `/ape/_compile/rpms/centos/el5/i386/apeEpm-4.1-ap167464.el5.ape.i386.rpm'. ## ape.epm-4.1.sh # Executing APE_CONF_POST_RPM_CMD "/ape/_compile/rpms/up-mrepo.sh -v". ## ape.epm-4.1.sh # Nothing to do. Either MREPO is not installed or no processes called mrepoHttpd were found. ## ape.epm-4.1.sh # ape_sys_run_rpm result: 0 ## ape.epm-4.1.sh # Moving back to /ape/_compile [root@localhost:~]$ |
You may have noticed the references to a file called "link_to_current.epm-4.1.sh" landing in "/ape/epm/4.1/bin". Link-to-current scripts are explained fully explained later. For now, let's just run it to complete the EPM installation. You might be able to glean some information from its output.
[root@localhost:~]$ /ape/epm/4.1/bin/link_to_current.epm-4.1.sh ** link_to_current.epm-4.1.sh ** begun for APP "epm" VER "4.1" ** link_to_current.epm-4.1.sh ** CAUTION! Linking version 4.1 to be the current epm version! create symbolic link `/ape/epm/current' to `/ape/epm/4.1' create symbolic link `/ape/bin/epm' to `/ape/epm/current/bin/epm' create symbolic link `/ape/bin/epminstall' to `/ape/epm/current/bin/epminstall' create symbolic link `/ape/bin/mkepmlist' to `/ape/epm/current/bin/mkepmlist' create symbolic link `/ape/bin/link_to_current.epm-4.1.sh' to `/ape/epm/4.1/bin/link_to_current.epm-4.1.sh' ** link_to_current.epm-4.1.sh ** complete. [root@localhost:~]$ |
You are now ready to finalize a complete Ape Base Compile System installation by moving on to the next step and setting up Apache to serve MREPO repositories.
I'm hoping you can accomplish this based upon the instructions for setting up EPM. The process should be the same, except this time you are grabbing the Apache Foundation HTTPD daemon. We aren't recompiling MREPO as that takes some advanced usage (MREPO doesn not support `configure` nor it's "--prefix" parameter).
You'll want to grab the source files from httpd.apache.org and move your source tarball to the ./sourceballs directory. For our example, we grabbed ourselves a copy of "httpd-2.2.8.tar.gz" from a mirror. WE're also asuming you've extracted it to ./src/httpd-2.2.8.