Re: Java Version required to be checked.

2016-03-29 Thread Russell Jones

Hi Abdulrahman,

Do you mean this Z3? https://github.com/Z3Prover/z3 It appears to be MIT 
licensed.


Russell

On 29/03/16 00:22, Abdulrahman Alshammari wrote:


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


Re: Java Version required to be checked.

2016-03-28 Thread Abdulrahman Alshammari
Thank you so much for your support. I get the idea now. 
> On Mar 28, 2016, at 9:08 PM, Ryan Schmidt  wrote:
> 
>> 
>> On Mar 28, 2016, at 6:22 PM, Abdulrahman Alshammari  
>> wrote:
>> 
>>> 
>>> On Mar 28, 2016, at 11:54 AM, Ryan Schmidt  wrote:
>>> 
>>> 
 On Mar 27, 2016, at 7:14 PM, Abdulrahman Alshammari  
 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?
> 
> There isn't a variable built in to MacPorts that represents the Java version, 
> as there is for the OS version. That's why you have to compute the Java 
> version yourself, for example using the code I provided.
> 
> OS version checks are typically done in pre-fetch, because if a port won't 
> work on your OS version, you don't want to waste time downloading a file 
> before finding that out, since upgrading the OS is something you may not want 
> or be able to do. On the other hand, upgrading Java is simple enough to do, 
> so I suggest doing that check in pre-configure (for source builds) and 
> pre-archivefetch (for binary installations).
> 
> 
> 
 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.

___
macports-dev mailing list
macports-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-dev


Re: Java Version required to be checked.

2016-03-28 Thread Ryan Schmidt

> On Mar 28, 2016, at 6:22 PM, Abdulrahman Alshammari  
> wrote:
> 
>> 
>> On Mar 28, 2016, at 11:54 AM, Ryan Schmidt  wrote:
>> 
>> 
>>> On Mar 27, 2016, at 7:14 PM, Abdulrahman Alshammari  
>>> 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?

There isn't a variable built in to MacPorts that represents the Java version, 
as there is for the OS version. That's why you have to compute the Java version 
yourself, for example using the code I provided.

OS version checks are typically done in pre-fetch, because if a port won't work 
on your OS version, you don't want to waste time downloading a file before 
finding that out, since upgrading the OS is something you may not want or be 
able to do. On the other hand, upgrading Java is simple enough to do, so I 
suggest doing that check in pre-configure (for source builds) and 
pre-archivefetch (for binary installations).



>>> 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.




___
macports-dev mailing list
macports-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-dev


Re: Java Version required to be checked.

2016-03-28 Thread Abdulrahman Alshammari

> On Mar 28, 2016, at 11:54 AM, Ryan Schmidt  wrote:
> 
> 
>> On Mar 27, 2016, at 7:14 PM, Abdulrahman Alshammari  
>> 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


Re: Java Version required to be checked.

2016-03-28 Thread Ryan Schmidt

> On Mar 27, 2016, at 7:14 PM, Abdulrahman Alshammari  
> 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.


> 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?


___
macports-dev mailing list
macports-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/macports-dev