From 64108a67f90ef60f54ea65a0c96d45742a650ab3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 8 Jun 2023 13:56:03 +0200 Subject: Handle exported buildfile installation in pkg-bindist --- bpkg/system-package-manager-archive.cxx | 1 + bpkg/system-package-manager-debian.cxx | 11 ++++++ bpkg/system-package-manager-fedora.cxx | 65 +++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/bpkg/system-package-manager-archive.cxx b/bpkg/system-package-manager-archive.cxx index 1278330..2639bb1 100644 --- a/bpkg/system-package-manager-archive.cxx +++ b/bpkg/system-package-manager-archive.cxx @@ -430,6 +430,7 @@ namespace bpkg add ("include_arch=include/"); add ("share=data_root/share/"); add ("data=share///"); + add ("buildfile=share/build2/export//"); add ("doc=share/doc///"); add ("legal=doc/"); diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx index 08767d3..8b27e37 100644 --- a/bpkg/system-package-manager-debian.cxx +++ b/bpkg/system-package-manager-debian.cxx @@ -2152,6 +2152,7 @@ namespace bpkg "config.install.include_arch='data_root/include/$(DEB_HOST_MULTIARCH)//'", "config.install.share=data_root/share/", "config.install.data=share///", + "config.install.buildfile=share/build2/export//", "config.install.doc=share/doc///", "config.install.legal=doc/", @@ -2213,11 +2214,17 @@ namespace bpkg // NOTE: keep consistent with the config.install.* values above. // + // We put exported buildfiles into the main package, which makes sense + // after some meditation: they normally contain rules and are bundled + // either with a tool (say, thrift), a module (say, libbuild2-thrift), or + // an add-on package (say, thrift-build2). + // dir_path bindir ("/usr/bin/"); dir_path sbindir ("/usr/sbin/"); dir_path etcdir ("/etc/"); dir_path incdir ("/usr/include/" + pd); dir_path incarchdir ("/usr/include/$(DEB_HOST_MULTIARCH)/" + pd); + //dir_path bfdir ("/usr/share/build2/export/"); dir_path libdir ("/usr/lib/$(DEB_HOST_MULTIARCH)/" + pd); dir_path pkgdir (libdir / dir_path ("pkgconfig")); dir_path sharedir ("/usr/share/" + pd); @@ -2295,6 +2302,8 @@ namespace bpkg // if (!gen_main) { + // Note: covers bfdir. + // for (auto p (ies.find_sub (sharedir)); p.first != p.second; ++p.first) { const path& f (p.first->first); @@ -3380,6 +3389,8 @@ namespace bpkg // if (gen_main) { + // Note: covers bfdir. + // for (auto p (ies.find_sub (sharedir)); p.first != p.second; ) { const path& f ((p.first++)->first); diff --git a/bpkg/system-package-manager-fedora.cxx b/bpkg/system-package-manager-fedora.cxx index 4034932..5537f7a 100644 --- a/bpkg/system-package-manager-fedora.cxx +++ b/bpkg/system-package-manager-fedora.cxx @@ -2588,6 +2588,7 @@ namespace bpkg "config.install.include_arch=include/", "config.install.share=%{_datadir}/", "config.install.data=share///", + "config.install.buildfile=share/build2/export//", "config.install.doc=%{_docdir}///", "config.install.legal=%{_licensedir}///", @@ -2627,17 +2628,24 @@ namespace bpkg // Installed entry directories for sorting out the installed files into // the %files sections of the sub-packages. // + // We put exported buildfiles into the main package, which makes sense + // after some meditation: they normally contain rules and are bundled + // either with a tool (say, thrift), a module (say, libbuild2-thrift), or + // an add-on package (say, thrift-build2). + // dir_path bindir; dir_path sbindir; dir_path libexecdir; dir_path confdir; dir_path incdir; + dir_path bfdir; dir_path libdir; dir_path pkgdir; // Not queried, set as libdir/pkgconfig/. dir_path sharedir; dir_path docdir; dir_path mandir; dir_path licensedir; + dir_path build2dir; // Note that the ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} // directory paths used by rpmbuild are actually defined as the @@ -2757,7 +2765,10 @@ namespace bpkg licensedir = pop_dir () / pd; mandir = pop_dir (); docdir = pop_dir () / pd; - sharedir = pop_dir () / pd; + sharedir = pop_dir (); + build2dir = sharedir / dir_path ("build2"); + bfdir = build2dir / dir_path ("export"); + sharedir /= pd; libdir = pop_dir () / pd; pkgdir = libdir / dir_path ("pkgconfig"); incdir = pop_dir () / pd; @@ -2916,6 +2927,15 @@ namespace bpkg << os_release.name_id << " name mapping in package manifest"; } } + + for (auto p (ies.find_sub (bfdir)); p.first != p.second; ++p.first) + { + const path& f (p.first->first); + + fail << "binless library " << pn << ' ' << pv << " installs " << f << + info << "consider specifying -common package in explicit " + << os_release.name_id << " name mapping in package manifest"; + } } if (verb >= 3) @@ -4018,7 +4038,7 @@ namespace bpkg // We cannot just do usr/share/* since it will clash with doc/, man/, // and licenses/ below. So we have to list all the top-level entries - // in usr/share/ that are not doc/, man/, or licenses/. + // in usr/share/ that are not doc/, man/, licenses/, or build2/. // if (gen_main) { @@ -4034,7 +4054,10 @@ namespace bpkg { const path& f ((p.first++)->first); - if (f.sub (docdir) || f.sub (mandir) || f.sub (licensedir)) + if (f.sub (docdir) || + f.sub (mandir) || + f.sub (licensedir) || + f.sub (build2dir)) continue; path l (f.leaf (sharedir)); @@ -4073,6 +4096,42 @@ namespace bpkg *private_owner += "%dir %{_datadir}/" + pd + '\n'; } + // Note that we only consider the bfdir//* sub-entries, + // adding the bfdir// subdirectories to the %files + // section. This way no additional directory ownership entry needs to + // be added. Any immediate sub-entries of bfdir/, if present, will be + // ignored, which will end up with the 'unpackaged files' rpmbuild + // error. + // + // Also note that the bfdir/ directory is not owned by any package. + // + if (gen_main) + { + for (auto p (ies.find_sub (bfdir)); p.first != p.second; ) + { + const path& f ((p.first++)->first); + + path l (f.leaf (bfdir)); + + if (!l.simple ()) + { + // Let's keep things tidy and use a sub-directory rather than + // listing all its sub-entries verbatim. + // + dir_path sd (*l.begin ()); + + main += "%{_datadir}/build2/export/" + sd.string () + '/' + '\n'; + + // Skip all the other entries in this subdirectory (in the + // prefix map they will all be in a contiguous range). + // + dir_path d (bfdir / sd); + while (p.first != p.second && p.first->first.sub (d)) + ++p.first; + } + } + } + // Should we put the documentation into -common if there is no -doc? // While there doesn't seem to be anything explicit in the policy, // there are packages that do it this way (e.g., mariadb-common). And -- cgit v1.1