> On Mar 28, 2016, at 11:54 AM, Ryan Schmidt <ryandes...@macports.org> wrote:
> 
> 
>> On Mar 27, 2016, at 7:14 PM, Abdulrahman Alshammari <a.tu...@hotmail.com> 
>> wrote:
>> 
>> Hey,
>> 
>> I am building a porfile of my software. Originally, the software requires at 
>> least  1.8 Java version. I have found some portfiles in available ports 
>> section, they use pre-fetch to check if the operation system is at least 
>> earlier than a certain version. Can I do that for to check for Java version? 
>> if yes, How can I perform that ?
> 
> You can run commands to determine the java version and compare it against the 
> one you need. You would have to code it in such a way that you also account 
> for the situation where the user does not have any java version installed. I 
> do have java installed, so I'm not completely certain this handles the 
> no-java case correctly, but here's some code I came up with:
> 
> 
>    proc javac_version_ok {min_javac_version} {
>        if {![catch {set javac_long_version [exec javac -version 2>@1]}]} {
>            if {[regexp {^javac (.*)$} $javac_long_version -> javac_version]} {
>                return [expr [vercmp $javac_version $min_javac_version] >= 0]
>            }
>        }
>        return NO;
>    }
> 
>    proc check_javac_version {} {
>        set min_javac_version 1.8
>        if {![javac_version_ok ${min_javac_version}]} {
>            global name version
>            ui_error "${name} @${version} requires java ${min_javac_version} 
> or later"
>            return -code error "incompatible java version"
>        }
>    }
> 
>    pre-archivefetch {
>        check_javac_version
>    }
> 
>    pre-configure {
>        check_javac_version
>    }
> 
> 
> Here I'm assuming java is required both at build time and at runtime. If it's 
> only needed at build time, then you should not use the pre-archivefetch block 
> above.
> 
I really appreciate your support. This is helpful. I found a situation similar 
to this and he add a simple pre-fetch in his portfile. This is what he did:

re-fetch {

if {${os.platform} eq "darwin" && ${os.major} > 10} {

  ui_error "${name} uses deprecated API which has been removed as of Mac OS X 
10.7."

        return -code error "incompatible Mac OS X version"

    }

}
Can I did that to check just the java version? Instead of OS.version?

> 
>> Other question is about file dependencies, Z3 is a theorem prover like CVC4. 
>> Unfortunately, Z3 is not available as a port. How can I deal with this as 
>> file dependency? Please let me know if there is an similar example to my 
>> situation? 
> 
> I don't know what Z3 is, but can you add a port for it?
> 
> 

I can do a port of this tool but I am wondering about the copyright issue. I 
will search on this situation.

Thanks Ryan
_______________________________________________
macports-dev mailing list
macports-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-dev

Reply via email to