[Project_owners] Getting OS and CPU type via XPInstall...

Roland Mainz roland.mainz at nrubsig.org
Mon Feb 9 10:00:59 EST 2004


Patrick Brunschwig wrote:
> > Another problem I hit today while working on my XPI install script:
> > How can I get the OS and the CPU type of the current Mozilla/GRE/MRE
> > etc. ?
> >
> > For example:
> > On Unix/Linux I can do this:
> > * Solaris/SPARC:
> > % uname -s
> > SunOS
> > % uname -p
> > sparc
> >
> > * Linux/x86:
> > % uname -s
> > Linux
> > % uname -p
> > unknown
> > % uname -m
> > i686
> >
> > Does anyone know a way to obtain the same type of information from an
> > XPInstall script ? I'd like to add a check that people cannot install
> > the XPI on a mozilla which cannot execute that type of binaries...
>
> I use this function in Enigmail. I'm sure you can get more info from
> platformNode.

How can I obtain the value for "platformNode" ?

> function getPlatform() {
>   var platformStr;
>   var platformNode;
> 
>   if('platform' in Install) {
>     platformStr = new String(Install.platform);
> 
>     if (!platformStr.search(/^Macintosh/))
>       platformNode = 'mac';
>     else if (!platformStr.search(/^Win/))
>       platformNode = 'win';
>     else
>       platformNode = 'unix';
>   }
[snip]

The problem is: I have to check for the different flavours of
Unix/Linux... e.g. "Solaris" vs. "Linux" vs. "AIX" ... and I have even
to check for the CPU type, e.g. Solaris exists on both SPARC and
x86/x86_64 and Linux... well... x86, IA64, PPC, ARM, MIPS, etc. ... -
the list is endless and I have to provide seperate binaries for all the
different types... ;-(

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 2426 901568 FAX +49 2426 901569
 (;O/ \/ \O;)


More information about the Project_owners mailing list