How to abort a macports portfile on an error condition?

47 views Asked by At

I working on a version bump on the cc65 and encountered a problem with the linuxdoc-tools. Since I can't fix the linuxdoc-tools and there is a simple workaround possible I decided to add an if statement to inform the user together with the workaround:

    if {! [file exists ${prefix}/bin/perl] } {
        ui_error "
«${prefix}/bin/perl» is missing but the linuxdoc-tools depends on it.

Please create an appropriate symbolic link for linuxdoc-tools to work.
"
    exit 1
    }

Crude but the best I can do since I'm neither the perl5 nor the linuxdoc-tools maintainer and I don't want to spend to much time on a version bump.

However, the MacPorts doesn't understand exit 1 and ui_error won't stop execution on its own.

How do I stop the execution so not to waste the users time on a build which will otherwise fail right at the end.

1

There are 1 answers

2
neverpanic On

Use return -code error "error message", or the shorthand for the same thing, error "error message".

Note that you should use ui_error before that to print a human-readable message for the user – while the error message is also being printed, it can sometimes get lost in the output.

Additionally, note that $prefix/bin/perl is a build dependency of linuxdoc-tools. If it is also needed at runtime, you should submit a pull request that adds depends_run path:bin/perl:perl5 to the port rather than attempting to fix this bug in your port.