Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Saturday January 25, 2003
03:08 PM

Automatic releases

[ #10188 ]

I am working on a (non-technical) project, and although I use all of the trappings of technical projects, including make, CVS, and so on, the other people do not really care about that. They just want to see the results.

Since I have a Makefile, I can easily publish the results.

FILE=foo.txt
USER=joe_user
HOST=foo.example.com
DIR=public_html/project
DEST =${USER}@${HOST}:${DIR}
 
publish: ${FILE}
        scp ${FILE} ${DEST}
        @ touch $@

To send the results to the project web server where everyone can access it, I simply type 'make'.

If I want to automatically publish it, I run make from my crontab. I have not done this sort of thing before, but I figured someone must have thought of doing it before. The trick is to get 'make' to run in the right directory. I can tell it which Makefile to use with -f, but it still needs to be in the right directory. Checking the manual page for 'make' I discover the -C switch.

-C dir
    Change  to directory dir before reading the makefiles
    or doing anything else.  If multiple -C  options  are
    specified, each is interpreted relative to the previ-
    ous one: -C / -C etc is equivalent to -C /etc.   This
    is typically used with recursive invocations of make.

Now I run make from cron every 15 minutes. Since this is make, I only publish the latest stuff if it has changed.

*/15 * * * * make -C ${HOME}/Projects/Foo