# Wrap binary in scrip to set some variables



## tkjacobsen (Nov 29, 2009)

Hi all

I'm maintaining a port (graphics/ipe) and the newest version needs a
variable set. The way I would solve this is to rename the binary (and
move it out of PATH), create a script instead with the original and
let the script set the variable.

Is this the way to go or should I rather do something else?

If yes, how would I do so. Do a 'mv' in the Makefile and put the
script in files/?

Best Regards

Troels Kofoed Jacobsen


----------



## SirDice (Nov 29, 2009)

tkjacobsen said:
			
		

> The way I would solve this is to rename the binary (and move it out of PATH), create a script instead with the original and let the script set the variable.


The net-p2p/mldonkey port does something similar. Except it installs the binary in /usr/local/bin but renames it to mlnet-real. The script is named mlnet. 



> If yes, how would I do so. Do a 'mv' in the Makefile and put the script in files/?


That's how the mldonkey port does it.


----------



## DutchDaemon (Nov 29, 2009)

There's also some moving/renaming going on in the nvidia port (x11/nvidia-driver), so even more inspiration there


----------



## vivek (Dec 2, 2009)

I'm little late to party but this technique can be used with php, and perl via Apache+fastcgi too. You write a wrapper and move original php / perl binary and call your script. You can set additional environment, security checking (e.g. do not run perl script in /tmp) and much more.


----------



## aragon (Dec 2, 2009)

tkjacobsen said:
			
		

> I'm maintaining a port (graphics/ipe) and the newest version needs a
> variable set.


I take it you mean it needs a variable set to work at all on FreeBSD?  If so, surely it'd be better to patch the source so that it doesn't need that env var and wrapper script?


----------



## tkjacobsen (Dec 2, 2009)

Actually, it needs a variable set to work with tetex. Here is the error I get:


```
! Pdftex is too old. Set IPEANCIENTPDFTEX environment variable!.
l.3 ...Set IPEANCIENTPDFTEX environment variable!}
```

The minute someone imports texlive into ports this will go away.


----------

