[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to test for architecture in perl base pre/postinst scripts ?

On Tue, 24 Feb 2004, Sven Luther wrote:
> On Mon, Feb 23, 2004 at 11:20:10AM -0800, Don Armstrong wrote:
> > On Mon, 23 Feb 2004, Sven Luther wrote:
> > > Yeah, seems reasonable, now i only need to find out how to call it
> > > from perl.
> > 
> > %arch = split /[=\n]/, qx(dpkg-architecture) or die q(dpkg-architecture failed);
> > 
> > should do nicely. [dpkg-architecture should exist once dpkg has been
> > unpacked...]
> Mmm, the following was recomended to me :
>   # Get the architecture we are running on, to set silent_modules on powerpc.
>   open(FILE, "dpkg-architecture -qDEB_HOST_ARCH |");
>   undef $/;
>   $arch = <FILE>;
>   close(FILE);
> As said, i am no perl expert, is this better or worse than your solution ? 

It's slightly different because it only gives you DEB_HOST_ARCH, but
if that's all you're interested in, it might be better to use that

Frankly though, there is no reason to explicitely open a FILEHANDLE to
dpkg-architecture when qx() or `` does this for you automatically
while enhancing readability. [Moreover, the above code doesn't check
for dpkg-architecture failing and giving you garbage...]

  $arch = qx(dpkg-architecture -qDEB_HOST_ARCH);
  die "dpkg-architecture failed with $?" if $?;

But, again, TMTOWTDI.

Don Armstrong

I now know how retro SCOs OSes are. Riotous, riotous stuff. How they
had the ya-yas to declare Linux an infant OS in need of their IP is
beyond me. Upcoming features? PAM. files larger than 2 gigs. NFS over
TCP. The 80's called, they want their features back.
 -- Compactable Dave http://www3.sympatico.ca/dcarpeneto/sco.html


Attachment: signature.asc
Description: Digital signature

Reply to: