mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] system bash replacement
@ 2017-09-09  8:59 Erwin Rol
  2017-09-11  8:28 ` Michael Olbrich
  0 siblings, 1 reply; 4+ messages in thread
From: Erwin Rol @ 2017-09-09  8:59 UTC (permalink / raw)
  To: ptxdist

Hallo All,

I have several (older) CentOS 6.X (and even 5.X :-/ ) systems that have
bash 4.1.2 which is to old for newer ptxdist releases.

Ptxdist checks for several tools and places links in its $PTXDIR/bin/
dir. Tools include cp, ls, awk, and bash. The ptxdist $PTXDIR/bin/ dir
is placed in PATH so those links in $PTXDIR/bin/ are found first.

But! all ptxdist scripts have "#!/bin/bash" in them, so that bash link
in $PTXDIR/bin/ is never used. 

I have some success by replacing "#!/bin/bash" with "#!/usr/bin/env
bash" but before I go ahead with that I would like to hear if someone
already tried that and failed (or succeeded).

BTW the same for the python link, scripts with #!/bin/python  will not
use it. 

- Erwin



_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ptxdist] system bash replacement
  2017-09-09  8:59 [ptxdist] system bash replacement Erwin Rol
@ 2017-09-11  8:28 ` Michael Olbrich
  2017-09-11  8:59   ` Erwin Rol
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Olbrich @ 2017-09-11  8:28 UTC (permalink / raw)
  To: ptxdist

Hi,

On Sat, Sep 09, 2017 at 10:59:34AM +0200, Erwin Rol wrote:
> I have several (older) CentOS 6.X (and even 5.X :-/ ) systems that have
> bash 4.1.2 which is to old for newer ptxdist releases.
> 
> Ptxdist checks for several tools and places links in its $PTXDIR/bin/
> dir. Tools include cp, ls, awk, and bash. The ptxdist $PTXDIR/bin/ dir
> is placed in PATH so those links in $PTXDIR/bin/ are found first.
> 
> But! all ptxdist scripts have "#!/bin/bash" in them, so that bash link
> in $PTXDIR/bin/ is never used. 
> 
> I have some success by replacing "#!/bin/bash" with "#!/usr/bin/env
> bash" but before I go ahead with that I would like to hear if someone
> already tried that and failed (or succeeded).
> 
> BTW the same for the python link, scripts with #!/bin/python  will not
> use it. 

I've never tried this, but I had some ideas:

1. We already set SHELL=$(PTXDIST_TOPDIR)/bin/bash in
   rules/other/Toplevel.make so that handles some of it.
2. PTXdist itself is a problem. I had some ideas about re-executing ptxdist
   if the shell is different from $(PTXDIST_TOPDIR)/bin/bash.

That should help for PTXdist. Most files are not directly executed so the
shebang is just cosmetics.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ptxdist] system bash replacement
  2017-09-11  8:28 ` Michael Olbrich
@ 2017-09-11  8:59   ` Erwin Rol
  2017-09-13 14:57     ` Michael Olbrich
  0 siblings, 1 reply; 4+ messages in thread
From: Erwin Rol @ 2017-09-11  8:59 UTC (permalink / raw)
  To: ptxdist

On Mon, 2017-09-11 at 10:28 +0200, Michael Olbrich wrote:
> Hi,
> 
> On Sat, Sep 09, 2017 at 10:59:34AM +0200, Erwin Rol wrote:
> > I have several (older) CentOS 6.X (and even 5.X :-/ ) systems that have
> > bash 4.1.2 which is to old for newer ptxdist releases.
> > 
> > Ptxdist checks for several tools and places links in its $PTXDIR/bin/
> > dir. Tools include cp, ls, awk, and bash. The ptxdist $PTXDIR/bin/ dir
> > is placed in PATH so those links in $PTXDIR/bin/ are found first.
> > 
> > But! all ptxdist scripts have "#!/bin/bash" in them, so that bash link
> > in $PTXDIR/bin/ is never used. 
> > 
> > I have some success by replacing "#!/bin/bash" with "#!/usr/bin/env
> > bash" but before I go ahead with that I would like to hear if someone
> > already tried that and failed (or succeeded).
> > 
> > BTW the same for the python link, scripts with #!/bin/python  will not
> > use it. 
> 
> I've never tried this, but I had some ideas:
> 
> 1. We already set SHELL=$(PTXDIST_TOPDIR)/bin/bash in
>    rules/other/Toplevel.make so that handles some of it.
> 2. PTXdist itself is a problem. I had some ideas about re-executing ptxdist
>    if the shell is different from $(PTXDIST_TOPDIR)/bin/bash.

I already have some "wrapper" around ptxdist so I have a bash there and
that is first in the path so "#!/usr/bin/env bash" works for me. But
that surely isn't a general solution for ptxdist.  

BTW I found out the awk should be version checked, cause the CentOS 6
awk silently fails, causing the dependencies to be not generated and so
building just starts with some random package. 

In the end things still didn't want to work right. So I ended up
creating a chroot where I bind mount everything from the host under
host_root. Than create a bin dir  and symlink everything from
host_root/bin/. Than replace the bash link with the new bash (and the
same with the awk). The other dirs like lib, etc, opt I just ln to the
dir in host_root. After that I can chroot in it and everything looks
like my host but with a new shell and awk. Also had to get a new host
GCC (4.4.8 is to old for the toolchain building). But in the end I was
able to build the lastest ptxdist toolchain on Centos 6 without changing
the host OS. 

It is like a mini "container", if I would selectively setup usr/lib/ and
usr/include it could also be used to prevent pulling in host stuff. 

- Erwin


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ptxdist] system bash replacement
  2017-09-11  8:59   ` Erwin Rol
@ 2017-09-13 14:57     ` Michael Olbrich
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Olbrich @ 2017-09-13 14:57 UTC (permalink / raw)
  To: ptxdist

On Mon, Sep 11, 2017 at 10:59:09AM +0200, Erwin Rol wrote:
> On Mon, 2017-09-11 at 10:28 +0200, Michael Olbrich wrote:
> > On Sat, Sep 09, 2017 at 10:59:34AM +0200, Erwin Rol wrote:
> > > I have several (older) CentOS 6.X (and even 5.X :-/ ) systems that have
> > > bash 4.1.2 which is to old for newer ptxdist releases.
> > > 
> > > Ptxdist checks for several tools and places links in its $PTXDIR/bin/
> > > dir. Tools include cp, ls, awk, and bash. The ptxdist $PTXDIR/bin/ dir
> > > is placed in PATH so those links in $PTXDIR/bin/ are found first.
> > > 
> > > But! all ptxdist scripts have "#!/bin/bash" in them, so that bash link
> > > in $PTXDIR/bin/ is never used. 
> > > 
> > > I have some success by replacing "#!/bin/bash" with "#!/usr/bin/env
> > > bash" but before I go ahead with that I would like to hear if someone
> > > already tried that and failed (or succeeded).
> > > 
> > > BTW the same for the python link, scripts with #!/bin/python  will not
> > > use it. 
> > 
> > I've never tried this, but I had some ideas:
> > 
> > 1. We already set SHELL=$(PTXDIST_TOPDIR)/bin/bash in
> >    rules/other/Toplevel.make so that handles some of it.
> > 2. PTXdist itself is a problem. I had some ideas about re-executing ptxdist
> >    if the shell is different from $(PTXDIST_TOPDIR)/bin/bash.
> 
> I already have some "wrapper" around ptxdist so I have a bash there and
> that is first in the path so "#!/usr/bin/env bash" works for me. But
> that surely isn't a general solution for ptxdist.  

Yes that not so nice. That should be handled in ptxdist. We could add some
early check like this (untested):

if [ "$BASH_VERSION" != "$($(dirname $0)/bash -c 'echo $BASH_VERSION')" ]; then
	exec "$(dirname $0)/bash" "${0}" "${@}"
fi

Or something like that.

> BTW I found out the awk should be version checked, cause the CentOS 6
> awk silently fails, causing the dependencies to be not generated and so
> building just starts with some random package. 

A patch for configure.ac would be great :-)

> In the end things still didn't want to work right. So I ended up
> creating a chroot where I bind mount everything from the host under
> host_root. Than create a bin dir  and symlink everything from
> host_root/bin/. Than replace the bash link with the new bash (and the
> same with the awk). The other dirs like lib, etc, opt I just ln to the
> dir in host_root. After that I can chroot in it and everything looks
> like my host but with a new shell and awk. Also had to get a new host
> GCC (4.4.8 is to old for the toolchain building). But in the end I was
> able to build the lastest ptxdist toolchain on Centos 6 without changing
> the host OS. 
> 
> It is like a mini "container", if I would selectively setup usr/lib/ and
> usr/include it could also be used to prevent pulling in host stuff. 

So what else fails? Is it within ptxdist or while building packages?

Regards,
Michael


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-13 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-09  8:59 [ptxdist] system bash replacement Erwin Rol
2017-09-11  8:28 ` Michael Olbrich
2017-09-11  8:59   ` Erwin Rol
2017-09-13 14:57     ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox