Svn post-commit hook failing on command not found - linux

I'm trying to call a script using a post-commit hook, but it fails because it cannot find various commands.
My research has shown that there are basically no environment variables loaded when a post-commit hook is run, so I suppose that's why it can't find commands like ping.
Is there anyway to define enough in my post-commit hook so that I can call a script that runs on baseline POSIX commands?

Subversion hook scripts are executed with an empty environment. Best practice is to specify full paths in your scripts (and any other scripts that they may call), or set up the environment variables you require in the hook script itself.
From the manual:
For security reasons, the Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH (or %PATH%, under Windows). Because of this, many administrators are baffled when their hook program runs fine by hand, but doesn't work when run by Subversion. Be sure to explicitly set any necessary environment variables in your hook program and/or use absolute paths to programs.

At the start of your hook, you can set up PATH and other environment variables:
LANG=en_US.UTF-8
PATH=/path/to/bin:/another/bin:$PATH

Related

Set environmental vars and enable core dumps in autotools build

I am using Autotools for my current project. I'm using Ubuntu and Linux mint. With Autotools I can tell it to check a users's system to check for any required libraries my project needs in order to function properly. Now I would like to check if a user's system has enabled core dumps and if not, then execute the command ulimit -c unlimited to enable core dumps. How and where do I specify this?
Also, once the user has executed the make command to compile the source code, they execute sudo make install in order to move the binaries at /usr/local/bin/MYPROJECT. I want to add the location of my project's binaries into the path environmental variable, so that the user can execute any of the binaries in my project from a terminal without the need of typing the full path. How and where do I specify this in Autotools?
I'm thinking this is something I would add in the configure.ac file, but I haven't found any examples on how I can do this. Any help would be appreciated.
It sounds as if you basically misunderstand what installation of a software
package on Linux is about.
The job of autotools is to build a portable installation package of your
software. When I install your package, it does not become your decision
whether programs that crash will generate core dumps on my computer
when I run them. It does not become your decision what PATH I use to
invoke programs by unqualified name. These are my decisions or defaults
that I have accepted from my OS distribution.
If you execute ulimit -c unlimited, the command will in any case
only apply to the shell in which it is invoked. It doesn't
reconfigure the host system (!).
If you would like users to be able to invoke your program by unqualified
name, the normal procedure is make your package install it by default in the place,
/usr/local/bin, that unix-like OSes traditionally add to a
user's default PATH for finding locally installed programs. That is
where autotools will configure it to be installed, by default. Change it
only if you don't want your program to be in the user's default PATH.
And in any case, a user can decide where your software is installed by
passing --prefix=/path/of/my/choice to the ./configure command. Unless
you have some unavoidable reason not to, make your package installation
use the defaults that everybody expects and leave it up to the installing user
to change them.
Bottom line: You are asking how to do installation actions with autotools that
are not meant to be done with autotools, because they are not meant to be
done by package installations.

multiple binaries with same name in ubuntu/linux

I have recently installed a webframework play (http://www.playframework.com/) and want to have the play executable in the system path ie $PATH. But ubuntu already defines a command called play. How do I overwrite the system defined command with my framework binary path so that command play on commandline calls my framework rather than the old application.
Installation: I downloaded zipped file of the framework and upzipped in one of my personal folder which contains the docs and the executable.
Never alter the contents of installed packages. Such changes can provoke hard to find problems in the system and anyway, they will most likely be overwritten again in subsequent updates. There are other alternatives:
obviously you can chose another name for your executable
place the executable in another part of your $PATH if its a "personal installation", typically ~/bin is used for such approach. Remember that the order of entries in the $PATH variable is important, first come first serve.
use the traditional /usr/local/bin location for locally added "wild" installations, this way there is some form of clean separation between clean packages and wild installed files inside the system
store your software in some other location and prepend that to your personal or system wide $PATH variable
store your executable under another name and create an alias (see man alias for an explanation) for it which allows to call it by some name that "hides" the original command this way. For this the executable can be addressed with an absolute path, so it dies not have to be found inside the $PATH variable.
In my personal opinion options 2. and 5. and the best if it comes to "personal installations".
If you are sure you'll never use the original play command, you could just remove the binary. But in general, this isn't a good idea, since some system component you don't think of might need it, and the next update will probably restore it.
The best thing to do is to prepend the directory of your play command to the PATH, for example, using PATH=/opt/framework/bin:$PATH in your .profile (assuming your play command installs to /opt/framework/bin/play), or the script that starts your web server, or wherever you need your play command.
Remember that does not make your play command global. A common mistake is to add the path in their .profile file, then call the program from crontab - crontab scripts will not execute .profile or .bashrc.

Creating a shell environment for git hooks and Git Tower

I'm using Git Tower. My project has some git hooks that aren't running. According go the Git Tower FAQ:
You need to make sure you're creating the required shell environment
in the hook script itself (like modifying "PATH"), not in your shell
profile, as the hook script is called from the Tower process
environment which is not running in a shell environment (hence your
shell profile is not loaded).
This is quite foreign to me. My shell script is quite simply:
#!/bin/sh
git ftp push
What do I need to do in order to get Tower "permission" to process my hooks?

gitolite hook after git push doesn't work

I tried to search to find a solution.
but, I can't.
I installed gitolite. And it works well.
I can git clone on the local machine, and change gitolite-admin repo too.
But I want to use gitolite hooking.
followed this manual
http://sitaramc.github.com/gitolite/hooks.html
custom hooks
You can supply your own, custom, hook scripts if you wish. Install
gitolite as usual, then:
go to ~/.gitolite/hooks/common on the server and put your new hook
there now run "gl-setup" again You can use this procedure to install
new hooks as well as to update hooks that you had previously
installed.
So I tried to hook some basic shell script.
I put bash shell script on
~/.gitolite/hooks/common
and named it
update
update script file's owner is git, and excutable.
the shell script is like this..
#!/bin/bash
touch /tmp/$GL_REPO
and I execute
gl-setup mypubkey.pub
and then,
On my local git folder,
I modified some file, commit and push to gitolite server.
push works well. every file uploaded to the gitolite's repo.
but, hooking doesn't seems to occur. Nothing happened.
on the server's tmp directory, no file is created.
Did I forget something?
any comments plz...
You should realize that (from the "using hooks" page you mention in your question=:
The update hook is used in all repos and is critical to gitolite's access control
In other words, you cannot directly use an "update" script.
You must use the "hook chaining" feature of gitolite, in order to call your own update hook after the one of gitolite:
To run your own 'update' hook, just put it in a file called update.secondary and install it as a hook.
Gitolite's update hook will automatically chain to it, taking care to pass it the same 3 arguments the original update hook received from git.
In the end, the OP Jinbom Heo, rather than using "gitolite hook chaining", went with another hook:
I put post-receive file in /var/gitolite/hooks/common/ folder. And it works.
The doc "Where do I put my hooks" suggest rather to put those under the "user" location (~/.gitolite/hooks/common):
But the system location works too.
( /var/gitolite/hooks/common/ means, by the way, the OP chose the root method installation or the package one, with the default paths /usr/local/bin, /var/gitolite/conf, /var/gitolite/hooks)

Running a program from the source tree

Should it generally be possible to run a program from the source directory (src) after having invoked ./configure and make (but not make install)? I'm trying to fix a bug in an application and it seems unnecessary to run make install after each code change. Unfortunately I can't run the application in the source directory since it tries to access files in the lib installation directory (which do not exist before make install). Is the application wrongly configured or do I have to reinstall it after each change to the source code?
It all depends on the application and what components or files it expects to be visible and where. But assuming no required configuration or dependencies, then yes, you can run the program in-place.
To add a directory to your lib search path, add to the environment variable LD_LIBRARY_PATH. Like so:
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/user/myproject/lib" ./someprogram
Note that specifiying a variable assignment on the command line in front of the program you run sets that variable for that run only. (Note, no semicolon -- this is a single command.) If you want to set the variable for the entire session, use
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/user/myproject/lib"
I'd recommend against this, though. It can lead to problems and confusion.

Resources