Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Oct 2018 10:49:53 +0100
From:      Luca Pizzamiglio <pizzamig@freebsd.org>
To:        Jan Beich <jbeich@freebsd.org>
Cc:        Mathieu Arnold <mat@freebsd.org>, svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org
Subject:   Re: svn commit: r482294 - head/devel/sccache
Message-ID:  <CAB88xy9gS38ANUXws=%2BmWuZAsoVOxyXTaVbH8ibYFJUPfO6j1g@mail.gmail.com>
In-Reply-To: <woq7-s4iw-wny@FreeBSD.org>
References:  <201810171315.w9HDFrgI039873@repo.freebsd.org> <20181024083541.4q726xezswwqe2xo@atuin.in.mat.cc> <CAB88xy_2rP%2Bn5wtrxYiJqhxSng3MdaYaeB%2BnYTmx=45C=_GJOA@mail.gmail.com> <woq7-s4iw-wny@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for this elegant solution.
I've tried to patch the openssl-0.9.24 crate to support openssl 1.1.1, but
I didn't spent to much time to make
I'll test and adopt you solution.

On Wed, Oct 24, 2018 at 6:17 PM Jan Beich <jbeich@freebsd.org> wrote:

> Luca Pizzamiglio <pizzamig@freebsd.org> writes:
>
> > Rust dependencies (crates) are statically linked in the final executable,
> > so if a dependency crate fails to build, the whole application failed to
> > build. Crates are not shared library, they are shared API statically
> linked
> > to the final executable.
>
> Crates aren't immutable, see below.
>
> diff --git devel/sccache/Makefile devel/sccache/Makefile
> index 7a2f12352ecb..17d610fdd656 100644
> --- devel/sccache/Makefile
> +++ devel/sccache/Makefile
> @@ -2,7 +2,7 @@
>
>  PORTNAME=      sccache
>  DISTVERSION=   2.8.0.alpha0
> -PORTREVISION=  1
> +PORTREVISION=  2
>  CATEGORIES=    devel
>
>  MAINTAINER=    pizzamig@FreeBSD.org
> @@ -39,7 +39,6 @@ CARGO_CRATES= adler32-1.0.3 \
>                 base64-0.9.2 \
>                 bincode-0.8.0 \
>                 bincode-1.0.1 \
> -               bitflags-0.9.1 \
>                 bitflags-1.0.4 \
>                 buf_redux-0.6.3 \
>                 bufstream-0.1.3 \
> @@ -145,7 +144,6 @@ CARGO_CRATES=       adler32-1.0.3 \
>                 num_cpus-1.8.0 \
>                 number_prefix-0.2.8 \
>                 openssl-0.10.11 \
> -               openssl-0.9.24 \
>                 openssl-sys-0.9.35 \
>                 owning_ref-0.3.3 \
>                 parking_lot-0.6.4 \
> @@ -282,16 +280,11 @@ CARGO_CRATES=     adler32-1.0.3 \
>                 xattr-0.2.2 \
>                 zip-0.4.2
>
> -.include <bsd.port.pre.mk>
> -
> -.if ${OPSYS} == FreeBSD && ${OSVERSION} > 1200084
> -IGNORE=        openssl 1.1.1 is incompatible with the reqwest 0.8.8
> dependencies
> -.endif
> -
>  do-install-DOCS-on:
>         @${MKDIR} ${STAGEDIR}${DOCSDIR}
>         ${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
>
>  post-install:
>         ${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/sccache
> -.include <bsd.port.post.mk>
> +
> +.include <bsd.port.mk>
> diff --git devel/sccache/distinfo devel/sccache/distinfo
> index 3168794b1eb1..9f1b09ac1b4f 100644
> --- devel/sccache/distinfo
> +++ devel/sccache/distinfo
> @@ -29,8 +29,6 @@ SHA256 (rust/crates/bincode-0.8.0.tar.gz) =
> e103c8b299b28a9c6990458b7013dc4a8356
>  SIZE (rust/crates/bincode-0.8.0.tar.gz) = 71632
>  SHA256 (rust/crates/bincode-1.0.1.tar.gz) =
> 9f2fb9e29e72fd6bc12071533d5dc7664cb01480c59406f656d7ac25c7bd8ff7
>  SIZE (rust/crates/bincode-1.0.1.tar.gz) = 14071
> -SHA256 (rust/crates/bitflags-0.9.1.tar.gz) =
> 4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5
> -SIZE (rust/crates/bitflags-0.9.1.tar.gz) = 12406
>  SHA256 (rust/crates/bitflags-1.0.4.tar.gz) =
> 228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12
>  SIZE (rust/crates/bitflags-1.0.4.tar.gz) = 15282
>  SHA256 (rust/crates/buf_redux-0.6.3.tar.gz) =
> b9279646319ff816b05fb5897883ece50d7d854d12b59992683d4f8a71b0f949
> @@ -241,8 +239,6 @@ SHA256 (rust/crates/number_prefix-0.2.8.tar.gz) =
> dbf9993e59c894e3c08aa1c2712914
>  SIZE (rust/crates/number_prefix-0.2.8.tar.gz) = 5493
>  SHA256 (rust/crates/openssl-0.10.11.tar.gz) =
> 6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc
>  SIZE (rust/crates/openssl-0.10.11.tar.gz) = 164328
> -SHA256 (rust/crates/openssl-0.9.24.tar.gz) =
> a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985
> -SIZE (rust/crates/openssl-0.9.24.tar.gz) = 149235
>  SHA256 (rust/crates/openssl-sys-0.9.35.tar.gz) =
> 912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129
>  SIZE (rust/crates/openssl-sys-0.9.35.tar.gz) = 44854
>  SHA256 (rust/crates/owning_ref-0.3.3.tar.gz) =
> cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37
> diff --git devel/sccache/files/patch-openssl-0.10
> devel/sccache/files/patch-openssl-0.10
> new file mode 100644
> index 000000000000..dc4d413348ef
> --- /dev/null
> +++ devel/sccache/files/patch-openssl-0.10
> @@ -0,0 +1,204 @@
> +https://github.com/sfackler/rust-native-tls/commit/f1a7ea94752c
> +
> +--- Cargo.lock 2018-09-10 20:16:55 UTC
> ++++ Cargo.lock
> +@@ -122,11 +122,6 @@ dependencies = [
> +
> + [[package]]
> + name = "bitflags"
> +-version = "0.9.1"
> +-source = "registry+https://github.com/rust-lang/crates.io-index"
> +-
> +-[[package]]
> +-name = "bitflags"
> + version = "1.0.4"
> + source = "registry+https://github.com/rust-lang/crates.io-index"
> +
> +@@ -943,7 +938,7 @@ source = "registry+
> https://github.com/rust-lang/crates
> + dependencies = [
> +  "lazy_static 0.2.11 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
> +- "openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index
> )",
> ++ "openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index
> )",
> +  "schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index
> )",
> +  "security-framework 0.1.16 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +  "security-framework-sys 0.1.16 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +@@ -1021,18 +1016,6 @@ dependencies = [
> +
> + [[package]]
> + name = "openssl"
> +-version = "0.9.24"
> +-source = "registry+https://github.com/rust-lang/crates.io-index"
> +-dependencies = [
> +- "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index
> )",
> +- "foreign-types 0.3.2 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +- "lazy_static 1.1.0 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +- "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
> +- "openssl-sys 0.9.35 (registry+
> https://github.com/rust-lang/crates.io-index)",
> +-]
> +-
> +-[[package]]
> +-name = "openssl"
> + version = "0.10.11"
> + source = "registry+https://github.com/rust-lang/crates.io-index"
> + dependencies = [
> +@@ -2318,7 +2301,6 @@ dependencies = [
> + "checksum base64 0.9.2 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "85415d2594767338a74a30c1d370b2f3262ec1b4ed2d7bba5b3faf4de40467d9"
> + "checksum bincode 0.8.0 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
> + "checksum bincode 1.0.1 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "9f2fb9e29e72fd6bc12071533d5dc7664cb01480c59406f656d7ac25c7bd8ff7"
> +-"checksum bitflags 0.9.1 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
> + "checksum bitflags 1.0.4 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
> + "checksum buf_redux 0.6.3 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "b9279646319ff816b05fb5897883ece50d7d854d12b59992683d4f8a71b0f949"
> + "checksum bufstream 0.1.3 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32"
> +@@ -2424,7 +2406,6 @@ dependencies = [
> + "checksum num_cpus 1.8.0 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
> + "checksum number_prefix 0.2.8 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
> + "checksum openssl 0.10.11 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc"
> +-"checksum openssl 0.9.24 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985"
> + "checksum openssl-sys 0.9.35 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129"
> + "checksum owning_ref 0.3.3 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
> + "checksum parking_lot 0.6.4 (registry+
> https://github.com/rust-lang/crates.io-index)" =
> "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
> +--- cargo-crates/native-tls-0.1.5/Cargo.toml.orig      2018-01-11
> 17:27:31 UTC
> ++++ cargo-crates/native-tls-0.1.5/Cargo.toml
> +@@ -34,6 +34,6 @@ version = "0.1.15"
> + [target."cfg(any(target_os = \"macos\", target_os =
> \"ios\"))".dependencies.tempdir]
> + version = "0.3"
> + [target."cfg(not(any(target_os = \"windows\", target_os = \"macos\",
> target_os = \"ios\")))".dependencies.openssl]
> +-version = "0.9.23"
> ++version = "0.10.1"
> + [target."cfg(target_os = \"windows\")".dependencies.schannel]
> + version = "0.1.7"
> +--- cargo-crates/native-tls-0.1.5/src/imp/openssl.rs.orig      2018-01-11
> 17:27:24 UTC
> ++++ cargo-crates/native-tls-0.1.5/src/imp/openssl.rs
> +@@ -6,25 +6,25 @@ use std::error;
> + use self::openssl::pkcs12;
> + use self::openssl::error::ErrorStack;
> + use self::openssl::ssl::{self, SslMethod, SslConnectorBuilder,
> SslConnector, SslAcceptorBuilder,
> +-                         SslAcceptor, MidHandshakeSslStream,
> SslContextBuilder};
> ++                         SslAcceptor, MidHandshakeSslStream,
> SslContextBuilder, SslOptions};
> + use self::openssl::x509::X509;
> +
> + use Protocol;
> +
> + fn supported_protocols(protocols: &[Protocol], ctx: &mut
> SslContextBuilder) {
> +     // This constant is only defined on OpenSSL 1.0.2 and above, so
> manually do it.
> +-    let ssl_op_no_ssl_mask = ssl::SSL_OP_NO_SSLV2 | ssl::SSL_OP_NO_SSLV3
> | ssl::SSL_OP_NO_TLSV1 |
> +-        ssl::SSL_OP_NO_TLSV1_1 |
> +-        ssl::SSL_OP_NO_TLSV1_2;
> ++    let ssl_op_no_ssl_mask = SslOptions::NO_SSLV2 | SslOptions::NO_SSLV3
> | SslOptions::NO_TLSV1 |
> ++        SslOptions::NO_TLSV1_1 |
> ++        SslOptions::NO_TLSV1_2;
> +
> +     ctx.clear_options(ssl_op_no_ssl_mask);
> +     let mut options = ssl_op_no_ssl_mask;
> +     for protocol in protocols {
> +         let op = match *protocol {
> +-            Protocol::Sslv3 => ssl::SSL_OP_NO_SSLV3,
> +-            Protocol::Tlsv10 => ssl::SSL_OP_NO_TLSV1,
> +-            Protocol::Tlsv11 => ssl::SSL_OP_NO_TLSV1_1,
> +-            Protocol::Tlsv12 => ssl::SSL_OP_NO_TLSV1_2,
> ++            Protocol::Sslv3 => SslOptions::NO_SSLV3,
> ++            Protocol::Tlsv10 => SslOptions::NO_TLSV1,
> ++            Protocol::Tlsv11 => SslOptions::NO_TLSV1_1,
> ++            Protocol::Tlsv12 => SslOptions::NO_TLSV1_2,
> +             Protocol::__NonExhaustive => unreachable!(),
> +         };
> +         options &= !op;
> +@@ -64,7 +64,7 @@ impl From<ssl::Error> for Error {
> +
> + impl From<ErrorStack> for Error {
> +     fn from(err: ErrorStack) -> Error {
> +-        ssl::Error::Ssl(err).into()
> ++        err.into()
> +     }
> + }
> +
> +@@ -132,11 +132,9 @@ pub enum HandshakeError<S> {
> + impl<S> From<ssl::HandshakeError<S>> for HandshakeError<S> {
> +     fn from(e: ssl::HandshakeError<S>) -> HandshakeError<S> {
> +         match e {
> +-            ssl::HandshakeError::SetupFailure(e) => {
> +-                HandshakeError::Failure(Error(ssl::Error::Ssl(e)))
> +-            }
> ++            ssl::HandshakeError::SetupFailure(e) =>
> HandshakeError::Failure(e.into()),
> +             ssl::HandshakeError::Failure(e) =>
> HandshakeError::Failure(Error(e.into_error())),
> +-            ssl::HandshakeError::Interrupted(s) => {
> ++            ssl::HandshakeError::WouldBlock(s) => {
> +                 HandshakeError::Interrupted(MidHandshakeTlsStream(s))
> +             }
> +         }
> +@@ -157,8 +155,10 @@ impl TlsConnectorBuilder {
> +         try!(self.0.set_certificate(&pkcs12.0.cert));
> +         try!(self.0.set_private_key(&pkcs12.0.pkey));
> +         try!(self.0.check_private_key());
> +-        for cert in pkcs12.0.chain {
> +-            try!(self.0.add_extra_chain_cert(cert));
> ++        if let Some(chain) = pkcs12.0.chain {
> ++            for cert in chain {
> ++                try!(self.0.add_extra_chain_cert(cert));
> ++            }
> +         }
> +         Ok(())
> +     }
> +@@ -183,7 +183,7 @@ pub struct TlsConnector(SslConnector);
> +
> + impl TlsConnector {
> +     pub fn builder() -> Result<TlsConnectorBuilder, Error> {
> +-        let builder = try!(SslConnectorBuilder::new(SslMethod::tls()));
> ++        let builder = try!(SslConnector::builder(SslMethod::tls()));
> +         Ok(TlsConnectorBuilder(builder))
> +     }
> +
> +@@ -199,7 +199,12 @@ impl TlsConnector {
> +     where
> +         S: io::Read + io::Write,
> +     {
> +-        let s =
> try!(self.0.danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication(stream));
> ++        let c = try!(self.0.configure());
> ++        let s = try!(
> ++            c.use_server_name_indication(false)
> ++                .verify_hostname(false)
> ++                .connect("", stream)
> ++        );
> +         Ok(TlsStream(s))
> +     }
> + }
> +@@ -248,12 +253,14 @@ pub struct TlsAcceptor(SslAcceptor);
> +
> + impl TlsAcceptor {
> +     pub fn builder(pkcs12: Pkcs12) -> Result<TlsAcceptorBuilder, Error> {
> +-        let builder = try!(SslAcceptorBuilder::mozilla_intermediate(
> +-            SslMethod::tls(),
> +-            &pkcs12.0.pkey,
> +-            &pkcs12.0.cert,
> +-            &pkcs12.0.chain,
> +-        ));
> ++        let mut builder =
> try!(SslAcceptor::mozilla_intermediate(SslMethod::tls()));
> ++        try!(builder.set_private_key(&pkcs12.0.pkey));
> ++        try!(builder.set_certificate(&pkcs12.0.cert));
> ++        if let Some(chain) = pkcs12.0.chain {
> ++            for cert in chain {
> ++                try!(builder.add_extra_chain_cert(cert));
> ++            }
> ++        }
> +         Ok(TlsAcceptorBuilder(builder))
> +     }
> +
> +@@ -307,12 +314,11 @@ impl<S: io::Read + io::Write> TlsStream<S> {
> +
> +     pub fn shutdown(&mut self) -> io::Result<()> {
> +         match self.0.shutdown() {
> +-            Ok(_) |
> +-            Err(ssl::Error::ZeroReturn) => Ok(()),
> +-            Err(ssl::Error::Stream(e)) |
> +-            Err(ssl::Error::WantRead(e)) |
> +-            Err(ssl::Error::WantWrite(e)) => Err(e),
> +-            Err(e) => return Err(io::Error::new(io::ErrorKind::Other,
> e)),
> ++            Ok(_) => Ok(()),
> ++            Err(ref e) if e.code() == ssl::ErrorCode::ZERO_RETURN =>
> Ok(()),
> ++            Err(e) => Err(e.into_io_error().unwrap_or_else(
> ++                |e| io::Error::new(io::ErrorKind::Other, e),
> ++            )),
> +         }
> +     }
> +
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB88xy9gS38ANUXws=%2BmWuZAsoVOxyXTaVbH8ibYFJUPfO6j1g>