Package: meson Version: 0.42.1-1 File: /usr/share/meson/debcrossgen Tags: patch User: helm...@debian.org Usertags: rebootstrap
Hi Jussi, Thanks for uploading debcrossgen. Unfortunately, the present debcrossgen is not useable, because it hard codes a non-default gcc (-6). Such a gcc is not installed by default. I'm not sure why you felt the need to append a version, but my attached patch supports your need by adding a --gccsuffix option to debcrossgen while defaulting to an unversioned gcc as is expected by most Debian packages. I also made it honour the environment variables CC and CXX by default. I took some time looking into the cpu and cpu_family variables and am a little confused what to put there. Experimentation with native meson shows the following strange results: debarch cpu cpu_family arm64 aarch64 aarch64 armel arm armv7l i386 i686 x86 mips mips64 mips64 mipsel mips64 mips64 powerpc ppc64 ppc64 ppc64el ppc64le ppc64le s390x s390x s390x At least mips, mipsel and powerpc look strange. Since this looks like a mess for the native case, I didn't try fixing debcrossgen. I'm not sure why all the tools use absolute paths, but I implemented that path lookup generically now. If it turns out to be unnecessary, you can remove it. Can you apply the attached patch? Helmut
diff --minimal -Nru meson-0.42.1/debian/debcrossgen meson-0.42.1/debian/debcrossgen --- meson-0.42.1/debian/debcrossgen 2017-09-12 18:37:59.000000000 +0200 +++ meson-0.42.1/debian/debcrossgen 2017-09-13 18:43:19.000000000 +0200 @@ -28,14 +28,25 @@ parser.add_argument('--arch', default=None, help='The dpkg architecture to generate.') +parser.add_argument('--gccsuffix', default="", + help='A particular gcc version suffix if necessary.') parser.add_argument('-o', required=True, dest='outfile', help='The output file.') -def run(arch, ofilename): - if arch is None: +def locate_path(program): + if os.path.isabs(program): + return program + for d in os.get_exec_path(): + f = os.path.join(d, program) + if os.access(f, os.X_OK): + return f + raise ValueError("%s not found on $PATH" % program) + +def run(options): + if options.arch is None: cmd = ['dpkg-architecture'] else: - cmd = ['dpkg-architecture', '-a' + arch] + cmd = ['dpkg-architecture', '-a' + options.arch] output = subprocess.check_output(cmd, universal_newlines=True) data = {} for line in output.split('\n'): @@ -49,22 +60,23 @@ host_cpu_family = data['DEB_HOST_GNU_CPU'] host_cpu = data['DEB_HOST_ARCH'] # Not really correct, should be arm7hlf etc but it is not exposed. host_endian = data['DEB_HOST_ARCH_ENDIAN'] - ofile = open(ofilename, 'w') - ofile.write('[binaries]\n') - ofile.write("c = '/usr/bin/%s-gcc-6'\n" % host_arch) - ofile.write("cpp = '/usr/bin/%s-g++-6'\n" % host_arch) - ofile.write("ar = '/usr/bin/%s-ar'\n" % host_arch) - ofile.write("strip = '/usr/bin/%s-strip'\n" % host_arch) - ofile.write("pkgconfig = '/usr/bin/%s-pkg-config'\n" % host_arch) - ofile.write('\n[properties]\n') - ofile.write('\n[host_machine]\n') - ofile.write("system = '%s'\n" % host_os) - ofile.write("cpu_family = '%s'\n" % host_cpu_family) - ofile.write("cpu = '%s'\n" % host_cpu) - ofile.write("endian = '%s'\n" % host_endian) - ofile.close() + with open(options.outfile, "w") as ofile: + ofile.write('[binaries]\n') + c = os.environ.get("CC", "%s-gcc%s" % (host_arch, options.gccsuffix)) + ofile.write("c = '%s'\n" % locate_path(c)) + cpp = os.environ.get("CXX", "%s-g++%s" % (host_arch, options.gccsuffix)) + ofile.write("cpp = '%s'\n" % locate_path(cpp)) + ofile.write("ar = '%s'\n" % locate_path("%s-ar" % host_arch)) + ofile.write("strip = '%s'\n" % locate_path("%s-strip" % host_arch)) + ofile.write("pkgconfig = '%s'\n" % locate_path("%s-pkg-config" % host_arch)) + ofile.write('\n[properties]\n') + ofile.write('\n[host_machine]\n') + ofile.write("system = '%s'\n" % host_os) + ofile.write("cpu_family = '%s'\n" % host_cpu_family) + ofile.write("cpu = '%s'\n" % host_cpu) + ofile.write("endian = '%s'\n" % host_endian) if __name__ == '__main__': options = parser.parse_args() - run(options.arch, options.outfile) + run(options) print('Remember to add the proper --libdir arg to Meson invocation.')