On 3/12/07, Meir Kriheli <[EMAIL PROTECTED]> wrote:

Sorry for replying to my own post, but looks like the list manager
removed the "dot" at the beginning of the 1st method (something to do
with list commands maybe ?). It appears in my "sent" folder.

It should be: ". setenv.sh"

Testing:

. setenv.sh


Actually I got it ok the first time.

I would like to comment that I had no idea source (".") actually runs
the file it's sourcing. I was sure it's just a quick short cut to
typing each command at the terminal.

Because I've used it for something that is cool (IMHO) I would like to
share with the list.
I'm patching our dev's environment and was looking for a way to
automate the PATH setup for them (taking into account that not all the
devs are unix gurus).

We are using subversion as the scm and scons as the builder. Note that
the scons version is local, that is you get it with the source once
you checkout, no install is needed (besides python, obviously).

With the help you Meir and Peter I now have a setup the allows me to
dynamically set the  PATH variable once a developer cd's into the root
of his checked-out working copy.


The OS is RH 4 WS, the shell is bash.
It's set up is the following way:

$ cat /etc/profile.d/hooks.sh
# Add custom hooks to user-activity in the shell
export PROMPT_COMMAND='[[ -x Utils/bin/local_setup_bashenv.sh ]] &&
source Utils/bin/local_setup_bashenv.sh'

$ pwd
/home/hq4ever/development/builder

$ cat Utils/bin/local_setup_bashenv.sh
#!/bin/bash
for export_val in $(python Utils/bin/local_setup_environment.py); do
export $export_val; done

$ cat Utils/bin/ml_setup_environment.py
#!/bin/python
import os

def find_svn_wcroot():
   homedir_len=len(os.getenv('HOME').split('/'))
   cwddir_len=len(os.getcwd().split('/'))
   cwddir_text=os.getcwd()

   for i in range(cwddir_len, homedir_len, -1):
       if not os.path.exists('/'.join(cwddir_text.split('/')[:i])  + '/.svn'):
           return '/'.join(cwddir_text.split('/')[:i+1])
       #else:
           #print 'Still ok: ' + '/'.join(cwddir_text.split('/')[:i])
+ '/.svn'

def setPATH(export_environment):
   try:
       os.getenv('PATH').split(':').index(find_svn_wcroot()+'/Utils/bin')
   except ValueError:
       export_environment['PATH']=[find_svn_wcroot()+'/Utils/bin'] +
os.getenv('PATH').split(':')

export_env = {}
setPATH(export_env)
#export_env['SOMEVAL']=['maxim']

for (k, v) in export_env.items():
   print k + '=' + ':'.join(v)


Note that I've only written it today and haven't actually tried to
work with it, so bugs are real.

Cheers
--
Meir



--
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to