STANFORD SERVER RPM build instructions
Last updated 2015-03-09

Created for and maintained by Jonathan Lent <jlent@stanford.edu>
YOUR MILEAGE MAY VARY.

Unlike RPM builds for webauth, building stanford-server will involve
a bit more manual work than simply sourcing a tar.gz and updating the spec file.
What's easiest here is if we package from an already-extracted tree. This
will allow us to quickly manipulate things on-the-fly relevant to RedHat without
having to do the tar/untar/retar-dance.

(1) Checkout the general stanford-server git repository (or pull):

git clone ssh://git.stanford.edu/srv/git/server/server.git

You may want to go ahead and `git rm` the usr/ and etc/ directories. You'll
be overwriting/merging into those later, and extra scripts that are no longer
packaged with stanford-server will cause you headaches during the build.

(2) Adjust as necessary if you need something other than latest release. Taking
a look at the `git log` is probably not a bad idea in general.

(3) Make sure your packages/stanford-server git environment is clean and
otherwise ready to go. You can always blow it away and start over with:

git clone ssh://git.stanford.edu/srv/git/redhat/stanford-server.git

(4) copy a few directories directly into your packages/stanford-server directory.
Also, do some housekeeping and manipulation while you're at it:

cp -r /srv/scratch/jlent/stanford-server/etc/ ~/packages/stanford-server/
cp -r /srv/scratch/jlent/stanford-server/usr/ ~/packages/stanford-server/
mkdir -p ~/packages/stanford-server/etc/CRON
mkdir -p ~/packages/stanford-server/etc/cron.d
mkdir -p ~/packages/stanford-server/etc/cron.daily
mkdir -p ~/packages/stanford-server/etc/cron.hourly
find /srv/scratch/jlent/stanford-server/ -name "*cron*" -exec cp -rfp {} ~/packages/stanford-server/etc/CRON \;

(5) Make sure that your files.mk is ready to go. In addition to Makefile and install.mk, 
you'll want to make sure that all files in the relevant directories are present. This
command will likely get you what you need:

cd ~/packages/stanford-server ; echo -n "FILES= Makefile install.mk " ; find usr -type f | tr '\n' ' ' ; find etc -type f | tr '\n' ' '

(6) For any new directories that make it into the files.mk, you'll likely want
corresponding entries in stanford-server.spec. You'll error out if the files are
recognized on one end and not the other (e.g. rpm-lint)

(7A) Make a new tarball of the source
cd ~/packages/
tar -pczf stanford-server-128.tar.gz --exclude "*.mk" --exclude "no-rhel*" --exclude "README.build" --exclude "Makefile" --exclude "stanford-server-*" --exclude "stanford-server.spec" stanford-server/
cp stanford-server-128.tar.gz /afs/ir/product/redhat/tarballs/
cd stanford-server
ln -s /afs/ir/product/redhat/tarballs/stanford-server-128.tar.gz stanford-server-128.tar.gz

(7B) Verify the contents of the tarball
cp ~/packages/stanford-server-128.tar.gz /tmp
cd /tmp
du -h stanford-server-128.tar.gz
tar -zxvf stanford-server-128.tar.gz
tree stanford-server

(8) Try your make 

(9) If all is done, make sure to git commit all of your changes
