diff mbox series

package.py: fix Darwin support

Message ID 20240112135252.1871340-1-ecordonnier@snap.com
State Accepted, archived
Commit 248ca79a6400e063c4965f9542c614bf837ff758
Headers show
Series package.py: fix Darwin support | expand

Commit Message

Etienne Cordonnier Jan. 12, 2024, 1:52 p.m. UTC
From: Etienne Cordonnier <ecordonnier@snap.com>

Signed-off-by: Dominik Schnitzer <dominik@snap.com>
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 meta/lib/oe/package.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alexander Kanavin Jan. 12, 2024, 2:05 p.m. UTC | #1
The universal_newlines=True changes need to be explained in the commit
message. Why are they added?

The need for hostos.startswith("darwin") is easier to guess, but that
too, needs an explanation.

Alex

On Fri, 12 Jan 2024 at 14:53, Etienne Cordonnier via
lists.openembedded.org <ecordonnier=snap.com@lists.openembedded.org>
wrote:
>
> From: Etienne Cordonnier <ecordonnier@snap.com>
>
> Signed-off-by: Dominik Schnitzer <dominik@snap.com>
> Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
> ---
>  meta/lib/oe/package.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> index 9a465eaa09..635efc9763 100644
> --- a/meta/lib/oe/package.py
> +++ b/meta/lib/oe/package.py
> @@ -1615,7 +1615,7 @@ def process_shlibs(pkgfiles, d):
>                      sonames.add(prov)
>          if file.endswith('.dylib') or file.endswith('.so'):
>              rpath = []
> -            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> +            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
>              out, err = p.communicate()
>              # If returned successfully, process stdout for results
>              if p.returncode == 0:
> @@ -1624,7 +1624,7 @@ def process_shlibs(pkgfiles, d):
>                      if l.startswith('path '):
>                          rpath.append(l.split()[1])
>
> -        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> +        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
>          out, err = p.communicate()
>          # If returned successfully, process stdout for results
>          if p.returncode == 0:
> @@ -1686,7 +1686,7 @@ def process_shlibs(pkgfiles, d):
>                  soname = None
>                  if cpath.islink(file):
>                      continue
> -                if hostos == "darwin" or hostos == "darwin8":
> +                if hostos.startswith("darwin"):
>                      darwin_so(file, needed, sonames, renames, pkgver)
>                  elif hostos.startswith("mingw"):
>                      mingw_dll(file, needed, sonames, renames, pkgver)
> --
> 2.36.1.vfs.0.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#193581): https://lists.openembedded.org/g/openembedded-core/message/193581
> Mute This Topic: https://lists.openembedded.org/mt/103682827/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Etienne Cordonnier Jan. 12, 2024, 2:59 p.m. UTC | #2
hi Alex,
as far as I know, universal_newlines=True is always required when executing
commands which produce text. I'll send an updated commit, but it's already
used a lot in the code-base, so I didn't think it needed an explanation.
See this example:

>>> p = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
>>> stdout, stderr = p.communicate()
>>> print(stdout)
b'total 32\ndrwxrwxr-x  2 ecordonnier ecordonnier 4096 Sep 19 13:43
classes\ndrwxrwxr-x  3 ecordonnier ecordonnier 4096 Aug 31 17:32
conf\n-rw-rw-r--  1 ecordonnier ecordonnier 1023 Jun 23  2022
COPYING.MIT\n-rw-rw-r--  1 ecordonnier ecordonnier 1946 Sep 19 13:43
README\ndrwxrwxr-x  5 ecordonnier ecordonnier 4096 Jun 23  2022
recipes-core\ndrwxrwxr-x 13 ecordonnier ecordonnier 4096 Aug 31 17:32
recipes-devtools\ndrwxrwxr-x  3 ecordonnier ecordonnier 4096 Aug 31 17:32
recipes-extended\ndrwxrwxr-x  5 ecordonnier ecordonnier 4096 Aug 31 17:32
recipes-support\n'

>>> p = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
>>> stdout, stderr = p.communicate()
>>> print(stdout)
total 32
drwxrwxr-x  2 ecordonnier ecordonnier 4096 Sep 19 13:43 classes
drwxrwxr-x  3 ecordonnier ecordonnier 4096 Aug 31 17:32 conf
-rw-rw-r--  1 ecordonnier ecordonnier 1023 Jun 23  2022 COPYING.MIT
-rw-rw-r--  1 ecordonnier ecordonnier 1946 Sep 19 13:43 README
drwxrwxr-x  5 ecordonnier ecordonnier 4096 Jun 23  2022 recipes-core
drwxrwxr-x 13 ecordonnier ecordonnier 4096 Aug 31 17:32 recipes-devtools
drwxrwxr-x  3 ecordonnier ecordonnier 4096 Aug 31 17:32 recipes-extended
drwxrwxr-x  5 ecordonnier ecordonnier 4096 Aug 31 17:32 recipes-support

On Fri, Jan 12, 2024 at 3:06 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> The universal_newlines=True changes need to be explained in the commit
> message. Why are they added?
>
> The need for hostos.startswith("darwin") is easier to guess, but that
> too, needs an explanation.
>
> Alex
>
> On Fri, 12 Jan 2024 at 14:53, Etienne Cordonnier via
> lists.openembedded.org <ecordonnier=snap.com@lists.openembedded.org>
> wrote:
> >
> > From: Etienne Cordonnier <ecordonnier@snap.com>
> >
> > Signed-off-by: Dominik Schnitzer <dominik@snap.com>
> > Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
> > ---
> >  meta/lib/oe/package.py | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> > index 9a465eaa09..635efc9763 100644
> > --- a/meta/lib/oe/package.py
> > +++ b/meta/lib/oe/package.py
> > @@ -1615,7 +1615,7 @@ def process_shlibs(pkgfiles, d):
> >                      sonames.add(prov)
> >          if file.endswith('.dylib') or file.endswith('.so'):
> >              rpath = []
> > -            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"),
> '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> > +            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"),
> '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> universal_newlines=True)
> >              out, err = p.communicate()
> >              # If returned successfully, process stdout for results
> >              if p.returncode == 0:
> > @@ -1624,7 +1624,7 @@ def process_shlibs(pkgfiles, d):
> >                      if l.startswith('path '):
> >                          rpath.append(l.split()[1])
> >
> > -        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L',
> file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> > +        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L',
> file], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> universal_newlines=True)
> >          out, err = p.communicate()
> >          # If returned successfully, process stdout for results
> >          if p.returncode == 0:
> > @@ -1686,7 +1686,7 @@ def process_shlibs(pkgfiles, d):
> >                  soname = None
> >                  if cpath.islink(file):
> >                      continue
> > -                if hostos == "darwin" or hostos == "darwin8":
> > +                if hostos.startswith("darwin"):
> >                      darwin_so(file, needed, sonames, renames, pkgver)
> >                  elif hostos.startswith("mingw"):
> >                      mingw_dll(file, needed, sonames, renames, pkgver)
> > --
> > 2.36.1.vfs.0.0
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#193581):
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_message_193581&d=DwIBaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=bC-1l9s8NypI08MIH0GkVOLZuK5GhN-8HKGWDd14XzEPV0hokRSMnQool8P_UxeE&s=3np-oDcl19G26iJYYe4LYKJh8dR8GfPupB3gN-3ePOc&e=
> > Mute This Topic:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_mt_103682827_1686489&d=DwIBaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=bC-1l9s8NypI08MIH0GkVOLZuK5GhN-8HKGWDd14XzEPV0hokRSMnQool8P_UxeE&s=2J7mVEMxvnhNr7-F0orRggogqKQzpe1eSjFnvgmGeVU&e=
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_unsub&d=DwIBaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=bC-1l9s8NypI08MIH0GkVOLZuK5GhN-8HKGWDd14XzEPV0hokRSMnQool8P_UxeE&s=iGAXfy_qbvatFl0SoKFI9C8WHypiYGpcAvA1eaP4F8Q&e=
> [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
diff mbox series

Patch

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 9a465eaa09..635efc9763 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1615,7 +1615,7 @@  def process_shlibs(pkgfiles, d):
                     sonames.add(prov)
         if file.endswith('.dylib') or file.endswith('.so'):
             rpath = []
-            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-l', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
             out, err = p.communicate()
             # If returned successfully, process stdout for results
             if p.returncode == 0:
@@ -1624,7 +1624,7 @@  def process_shlibs(pkgfiles, d):
                     if l.startswith('path '):
                         rpath.append(l.split()[1])
 
-        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        p = subprocess.Popen([d.expand("${HOST_PREFIX}otool"), '-L', file], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
         out, err = p.communicate()
         # If returned successfully, process stdout for results
         if p.returncode == 0:
@@ -1686,7 +1686,7 @@  def process_shlibs(pkgfiles, d):
                 soname = None
                 if cpath.islink(file):
                     continue
-                if hostos == "darwin" or hostos == "darwin8":
+                if hostos.startswith("darwin"):
                     darwin_so(file, needed, sonames, renames, pkgver)
                 elif hostos.startswith("mingw"):
                     mingw_dll(file, needed, sonames, renames, pkgver)