ClearFoundation

Developer Development Environment

Development Environment

Installing the Development Tools

Before getting underway, the first thing you need to do is install a ClearOS system. Thanks to the age of virtual machines, you no longer need dedicated hardware. Go ahead and install ClearOS 6 on your favorite virtual machine (or dedicated hardware) and get it up and running.

You may see some PHP warnings about the time zone. We will address the issue at a future date.

Once you have the system up and running, login as root (we'll get to creating a normal user account momentarily). You can then install a basic set of development tools with the following commands:

yum upgrade
yum --enablerepo=clearos-developer,clearos-epel install clearos-devel

You will also want to install your text editor of choice, for example:

yum install vim-enhanced

Create Normal User Account

Now that the developer tools are installed, it is time create a normal user account for development. To avoid the chicken/egg scenario when working on LDAP, we recommend adding a normal Unix/shadow account. The webconfig server will need read access to your developer directory, hence the need for the chmod file permissions changes.

useradd -u 500 devuser
passwd devuser
su - devuser
chmod og+rx /home/devuser

The -u 500 flag ensures that you are using a user ID that will not interfere with those in LDAP. On a ClearOS system, the user ID range from 500-999 is reserved for non-LDAP user accounts. Please make sure you pick a user ID that is not already in use (in other words, if you add another user, set the ID to 501). If you are curious, more information on ClearOS ID ranges is here.

Specify Environment Variables

Next, you need to specify an RPM “dist” tag that will distinguish your RPM packages from others. Please make sure you change the mydist tag to something that distinguishes your rpms. When you are done with your first RPM build, you will see the dist tag in the filename, for example myapp-1.0-1.1.mydist.i386.rpm.

echo "%dist .mydist" >> ~/.rpmmacros
echo -e "%_topdir\t$HOME/rpmbuild" >> ~/.rpmmacros

The latter command changes the default build location to our own directory - in this case located within the users home directory in a folder called rpmbuild. It is optional for ClearOS 6.x as rpmbuild can determine the local path, in previous versions the default build location otherwise is /usr/src/redhat.

Create Required Directory Structure

Whether building apps or patching software, you need a directory structure to build RPMs. For app developers, you don't need to know anything about creating RPMs, but you still need a place to put them! To create this directory structure, run:

mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

The details of each directory are described in the following table.

DirectoryDescription
BUILDScratch area for the build process
BUILDROOTScratch area for the installation
RPMS/*Where the build puts the RPMs
SOURCESSource code and patches needed to build an RPM
SPECSRPM spec files
SRPMSWhere the build puts the source RPMs

Now What

Framework - ClearOS Apps

If you are primarily interested in building web-based apps for ClearOS, then your next step is to continue building out your development environment. Continue your journey by reviewing Framework Development Environment.

Packaging - RPMs

If you are primarily interested in packaging and maintaining RPMs, you can jump right into the following Packaging documentation.



Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Video demonstrations - Copyright © 2010 ClearCenter Corporation