TVSET has asked for the wisdom of the Perl Monks concerning the following question:

Dear All, I am currently involved in development of a slightly bigger project than what I am used to. The project I am working on, has two branches - one for stable releases, and another for development releases.

Directory structure for stable version is:

/var/www/intranet/stable/ /var/www/intranet/stable/*.epl /var/www/intranet/stable/lib/ /var/www/intranet/stable/lib/*.pm

Directory structure for development version is:

/var/www/intranet/devel/ /var/www/intranet/devel/*.epl /var/www/intranet/devel/lib/ /var/www/intranet/devel/lib/*.pm

All my Embperl files (*.epl) do have

use lib "/var/www/intranet/devel/lib"

line at the beginning. When I need to release a version as a stable one, I need to go through all of the files and change the "use lib" line to point to "/var/www/intranet/stable/lib".

That is not a big problem, but it's rather inconvinient. I am interested in examples of TMTOWTDI from all of you :)

I, myself, came up with the following ways to go about the problem:

All ideas and comments are very well welcome. TIA.

P.S.: I am not posting it into SoPW, since this is a generic question and more or less applies to projects in any other language.

Leonid Mamtchenkov aka TVSET

Replies are listed 'Best First'.
Re: File/Directory hierarchy for devel/stable versions
by Abigail-II (Bishop) on May 19, 2003 at 23:45 UTC
    This is why God gave us environment variables. The right way to do it is to write a wrapper (shell)script, that does two things: source to appropriate config file (which sets a bunch of environment variables), and then launch the appropriate programs that use the environment variables to determine which directories/files to use.

    You'd have a config file for your development environment and one for your stable environment.

    Been there, done that, didn't get the T-shirt.

    Abigail

Re: File/Directory hierarchy for devel/stable versions
by mr_mischief (Monsignor) on May 19, 2003 at 23:08 UTC
    What's wrong with sticking this (possibly in a BEGIN block) at the top of each file, and never having to worry about it again?
    my $code_status; if ( -f './status-devel' ) { $code_status = 'devel'; } else { $code_status = 'stable'; } use lib "/var/www/intranet/${code_status}/lib";


    Update: Fixed the variable in the path per chromatic's good catch, and replaced "an INIT block" with "a BEGIN block", since that's what it's called in Perl. ;-)

    Christopher E. Stith
    use coffee;

      The fact that his directory names probably don't contain curly braces. :)

      use lib "/var/www/intranet/$code_status/lib"; # or use lib "/var/www/intranet/${code_status}/lib";
Re: File/Directory hierarchy for devel/stable versions
by Juerd (Abbot) on May 19, 2003 at 23:19 UTC

    When I need to release a version as a stable one, I need to go through all of the files and change the "use lib" line to point to "/var/www/intranet/stable/lib". (...) Manually go through the files and change the line.

    Manually? Are you sure you're a Perl coder? :)

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      :) I told you that I would never do it. I am not sure if I can be called a "perl coder", but I am a sysadmin, and it already makes me as lazy, as hell. :)

      Leonid Mamtchenkov aka TVSET

Re: File/Directory hierarchy for devel/stable versions
by blokhead (Monsignor) on May 20, 2003 at 04:39 UTC
    This screams "symlink" to me...

    In your embperl files:

    use lib "/var/www/intranet/currently-in-use/lib"
    And on the shell:
    $ ln -s /var/www/intranet/stable /var/www/intranet/currently-in-use .. time passes, switch to devel version .. $ rm /var/www/intranet/currently-in-use $ ln -s /var/www/intranet/devel /var/www/intranet/currently-in-use

    blokhead

Re: File/Directory hierarchy for devel/stable versions (relative paths)
by zby (Vicar) on May 20, 2003 at 08:08 UTC
    Why not use relative paths?:
    use lib "lib";