Bug 168253 - app-arch/rpm2targz is incompatible with fbsd's sh
Bug#: 168253 Product:  Gentoo/Alt Version: unspecified Platform: x86
OS/Version: FreeBSD Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: maintainer-needed@gentoo.org Reported By: zephyrus.271@gmail.com
Component: FreeBSD
URL: 
Summary: app-arch/rpm2targz is incompatible with fbsd's sh
Keywords:  
Status Whiteboard: 
Opened: 2007-02-24 18:26 0000
Description:   Opened: 2007-02-24 18:26 0000
There are two lines in the rpm2targz script which cause errors on g/fbsd due to
their incompatibility with fbsd's sh:

1] line 26 -> [ "$TMPDIR" == "" ] && TMPDIR=/tmp

   The correct expression, compatibile with the sh syntax, is with only one 
   equal sign, so:
   [ "$TMPDIR" = "" ] && TMPDIR=/tmp

2] line 91 -> if echo ${PAYLOADHEAD} | grep -e $'^\037\213' > /dev/null ; then

   This line fails due to the fact that the $'' construct is unsupported, as
   noted by exg, and therefore grep interprets \037 and \213 as backward
   expressions, instead of the considering the respective non-printable
   characters (which are the magic bytes of the gzip format).
   A possibile solution could be to filter PAYLOADHEAD trough `od -c` and then
   simply: grep -e '037.213'

However as Flameeyes noted, the most simple (yet effective) solution is to use
bash instead of sh to parse the script.

Reproducible: Always

Steps to Reproduce:

------- Comment #1 From Diego E. 'Flameeyes' Pettenò 2007-06-18 11:53:57 0000 -------
I have committed the fix; as with the new baselayout we might have more people
having /bin/sh not linked to bash, I've followed exg's suggestion and used od
-c.