Update to v0.14.0

* .gitignore, sources: Update to v0.14.0
 * bpkg-openssl-3-pkeyutl.patch, libbutl-openssl-info-overloads.patch: add patches for OpenSSL v3.0 support [1]
 * build2-disable-test-cc-modules-ppc64le.patch: add patch to disable failing C++ modules tests on PPC64LE
 * build2.spec:
    - Update to v0.14.0
    - Re-enable bootstrap required for this releas
    - Update comments on libbutl license
    - Use config.install.etc for specifying system configuration file directory
    - Use config.install.scope to prevent installing statically built, bundled libodb [2,3]
 * libbuild2-config.install.scope-no-update-for-install.patch: add patch to make config.install.scope not apply during update-for-install pre-operation [3]
 * macros.build2:
    - Use config.install.legal for specifying system configuration file directory

[1] https://lists.build2.org/archives/users/2021-November/000923.html
[2] https://lists.build2.org/archives/announce/2021/000021.html
[3] https://lists.build2.org/archives/users/2021-November/000919.html
This commit is contained in:
Matthew Krupcale 2022-01-23 18:21:24 -05:00
parent 740f047cb9
commit babacf4446
8 changed files with 720 additions and 42 deletions

14
.gitignore vendored
View File

@ -1,7 +1,7 @@
/build2-0.13.0.tar.gz
/libbutl-0.13.0.tar.gz
/libbpkg-0.13.0.tar.gz
/bpkg-0.13.0.tar.gz
/bdep-0.13.0.tar.gz
/libodb-2.5.0-b.19.tar.gz
/libodb-sqlite-2.5.0-b.19.tar.gz
/build2-0.14.0.tar.gz
/libbutl-0.14.0.tar.gz
/libbpkg-0.14.0.tar.gz
/bpkg-0.14.0.tar.gz
/bdep-0.14.0.tar.gz
/libodb-2.5.0-b.21.tar.gz
/libodb-sqlite-2.5.0-b.21.tar.gz

View File

@ -0,0 +1,231 @@
From 073f4ed111b0b10dcbd81fc112f9d66e41f40fac Mon Sep 17 00:00:00 2001
From: Karen Arutyunov <karen@codesynthesis.com>
Date: Wed, 17 Nov 2021 17:43:22 +0300
Subject: Use pkeyutl command instead of rsautl starting openssl version 3.0.0
---
bpkg/auth.cxx | 81 +++++++++++++++++++++++++++++++++++++++------
bpkg/auth.hxx | 14 +++-----
bpkg/common.cli | 12 ++++---
bpkg/options-types.hxx | 2 +-
bpkg/repository-signing.cli | 8 +++--
5 files changed, 89 insertions(+), 28 deletions(-)
diff --git a/bpkg/auth.cxx b/bpkg/auth.cxx
index 93c88f5..85cf5fa 100644
--- a/bpkg/auth.cxx
+++ b/bpkg/auth.cxx
@@ -12,6 +12,7 @@
#include <libbutl/openssl.hxx>
#include <libbutl/timestamp.hxx>
#include <libbutl/filesystem.hxx>
+#include <libbutl/semantic-version.hxx>
#include <bpkg/package.hxx>
#include <bpkg/package-odb.hxx>
@@ -23,10 +24,14 @@ using namespace butl;
namespace bpkg
{
- static const string openssl_rsautl ("rsautl");
- static const string openssl_x509 ("x509");
-
- const char* openssl_commands[3] = {openssl_rsautl.c_str (),
+ static const string openssl_version ("version");
+ static const string openssl_pkeyutl ("pkeyutl");
+ static const string openssl_rsautl ("rsautl");
+ static const string openssl_x509 ("x509");
+
+ const char* openssl_commands[5] = {openssl_version.c_str (),
+ openssl_pkeyutl.c_str (),
+ openssl_rsautl.c_str (),
openssl_x509.c_str (),
nullptr};
@@ -39,6 +44,49 @@ namespace bpkg
print_process (args, n);
}
+ // Return true if the openssl version is greater or equal to 3.0.0 and so
+ // pkeyutl needs to be used instead of rsautl. Cache the result on the first
+ // function call.
+ //
+ // Note that openssl 3.0.0 deprecates rsautl in favor of pkeyutl.
+ //
+ // Also note that pkeyutl is only implemented in openssl version 1.0.0 and
+ // its -verifyrecover mode is broken in the [1.1.1 1.1.1d] version range
+ // (see the 'pkeyutl -verifyrecover error "input data too long to be a
+ // hash"' issue report for details).
+ //
+ static optional<bool> use_pkeyutl;
+
+ static bool
+ use_openssl_pkeyutl (const common_options& co)
+ {
+ if (!use_pkeyutl)
+ {
+ const path& openssl_path (co.openssl ()[openssl_version]);
+
+ try
+ {
+ optional<openssl_info> oi (
+ openssl::info (print_command, 2, openssl_path));
+
+ use_pkeyutl = oi &&
+ oi->name == "OpenSSL" &&
+ oi->version >= semantic_version {3, 0, 0};
+ }
+ catch (const process_error& e)
+ {
+ fail << "unable to execute " << openssl_path << ": " << e << endf;
+ }
+ catch (const io_error& e)
+ {
+ fail << "unable to read '" << openssl_path << "' output: " << e
+ << endf;
+ }
+ }
+
+ return *use_pkeyutl;
+ }
+
// Find the repository location prefix that ends with the version component.
// We consider all repositories under this location to be related.
//
@@ -829,15 +877,22 @@ namespace bpkg
dr << ": " << *e;
};
- const path& openssl_path (co.openssl ()[openssl_rsautl]);
- const strings& openssl_opts (co.openssl_option ()[openssl_rsautl]);
+ bool ku (use_openssl_pkeyutl (co));
+ const string& cmd (ku ? openssl_pkeyutl : openssl_rsautl);
+
+ const path& openssl_path (co.openssl ()[cmd]);
+ const strings& openssl_opts (co.openssl_option ()[cmd]);
try
{
openssl os (print_command,
path ("-"), fdstream_mode::text, 2,
- openssl_path, openssl_rsautl,
- openssl_opts, "-verify", "-certin", "-inkey", f);
+ openssl_path, cmd,
+ openssl_opts,
+ ku ? "-verifyrecover" : "-verify",
+ "-certin",
+ "-inkey",
+ f);
for (const auto& c: sm.signature)
os.out.put (c); // Sets badbit on failure.
@@ -918,14 +973,18 @@ namespace bpkg
dr << ": " << *e;
};
- const path& openssl_path (co.openssl ()[openssl_rsautl]);
- const strings& openssl_opts (co.openssl_option ()[openssl_rsautl]);
+ const string& cmd (use_openssl_pkeyutl (co)
+ ? openssl_pkeyutl
+ : openssl_rsautl);
+
+ const path& openssl_path (co.openssl ()[cmd]);
+ const strings& openssl_opts (co.openssl_option ()[cmd]);
try
{
openssl os (print_command,
fdstream_mode::text, path ("-"), 2,
- openssl_path, openssl_rsautl,
+ openssl_path, cmd,
openssl_opts, "-sign", "-inkey", key_name);
os.out << sha256sum;
diff --git a/bpkg/auth.hxx b/bpkg/auth.hxx
index 4cd2e56..54e6884 100644
--- a/bpkg/auth.hxx
+++ b/bpkg/auth.hxx
@@ -79,15 +79,11 @@ namespace bpkg
// openssl x509 -noout -modulus -in cert.pem
// openssl rsa -noout -modulus -in key.pem
//
- // But taking into account that we need to be able to use custom engines to
- // access keys, it seems to be impossible to provide the same additional
- // openssl options to fit both the rsa and pkeyutl commands. The first would
- // require "-engine pkcs11 -inform engine", while the second -- "-engine
- // pkcs11 -keyform engine". Also it would require to enter the key password
- // again, which is a showstopper. Maybe the easiest would be to recover the
- // sum back from the signature using the certificate, and compare it with
- // the original sum (like we do in authenticate_repository()). But that
- // would require to temporarily save the certificate to file.
+ // However, it would require to enter the key password again, which is a
+ // showstopper. Maybe the easiest would be to recover the sum back from the
+ // signature using the certificate, and compare it with the original sum
+ // (like we do in authenticate_repository()). But that would require to
+ // temporarily save the certificate to file.
//
std::vector<char>
sign_repository (const common_options&,
diff --git a/bpkg/common.cli b/bpkg/common.cli
index 5f67357..dd0417d 100644
--- a/bpkg/common.cli
+++ b/bpkg/common.cli
@@ -287,13 +287,17 @@ namespace bpkg
only applicable to the specific command, for example:
\
- bpkg rep-create \
- --openssl rsautl:/path/to/openssl \
- --openssl-option rsautl:-engine \
- --openssl-option rsautl:pkcs11 \
+ bpkg rep-create \
+ --openssl pkeyutl:/path/to/openssl \
+ --openssl-option pkeyutl:-engine \
+ --openssl-option pkeyutl:pkcs11 \
...
\
+ Note that for \cb{openssl} versions prior to \cb{3.0.0} \cb{bpkg} uses
+ the \cb{rsautl} command instead of \cb{pkeyutl} for the data signing
+ and recovery operations.
+
An unqualified value that contains a colon can be specified as
qualified with an empty command, for example, \cb{--openssl
:C:\\bin\\openssl}. To see openssl commands executed by \cb{bpkg}, use
diff --git a/bpkg/options-types.hxx b/bpkg/options-types.hxx
index 8e8cbf1..741e93c 100644
--- a/bpkg/options-types.hxx
+++ b/bpkg/options-types.hxx
@@ -73,7 +73,7 @@ namespace bpkg
}
};
- extern const char* openssl_commands[3]; // Clang bug requres explicit size.
+ extern const char* openssl_commands[5]; // Clang bug requres explicit size.
}
#endif // BPKG_OPTIONS_TYPES_HXX
diff --git a/bpkg/repository-signing.cli b/bpkg/repository-signing.cli
index 1796497..a85ecc0 100644
--- a/bpkg/repository-signing.cli
+++ b/bpkg/repository-signing.cli
@@ -193,11 +193,13 @@ just \cb{--key} as at step 4 (\c{\"SIGN key\"} is the label for the slot
\c{9c} private key):
\
-bpkg rep-create \
- --openssl-option rsautl:-engine --openssl-option rsautl:pkcs11 \
- --openssl-option rsautl:-keyform --openssl-option rsautl:engine \
+bpkg rep-create \
+ --openssl-option pkeyutl:-engine --openssl-option pkeyutl:pkcs11 \
+ --openssl-option pkeyutl:-keyform --openssl-option pkeyutl:engine \
--key \"pkcs11:object=SIGN%20key\" /path/to/repository
\
+Note that for \cb{openssl} versions prior to \cb{3.0.0} \cb{bpkg} uses the
+\cb{rsautl} command instead of \cb{pkeyutl} for the data signing operation.
||
"
--
cgit v1.1

View File

@ -0,0 +1,116 @@
diff --git a/tests/cc/modules/modules.testscript b/tests/cc/modules/modules.testscript
index 681238a..054ecd9 100644
--- a/tests/cc/modules/modules.testscript
+++ b/tests/cc/modules/modules.testscript
@@ -190,16 +190,16 @@ $* test &*.d &?*.ii* <'exe{test}: cxx{driver} mxx{core}' 2>>EOE != 0
info: consider specifying module name with cxx.module_name
EOE
-: library
-:
-: Test importing a module from a library.
-:
-ln -s ../core.mxx ../core.cxx ../driver.cxx ./;
-$* test clean <<EOI
- ./: lib{foo} exe{test} # Full build.
- exe{test}: cxx{driver} lib{foo}
- lib{foo}: {mxx cxx}{core}
- EOI
+# : library
+# :
+# : Test importing a module from a library.
+# :
+# ln -s ../core.mxx ../core.cxx ../driver.cxx ./;
+# $* test clean <<EOI
+# ./: lib{foo} exe{test} # Full build.
+# exe{test}: cxx{driver} lib{foo}
+# lib{foo}: {mxx cxx}{core}
+# EOI
: module-marker
:
@@ -286,17 +286,17 @@ $* test clean <<EOI
EOI
$* test clean <'exe{test}: cxx{driver core} mxx{core base extra foo}'
- : library
- :
- ln -s ../base.mxx ../extra.mxx ../foo.mxx ../../core.mxx ../../core.cxx ./;
- cat <<EOI >=driver.cxx;
- import foo;
- int main (int argc, char*[]) {return f (g (argc));}
- EOI
- $* test clean <<EOI
- exe{test}: cxx{driver} mxx{foo} lib{foo}
- lib{foo}: mxx{core base extra} cxx{core}
- EOI
+ # : library
+ # :
+ # ln -s ../base.mxx ../extra.mxx ../foo.mxx ../../core.mxx ../../core.cxx ./;
+ # cat <<EOI >=driver.cxx;
+ # import foo;
+ # int main (int argc, char*[]) {return f (g (argc));}
+ # EOI
+ # $* test clean <<EOI
+ # exe{test}: cxx{driver} mxx{foo} lib{foo}
+ # lib{foo}: mxx{core base extra} cxx{core}
+ # EOI
}
: import
@@ -364,29 +364,29 @@ $* test clean <<EOI
bmie{foo-core}: mxx{foo-core}
EOI
-: symexport
-:
-: Test the __symexport feature.
-:
-cat <<EOI >=core.mxx;
- export module foo.core;
-
- export __symexport int f (int);
-
- __symexport int g_impl (int i) {return i - 1;}
- export __symexport inline int g (int i) {return g_impl (i);}
- EOI
-ln -s ../core.cxx core-f.cxx;
-cat <<EOI >=core-g.cxx;
- module foo.core;
- int g_impl (int i) {return i - 1;}
- EOI
-cat <<EOI >=driver.cxx;
- import foo.core;
- int main (int argc, char*[]) {return f (argc) + g (argc);}
- EOI
-$* test clean <<EOI
- ./: lib{foo} exe{test} # Full build.
- exe{test}: cxx{driver} lib{foo}
- lib{foo}: mxx{core} cxx{core-f} # @@ VC: core-g
- EOI
+# : symexport
+# :
+# : Test the __symexport feature.
+# :
+# cat <<EOI >=core.mxx;
+# export module foo.core;
+
+# export __symexport int f (int);
+
+# __symexport int g_impl (int i) {return i - 1;}
+# export __symexport inline int g (int i) {return g_impl (i);}
+# EOI
+# ln -s ../core.cxx core-f.cxx;
+# cat <<EOI >=core-g.cxx;
+# module foo.core;
+# int g_impl (int i) {return i - 1;}
+# EOI
+# cat <<EOI >=driver.cxx;
+# import foo.core;
+# int main (int argc, char*[]) {return f (argc) + g (argc);}
+# EOI
+# $* test clean <<EOI
+# ./: lib{foo} exe{test} # Full build.
+# exe{test}: cxx{driver} lib{foo}
+# lib{foo}: mxx{core} cxx{core-f} # @@ VC: core-g
+# EOI

View File

@ -1,12 +1,12 @@
%bcond_without bootstrap
%bcond_without check
%bcond_without bundle_libodb
%bcond_with bootstrap
%bcond_with network_checks
%bcond_with static
Name: build2
Version: 0.13.0
Release: 6%{?dist}
Version: 0.14.0
Release: 1%{?dist}
Summary: Cross-platform build toolchain for developing and packaging C++ code
License: MIT
@ -20,11 +20,23 @@ Source5: macros.%{name}
# The latest official release of libodb is not compatible with build2
%if %{with bundle_libodb}
%global libodb_bundle_version 2.5.0-b.19
%global libodb_bundle_version 2.5.0-b.21
Source100: https://pkg.cppget.org/1/beta/odb/libodb-%{libodb_bundle_version}.tar.gz
Source101: https://pkg.cppget.org/1/beta/odb/libodb-sqlite-%{libodb_bundle_version}.tar.gz
%endif
# Upstream https://git.build2.org/cgit/build2/commit/?id=65f77bb9a9556033a0bfb7401dd9a00120e27524
Patch0000: libbuild2-config.install.scope-no-update-for-install.patch
# Disable some C++ modules tests for PPC64LE because GCC has issues linking C++
# modules on PPC64LE:
# driver.cxx:(.text+0x88): unresolvable R_PPC64_REL24 against `_ZGIW3foo4coreEv'
# /usr/bin/ld: final link failed: bad value
Patch0100: build2-disable-test-cc-modules-ppc64le.patch
# Upstream https://git.build2.org/cgit/libbutl/commit/?id=c6ea3d784ee920f51de3088437b471c8dd6d70e2
Patch1000: libbutl-openssl-info-overloads.patch
# Upstream https://git.build2.org/cgit/bpkg/commit/?id=073f4ed111b0b10dcbd81fc112f9d66e41f40fac
Patch3000: bpkg-openssl-3-pkeyutl.patch
BuildRequires: gcc-c++
BuildRequires: libpkgconf-devel
%if %{with bootstrap}
@ -120,12 +132,14 @@ applications that use lib%{name}.
%package -n libbutl
Summary: %{name} utility library
# BSD-2 clause:
# BSD-2-Clause:
# libbutl/lz4.{c,h}
# libbutl/lz4hc.{c,h}
# libbutl/sha256c.c
# libbutl/strptime.c
# libbutl/timelocal.c
# libbutl/timelocal.h
# BSD-3 clause:
# libbutl/timelocal.{c,h}
# libbutl/xxhash.{c,h}
# BSD-3-Clause:
# libbutl/sha1.c
License: MIT and BSD
Requires: curl
@ -252,11 +266,22 @@ This package contains the %{name} RPM macros.
%else
%setup -q -c -n %{name}-toolchain-%{version} -a 1 -a 2 -a 3 -a 4 -a 100 -a 101
%endif
pushd %{name}-%{version}
%patch -p 1 -P 0000
%ifarch ppc64le
%patch -p 1 -P 0100
%endif
popd
pushd libbutl-%{version}
%patch -p 1 -P 1000
popd
pushd bpkg-%{version}
%patch -p 1 -P 3000
popd
mv libbutl-%{version} %{name}-%{version}
%build
# Define basic installation configuration. Note that this does not include:
# %%{_sysconfdir} /etc
# %%{_libexecdir} %%{_exec_prefix}/libexec
# %%{_sharedstatedir} /var/lib
# %%{_datadir} %%{_prefix}/share
@ -275,6 +300,7 @@ mv libbutl-%{version} %{name}-%{version}
config.install.sbin=%{_sbindir} \\\
config.install.include=%{_includedir} \\\
config.install.lib=%{_libdir} \\\
config.install.etc=%{_sysconfdir} \\\
config.install.man=%{_mandir} \\\
config.install.legal=%{_defaultlicensedir}/"<project>" \\\
config.install.pkgconfig=%{_libdir}/pkgconfig \\\
@ -403,7 +429,10 @@ b install:
%{name}-%{version}/ \
libbpkg-%{version}/ \
bpkg-%{version}/ \
bdep-%{version}/
bdep-%{version}/ \
%if %{with bundle_libodb}
'!config.install.scope=project'
%endif
# copy licenses from build2 package to libbuild2 subpackage
mkdir -p %{buildroot}%{_defaultlicensedir}/lib%{name}
cp %{buildroot}%{_defaultlicensedir}/%{name}/{AUTHORS,LICENSE} %{buildroot}%{_defaultlicensedir}/lib%{name}
@ -455,25 +484,25 @@ b test:
%dir %{_defaultlicensedir}/lib%{name}
%license %{_defaultlicensedir}/lib%{name}/AUTHORS
%license %{_defaultlicensedir}/lib%{name}/LICENSE
%{_libdir}/lib%{name}-0.13.so
%{_libdir}/lib%{name}-bash-0.13-0.13.so
%{_libdir}/lib%{name}-bin-0.13-0.13.so
%{_libdir}/lib%{name}-c-0.13-0.13.so
%{_libdir}/lib%{name}-cc-0.13-0.13.so
%{_libdir}/lib%{name}-cxx-0.13-0.13.so
%{_libdir}/lib%{name}-in-0.13-0.13.so
%{_libdir}/lib%{name}-version-0.13-0.13.so
%{_libdir}/lib%{name}-0.14.so
%{_libdir}/lib%{name}-bash-0.14-0.14.so
%{_libdir}/lib%{name}-bin-0.14-0.14.so
%{_libdir}/lib%{name}-c-0.14-0.14.so
%{_libdir}/lib%{name}-cc-0.14-0.14.so
%{_libdir}/lib%{name}-cxx-0.14-0.14.so
%{_libdir}/lib%{name}-in-0.14-0.14.so
%{_libdir}/lib%{name}-version-0.14-0.14.so
%files -n lib%{name}-devel
%{_includedir}/lib%{name}
%{_libdir}/lib%{name}.so
%{_libdir}/lib%{name}-bash{,-0.13}.so
%{_libdir}/lib%{name}-bin{,-0.13}.so
%{_libdir}/lib%{name}-c{,-0.13}.so
%{_libdir}/lib%{name}-cc{,-0.13}.so
%{_libdir}/lib%{name}-cxx{,-0.13}.so
%{_libdir}/lib%{name}-in{,-0.13}.so
%{_libdir}/lib%{name}-version{,-0.13}.so
%{_libdir}/lib%{name}-bash{,-0.14}.so
%{_libdir}/lib%{name}-bin{,-0.14}.so
%{_libdir}/lib%{name}-c{,-0.14}.so
%{_libdir}/lib%{name}-cc{,-0.14}.so
%{_libdir}/lib%{name}-cxx{,-0.14}.so
%{_libdir}/lib%{name}-in{,-0.14}.so
%{_libdir}/lib%{name}-version{,-0.14}.so
%{_libdir}/pkgconfig/lib%{name}{,.shared}.pc
%{_libdir}/pkgconfig/lib%{name}-bash{,.shared}.pc
%{_libdir}/pkgconfig/lib%{name}-bin{,.shared}.pc
@ -508,7 +537,7 @@ b test:
%license %{_defaultlicensedir}/libbutl/AUTHORS
%license %{_defaultlicensedir}/libbutl/COPYRIGHT
%license %{_defaultlicensedir}/libbutl/LICENSE
%{_libdir}/libbutl-0.13.so
%{_libdir}/libbutl-0.14.so
%files -n libbutl-devel
%dir %{_docdir}/libbutl
@ -529,7 +558,7 @@ b test:
%dir %{_defaultlicensedir}/libbpkg
%license %{_defaultlicensedir}/libbpkg/AUTHORS
%license %{_defaultlicensedir}/libbpkg/LICENSE
%{_libdir}/libbpkg-0.13.so
%{_libdir}/libbpkg-0.14.so
%files -n libbpkg-devel
%dir %{_docdir}/libbpkg
@ -585,6 +614,9 @@ b test:
%{_rpmmacrodir}/macros.%{name}
%changelog
* Sun Jan 23 2022 Matthew Krupcale <mkrupcale@matthewkrupcale.com> - 0.14.0-1
- Update to v0.14.0
* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

View File

@ -0,0 +1,126 @@
From 65f77bb9a9556033a0bfb7401dd9a00120e27524 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Thu, 4 Nov 2021 13:41:23 +0200
Subject: Do not apply install scope to update-for-install pre-operation
---
libbuild2/cc/link-rule.cxx | 7 +++++++
libbuild2/cc/pkgconfig.cxx | 38 ++++++++++++++++++++++++++------------
libbuild2/install/rule.cxx | 4 ++--
libbuild2/install/utility.hxx | 4 ++++
4 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index fa9a1f1..79de01c 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -2379,6 +2379,13 @@ namespace build2
// install or no install, the reason is unless and until we are updating
// for install, we have no idea where-to things will be installed.
//
+ // There is a further complication: we may have no intention of
+ // installing the library but still need to update it for install (see
+ // install_scope() for background). In which case we may still not have
+ // the installation directories. We handle this in pkconfig_save() by
+ // skipping the generation of .pc files (and letting the install rule
+ // complain if we do end up trying to install them).
+ //
if (for_install && lt.library () && !lt.utility)
{
bool la (lt.static_library ());
diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx
index 3033a2b..54fc05f 100644
--- a/libbuild2/cc/pkgconfig.cxx
+++ b/libbuild2/cc/pkgconfig.cxx
@@ -1461,18 +1461,6 @@ namespace build2
/* */ pcs::static_type)));
assert (t != nullptr);
- // This is the lib{} group if we are generating the common file and the
- // target itself otherwise.
- //
- const file& g (common ? l.group->as<file> () : l);
-
- // By default we assume things go into install.{include, lib}.
- //
- using install::resolve_dir;
-
- dir_path idir (resolve_dir (g, cast<dir_path> (g["install.include"])));
- dir_path ldir (resolve_dir (g, cast<dir_path> (g["install.lib"])));
-
const path& p (t->path ());
// If we are uninstalling, skip regenerating the file if it already
@@ -1485,6 +1473,32 @@ namespace build2
return;
}
+ // This is the lib{} group if we are generating the common file and the
+ // target itself otherwise.
+ //
+ const file& g (common ? l.group->as<file> () : l);
+
+ // By default we assume things go into install.{include, lib}.
+ //
+ // If include.lib does not resolve, then assume this is update-for-
+ // install without actual install and remove the file if it exists.
+ //
+ // @@ Shouldn't we use target's install value rather than install.lib
+ // in case it gets installed into a custom location?
+ //
+ using install::resolve_dir;
+
+ dir_path ldir (resolve_dir (g,
+ cast<dir_path> (g["install.lib"]),
+ false /* fail_unknown */));
+ if (ldir.empty ())
+ {
+ rmfile (ctx, p, 3 /* verbosity */);
+ return;
+ }
+
+ dir_path idir (resolve_dir (g, cast<dir_path> (g["install.include"])));
+
// Note that generation can take some time if we have a large number of
// prerequisite libraries.
//
diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx
index 2d81067..d4c70c0 100644
--- a/libbuild2/install/rule.cxx
+++ b/libbuild2/install/rule.cxx
@@ -105,7 +105,7 @@ namespace build2
// iterates over all its members.
//
if (!is)
- is = install_scope (t);
+ is = a.operation () != update_id ? install_scope (t) : nullptr;
const target* pt (filter (*is, a, t, i));
if (pt == nullptr)
@@ -366,7 +366,7 @@ namespace build2
// iterates over all its members.
//
if (!is)
- is = install_scope (t);
+ is = a.operation () != update_id ? install_scope (t) : nullptr;
const target* pt (filter (*is, a, t, i));
diff --git a/libbuild2/install/utility.hxx b/libbuild2/install/utility.hxx
index cc5cd53..52b9a54 100644
--- a/libbuild2/install/utility.hxx
+++ b/libbuild2/install/utility.hxx
@@ -61,6 +61,10 @@ namespace build2
// belong to projects outside of this scope. If it's NULL, install
// prerequisites from all projects. See also config.install.scope.
//
+ // Note that this should not apply to update-for-install. Failed that we
+ // may end up using incompatibly-built prerequisites (e.g., a library) in
+ // a target built for install (e.g., an executable).
+ //
LIBBUILD2_SYMEXPORT const scope*
install_scope (const target&);
--
cgit v1.1

View File

@ -0,0 +1,173 @@
From c6ea3d784ee920f51de3088437b471c8dd6d70e2 Mon Sep 17 00:00:00 2001
From: Karen Arutyunov <karen@codesynthesis.com>
Date: Thu, 18 Nov 2021 15:54:46 +0300
Subject: Add openssl::info() overloads
---
libbutl/openssl.hxx | 35 +++++++++++++++++++++++++++
libbutl/openssl.ixx | 9 +++++++
libbutl/openssl.txx | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/openssl/driver.cxx | 24 +++++++++++++++---
4 files changed, 127 insertions(+), 4 deletions(-)
diff --git a/libbutl/openssl.hxx b/libbutl/openssl.hxx
index 58e38f8..b340f5c 100644
--- a/libbutl/openssl.hxx
+++ b/libbutl/openssl.hxx
@@ -8,8 +8,10 @@
#include <libbutl/path.hxx>
#include <libbutl/process.hxx>
+#include <libbutl/optional.hxx>
#include <libbutl/fdstream.hxx>
#include <libbutl/small-vector.hxx>
+#include <libbutl/semantic-version.hxx>
#include <libbutl/export.hxx>
@@ -78,6 +80,23 @@ namespace butl
// department (that were apparently fixed in 1.0.2). To work around these
// bugs pass user-supplied options first.
//
+ struct openssl_info
+ {
+ // Note that the program name can be used by the caller to properly
+ // interpret the version.
+ //
+ // The name/version examples:
+ //
+ // OpenSSL 3.0.0
+ // OpenSSL 1.1.1l
+ // LibreSSL 2.8.3
+ //
+ // The `l` component above ends up in semantic_version::build.
+ //
+ std::string name;
+ semantic_version version;
+ };
+
class LIBBUTL_SYMEXPORT openssl: public process
{
public:
@@ -111,6 +130,22 @@ namespace butl
const std::string& command,
A&&... options);
+ // Run `openssl version` command and try to parse and return the
+ // information it prints to stdout. Return nullopt if the process hasn't
+ // terminated successfully or stdout parsing has failed. Throw
+ // process_error and io_error in case of errors.
+ //
+ template <typename E>
+ static optional<openssl_info>
+ info (E&& err, const process_env&);
+
+ template <typename C,
+ typename E>
+ static optional<openssl_info>
+ info (const C&,
+ E&& err,
+ const process_env&);
+
private:
template <typename T>
struct is_other
diff --git a/libbutl/openssl.ixx b/libbutl/openssl.ixx
index 1435dcb..db2fbcd 100644
--- a/libbutl/openssl.ixx
+++ b/libbutl/openssl.ixx
@@ -26,4 +26,13 @@ namespace butl
std::forward<A> (options)...)
{
}
+
+ template <typename E>
+ inline optional<openssl_info> openssl::
+ info (E&& err, const process_env& env)
+ {
+ return info ([] (const char* [], std::size_t) {},
+ std::forward<E> (err),
+ env);
+ }
}
diff --git a/libbutl/openssl.txx b/libbutl/openssl.txx
index f198c22..01e854c 100644
--- a/libbutl/openssl.txx
+++ b/libbutl/openssl.txx
@@ -1,6 +1,7 @@
// file : libbutl/openssl.txx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
+#include <cstddef> // size_t
#include <utility> // forward()
namespace butl
@@ -49,4 +50,66 @@ namespace butl
// Note: leaving this scope closes any open ends of the pipes in io_data.
}
+
+ template <typename C,
+ typename E>
+ optional<openssl_info> openssl::
+ info (const C& cmdc, E&& err, const process_env& env)
+ {
+ using namespace std;
+
+ // Run the `openssl version` command.
+ //
+ openssl os (cmdc,
+ nullfd, fdstream_mode::text, forward<E> (err),
+ env,
+ "version");
+
+ // Read the command's stdout and wait for its completion. Bail out if the
+ // command didn't terminate successfully or stdout contains no data.
+ //
+ string s;
+ if (!getline (os.in, s))
+ return nullopt;
+
+ os.in.close ();
+
+ if (!os.wait ())
+ return nullopt;
+
+ // Parse the version string.
+ //
+ // Note that there is some variety in the version representations:
+ //
+ // OpenSSL 3.0.0 7 sep 2021 (Library: OpenSSL 3.0.0 7 sep 2021)
+ // OpenSSL 1.1.1l FIPS 24 Aug 2021
+ // LibreSSL 2.8.3
+ //
+ // We will only consider the first two space separated components as the
+ // program name and version. We will also assume that there are no leading
+ // spaces and the version is delimited from the program name with a single
+ // space character.
+ //
+ size_t e (s.find (' '));
+
+ // Bail out if there is no version present in the string or the program
+ // name is empty.
+ //
+ if (e == string::npos || e == 0)
+ return nullopt;
+
+ string nm (s, 0, e);
+
+ size_t b (e + 1); // The beginning of the version.
+ e = s.find (' ', b); // The end of the version.
+
+ optional<semantic_version> ver (
+ parse_semantic_version (string (s, b, e != string::npos ? e - b : e),
+ "" /* build_separators */));
+
+ if (!ver)
+ return nullopt;
+
+ return openssl_info {move (nm), move (*ver)};
+ }
}
cgit v1.1

View File

@ -11,7 +11,6 @@
config.cxx.coptions="%{build_cxxflags}" \\\
config.cc.loptions="%{build_ldflags}"
# Define basic installation configuration. Note that this does not include:
# %%{_sysconfdir} /etc
# %%{_libexecdir} %%{_exec_prefix}/libexec
# %%{_sharedstatedir} /var/lib
# %%{_datadir} %%{_prefix}/share
@ -30,6 +29,7 @@
config.install.sbin=%{_sbindir} \\\
config.install.include=%{_includedir} \\\
config.install.lib=%{_libdir} \\\
config.install.etc=%{_sysconfdir} \\\
config.install.man=%{_mandir} \\\
config.install.legal=%{_defaultlicensedir}/"<project>" \\\
config.install.pkgconfig=%{_libdir}/pkgconfig \\\

14
sources
View File

@ -1,7 +1,7 @@
SHA512 (build2-0.13.0.tar.gz) = c5adc72ec49dbfb3a3bfc2db35f1d4196f92572a18101ecb3261551b29e49c736e38dd5d4980d5b97bf49cd0391dd38295b23bcd50fae5b595cc063cd8376c62
SHA512 (libbutl-0.13.0.tar.gz) = 72d273baa8c107d5664d2e645f4fa58f644dd321e2be95d6133dfc358ca843001cafba85e05597f6e6bc4de1d4476439f46c2a99b3eb5370d88f0506683b05a1
SHA512 (libbpkg-0.13.0.tar.gz) = ac947f95b45fa6633e246e2aea679b8a8639d18d3e69b14e6931eb6dcbdb8fec60faf9051ba3307d3f0f8077edca78d15d3a754a1a3bbeb8b03046b215d21979
SHA512 (bpkg-0.13.0.tar.gz) = d8f4c61d8ef5a817be8f9681575850fdf2f19e9e91c1eca9e6dc21b4d99813a6db73045306e066c2d1f2aece9cb89e8d3adbb2ead6b7e8c2c52af7c5ec721a8e
SHA512 (bdep-0.13.0.tar.gz) = 8c2de9c84f27a80ad37879112ac6a0825327009435b81b5bdd6bd7a858e49cbd8c57c11673b0215c7161f265e9da8eb2edcf870717331b52676f82af4e5edabc
SHA512 (libodb-2.5.0-b.19.tar.gz) = 0a3e70afd2c2ba573676e1a2630986215b4c8e57a004f7d2f2227f301b6c58f739397a0efc8877902baf88b93aff83c9b67c9f5b5e87cc570d64bb76b7b8f66b
SHA512 (libodb-sqlite-2.5.0-b.19.tar.gz) = be6dbc731d9f45dfc7e9246f404edad78d59c9d38cff6599aed56d60d4f0e8391336e2da3608f66d74559f0a8d34243eb38e7e6a1221188959321810193ae901
SHA512 (bdep-0.14.0.tar.gz) = 0b2aaa76b82e431dc3a51327d8e4e53a0f6e804afdd9e90849e2b143ca30a3d12c84c64c80d57fd704eb85b2886d690b9434c3b599fead9ccf52a98ecb88b370
SHA512 (bpkg-0.14.0.tar.gz) = c7d25c4d1ead1d05a2ed2544a221df275e0ae6b44e337e59ec37a97c7110ed8242ac9f6fc816215047ce7f50768b433919fc3761efc4113d971bb1ad3b438978
SHA512 (build2-0.14.0.tar.gz) = 71afcba0e42f1e62766beb06ad3d62eabe417d648d98a901303613094e3e8d8165d3a2cffb11b166cd1a42aa2f322f3ff35b2f37e03e4af59b8778df7aa5ed11
SHA512 (libbpkg-0.14.0.tar.gz) = aceddba40c91910dbf7838f723d2f9acb2a5290ccfc4a02dfc0f0a950b0bd94f8c91ca358bc894a8fa544a8876bf07de293236256c2c4ea9a989b4abca88cfb7
SHA512 (libbutl-0.14.0.tar.gz) = 8226f7e5895a949aa38496d1ddebe270014c2fd0fcdf6667cb64c2ce28f4c2fab6ffd0be20d37102e284545e8320af02433c71e54a0db578cc92c64ec235e3cc
SHA512 (libodb-2.5.0-b.21.tar.gz) = 68fa486b3a6f1254fb57e480bdf8e1d008fe38f29c47d5a4648ff44dc964dd7f3ee9d07510d742db15120f272aa6152bf08ca9d7689e4b34b0f5e5910ea71c0e
SHA512 (libodb-sqlite-2.5.0-b.21.tar.gz) = a84ea3847c64e5beffcb1f3958583bc02d371a4eb354ad32d0083b01e27362905bdcf09913c9b4cd6fc977eeaba95fd46cf953332e4fd0d673ca2f7521c71a1f