diff mbox

[rdma-core,1/3] cbuild: Support distros that only ship python3

Message ID 20180115211347.5651-2-jgg@ziepe.ca (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jason Gunthorpe Jan. 15, 2018, 9:13 p.m. UTC
From: Jason Gunthorpe <jgg@mellanox.com>

SuSE tumbleweed is no longer shipping python2 by default, at least
in the minimal docker image. This breaks cbuild and travis.

Revise this little scriptlet we run in the container to support
both versions of python and use python3 in tumbleweed.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 buildlib/cbuild | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Nicolas Morey-Chaisemartin Jan. 17, 2018, 4:25 p.m. UTC | #1
Le 15/01/2018 à 22:13, Jason Gunthorpe a écrit :
> From: Jason Gunthorpe <jgg@mellanox.com>
>
> SuSE tumbleweed is no longer shipping python2 by default, at least
> in the minimal docker image. This breaks cbuild and travis.
>
> Revise this little scriptlet we run in the container to support
> both versions of python and use python3 in tumbleweed.
>
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
>  buildlib/cbuild | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/buildlib/cbuild b/buildlib/cbuild

I'm guessing this one should probably be backported to the stable branches so they keep working in travis ?
I don't think we need the others.

Can you confirm ?

Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe Jan. 17, 2018, 4:28 p.m. UTC | #2
On Wed, Jan 17, 2018 at 05:25:12PM +0100, Nicolas Morey-Chaisemartin wrote:
> 
> 
> Le 15/01/2018 à 22:13, Jason Gunthorpe a écrit :
> > From: Jason Gunthorpe <jgg@mellanox.com>
> >
> > SuSE tumbleweed is no longer shipping python2 by default, at least
> > in the minimal docker image. This breaks cbuild and travis.
> >
> > Revise this little scriptlet we run in the container to support
> > both versions of python and use python3 in tumbleweed.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> >  buildlib/cbuild | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/buildlib/cbuild b/buildlib/cbuild
> 
> I'm guessing this one should probably be backported to the stable branches so they keep working in travis ?
> I don't think we need the others.
> 
> Can you confirm ?

Makes sense to me, we should have travis working for the stable
branches.. You can use the github UI to construct PRs for the stable
branches if people want to use that?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicolas Morey-Chaisemartin Jan. 17, 2018, 4:31 p.m. UTC | #3
Le 17/01/2018 à 17:28, Jason Gunthorpe a écrit :
> On Wed, Jan 17, 2018 at 05:25:12PM +0100, Nicolas Morey-Chaisemartin wrote:
>>
>> Le 15/01/2018 à 22:13, Jason Gunthorpe a écrit :
>>> From: Jason Gunthorpe <jgg@mellanox.com>
>>>
>>> SuSE tumbleweed is no longer shipping python2 by default, at least
>>> in the minimal docker image. This breaks cbuild and travis.
>>>
>>> Revise this little scriptlet we run in the container to support
>>> both versions of python and use python3 in tumbleweed.
>>>
>>> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
>>>  buildlib/cbuild | 16 ++++++++++------
>>>  1 file changed, 10 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/buildlib/cbuild b/buildlib/cbuild
>> I'm guessing this one should probably be backported to the stable branches so they keep working in travis ?
>> I don't think we need the others.
>>
>> Can you confirm ?
> Makes sense to me, we should have travis working for the stable
> branches.. You can use the github UI to construct PRs for the stable
> branches if people want to use that?
>
> Jason
I know I do check the travis status in my own githup repo before pushing anything to stable.
So I'll backport it.

Thanks

Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/buildlib/cbuild b/buildlib/cbuild
index 3f659bf84ff68d..6e52328d489dea 100755
--- a/buildlib/cbuild
+++ b/buildlib/cbuild
@@ -73,6 +73,7 @@  class DockerFile(object):
         self.lines = ["FROM %s"%(src)];
 
 class Environment(object):
+    python_cmd = "python";
     aliases = set();
     use_make = False;
     proxy = True;
@@ -324,6 +325,9 @@  class tumbleweed(ZypperEnvironment):
     name = "tumbleweed";
     specfile = "suse/rdma-core.spec";
     rpmbuild_options = [ "--without=curlmini" ];
+    # tumbleweed no longer includes python2 in the base docker images, only python3,
+    # use that instead.
+    python_cmd = "python3";
 
 # -------------------------------------------------------------------------
 
@@ -474,17 +478,17 @@  def run_rpm_build(args,spec_file,env):
             print >> F,"""
 import os,subprocess;
 with open("/etc/passwd","a") as F:
-   print >> F, {passwd!r};
+   F.write({passwd!r} + "\\n");
 with open("/etc/group","a") as F:
-   print >> F, {group!r};
+   F.write({group!r} + "\\n");
 os.setgid({gid:d});
 os.setuid({uid:d});
 
 # Get RPM to tell us the expected tar filename.
 for ln in subprocess.check_output(["rpmspec","-P",{tspec_file!r}]).splitlines():
-   if ln.startswith("Source:"):
-      tarfn = ln.strip().partition(' ')[2].strip();
-os.symlink({tarfn!r},os.path.join("SOURCES",tarfn));
+   if ln.startswith(b"Source:"):
+      tarfn = ln.strip().partition(b' ')[2].strip();
+os.symlink({tarfn!r},os.path.join(b"SOURCES",tarfn));
 """.format(passwd=":".join(str(I) for I in pwd.getpwuid(os.getuid())),
            group=":".join(str(I) for I in grp.getgrgid(os.getgid())),
            uid=os.getuid(),
@@ -505,7 +509,7 @@  os.symlink({tarfn!r},os.path.join("SOURCES",tarfn));
         if args.run_shell:
             opts.append("/bin/bash");
         else:
-            opts.extend(["python","go.py"]);
+            opts.extend([env.python_cmd,"go.py"]);
 
         docker_cmd(args,*opts)