fbb-git / bobcat

Library of C++ classes and templates handling child processes, streams/sockets, shared memory, config files, etc.
12 stars 4 forks source link

Installation problem with realpath #2

Closed gendx closed 9 years ago

gendx commented 9 years ago

Hi, It seems that commits 821c1b6af9afd2d61a570036eff30d487736b30f to 4258ee3b0fe17cd151366687f95abf545fa479e6 introduced the use of the realpath program (https://github.com/fbb-git/bobcat/search?q=realpath). However, this breaks my automated build on Travis-CI, when issuing the command ./build install (https://travis-ci.org/gendx/compiler/jobs/87755822#L1215). I get the following error:

sh: 1: realpath: not found

Do you have any idea of a workaround for this?

fbb-git commented 9 years ago

Dear gendx, you wrote:

Hi, It seems that commits 821c1b6af9afd2d61a570036eff30d487736b30f to 4258ee3b0fe17cd151366687f95abf545fa479e6 introduced the use of the realpath program (https://github.com/fbb-git/bobcat/search?q=realpath). However, this breaks my automated build on Travis-CI, when issuing the command ./build install (https://travis-ci.org/gendx/compiler/jobs/87755822#L1215). I get the following error:

sh: 1: realpath: not found

Do you have any idea of a workaround for this?

The realpath program is part of the GNU coreutils (cf. http://www.gnu.org/software/coreutils/realpath), so one solution would be to install the GNU coreutils. Another is to write 'realpath' yourself (see below) and install that in your PATH so icmake can find it. GNU's realpath program has a lot of options, but icmake only uses its plain form, not using any options. If installing GNU's coreutils seems to be a bit over the top for you, then the following program can be used:


include

include

include

include

int main(int argc, char *argv) { char cp;

if (argc == 1)          /* no arguments: give usage info */
{
    printf(
        "Provide %s with a (relative or absolute) path name: "
                                                        "its absolute\n"
        "path is written to the std. output stream (and the program "
                                                        "returns 0)\n"
        "an empty string is written if the path could not be determined\n"
        "in which case the program returns realpath(3)'s error code\n", 
        argv[0]
    );
    return 0;
}

cp = realpath(argv[1], 0);
if (cp == 0)
    return errno;

printf("%s\n", cp);
free(cp);
return 0;

}

To compile the program use, e.g.,

gcc -O2 -o realpath realpath.c -s

I hope this solves your problem.

Cheers,

Frank B. Brokken
Center for Information Technology, University of Groningen
(+31) 50 363 9281 
Public PGP key: http://pgp.surfnet.nl
Key Fingerprint: DF32 13DE B156 7732 E65E  3B4D 7DB2 A8BE EAE4 D8AA
gendx commented 9 years ago

Well, the problem seems more complex than that.

It seems that the Ubuntu version of coreutils does not include realpath (and Travis-CI https://travis-ci.org/ uses Ubuntu 12.04). This issue does not seem to be new: see http://unix.stackexchange.com/questions/101080/realpath-command-not-found or http://unix.stackexchange.com/questions/136494/whats-the-difference-between-realpath-and-readlink-f

I checked the Ubuntu packages here: https://launchpad.net/ubuntu/+source/coreutils and they do not include realpath. Alternatively, it seems that readlink -f could be used instead of realpath. Do you think that it would be a more portable solution?

fbb-git commented 9 years ago

Dear gendx, you wrote:

Well, the problem seems more complex than that.

It seems that the Ubuntu version of coreutils does not include realpath (and Travis-CI https://travis-ci.org/ uses Ubuntu 12.04). This issue does not seem to be new: see http://unix.stackexchange.com/questions/101080/realpath-command-not-found or http://unix.stackexchange.com/questions/136494/whats-the-difference-between-realpath-and-readlink-f

I checked the Ubuntu packages here: https://launchpad.net/ubuntu/+source/coreutils and they do not include realpath. Alternatively, it seems that readlink -f could be used instead of realpath. Do you think that it would be a more portable solution?

Fine with me. I just noticed a problem with tar' requiring an update of 'build install' anyway, and it's easy to changerealpath' into readlink -f' at the same time. In the meantime I suppose you can change therealpath' call into `readlink -f' in the file icmake/install.

I.e., change

dest = cutEoln(backtick("realpath " + dest)[0]);

into

dest = cutEoln(backtick("readlink -f " + dest)[0]);

Frank B. Brokken
Center for Information Technology, University of Groningen
(+31) 50 363 9281 
Public PGP key: http://pgp.surfnet.nl
Key Fingerprint: DF32 13DE B156 7732 E65E  3B4D 7DB2 A8BE EAE4 D8AA
fbb-git commented 9 years ago

Commit 685a29944c716ae36f1b6e545c6cd39d6dd0f0ec now uses `readlink -f' which should solve the issue.

gendx commented 9 years ago

Thanks, it works for me! I think that these installation fixes should also be applied to your other projects, such as https://github.com/fbb-git/bisoncpp

fbb-git commented 9 years ago

Dear gendx, you wrote:

Thanks, it works for me!

Thanks for the feedback.

I think that these installation fixes should also be applied to your other projects, such as https://github.com/fbb-git/bisoncpp

Of course. But there is this Dutch saying: the impossible we do immediately, miracles take a bit longer ;-)

I'm working on this...

Cheers,

Frank B. Brokken
Center for Information Technology, University of Groningen
(+31) 50 363 9281 
Public PGP key: http://pgp.surfnet.nl
Key Fingerprint: DF32 13DE B156 7732 E65E  3B4D 7DB2 A8BE EAE4 D8AA
gendx commented 8 years ago

But there is this Dutch saying: the impossible we do immediately, miracles take a bit longer ;-)

Nice one !

I'm working on this...

I'll wait then :)