On Mon, 05 Dec 2011 15:12:05 +0100 Enrico Zini <enr...@debian.org> wrote: > I would like my test scripts to run under eatymdata when it is available > in the system. To do so, I would need to create a wrapper launcher for > my test scripts like so: > > if [ -x /usr/bin/eatmydata ] > then > eatmydata run-tests "$@" > else > run-tests "$@" > fi > > However, it would be even better if I could edit the run-tests script to > do the required export, adding something like this to it: > > libeatmydata="/usr/lib/libeatmydata/libeatmydata.so" > if [ -e $libeatmydata ] > then > if [ -n "$LD_PRELOAD" ]; then > export LD_PRELOAD="$libeatmydata $LD_PRELOAD" > else > export LD_PRELOAD="$libeatmydata" > fi > fi > > This code is however already present in > /usr/share/libeatmydata/eatmydata.sh: if it could be moved from > eatmydata_exec into a separate function, then I could just do this: > > if [ -e /usr/share/libeatmydata/eatmydata.sh ] > then > . /usr/share/libeatmydata/eatmydata.sh > eatmydata_exports > fi > > And not worry about future changes in the way the eatmydata environment > is set up, except the hardcoded /usr/share path.
I wouldn't do so: 1) Please do not hardcode the library path (as you write). actually it changed recently (due to multi arch) 2) Please do not hardcode script patch. Actually /usr/share/libeatmydata/eatmydata.sh is gone... 3) The presence of the library itself is not bound to the presence of the /usr/bin/eatmydata file (now that the library is in a different package than the script) I suggest you to just copy and paste this bit of the current script, plus a check to be sure the library is installed: if $(/sbin/ldconfig -p | grep -q "libeatmydata") ; then export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+"$LD_LIBRARY_PATH:"}/usr/lib/libeatmydata export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so fi (the LD_LIBRARY_PATH is there only to support some use cases where you run a chroot under eatmydata where the the actual path of the library differ between the host and the guest, drop it if your script does not need it) > Even better would be an > "eatmydata --exports" function, but I'm afraid that would mean > introducing some radical changes in the command line parsing code. indeed, and I don't like it. Tell me what you think. I'd wontfix+close this bug report, given that imho there is a better way to do what you want (and shorter, 3 rows instead of 5 in you example). -- regards, Mattia Rizzolo GPG Key: 4096R/B9444540 http://goo.gl/I8TMB more about me: http://mapreri.org Launchpad User: https://launchpad.net/~mapreri Ubuntu Wiki page: https://wiki.ubuntu.com/MattiaRizzolo -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org