Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Aug 2021 23:32:32 GMT
From:      Jan Beich <jbeich@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org
Subject:   git: f34b48106e69 - 2021Q3 - shells/starship: enable desktop notifications
Message-ID:  <202108232332.17NNWW2I008122@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch 2021Q3 has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f34b48106e69a6e8d7d261b635d4de09f7af7f73

commit f34b48106e69a6e8d7d261b635d4de09f7af7f73
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2021-08-23 13:51:22 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2021-08-23 23:32:06 +0000

    shells/starship: enable desktop notifications
    
    PR:             258008
    Inspired by:    Arch Linux
    Approved by:    yuri (maintainer)
    
    (cherry picked from commit ef5a84db43ef87175ee40b7d4de913ad65ec7c49)
---
 shells/starship/Makefile         |   6 +-
 shells/starship/distinfo         |   6 --
 shells/starship/files/patch-zbus | 227 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 229 insertions(+), 10 deletions(-)

diff --git a/shells/starship/Makefile b/shells/starship/Makefile
index ff8133f27330..fcad145fa0e8 100644
--- a/shells/starship/Makefile
+++ b/shells/starship/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	starship
 DISTVERSION=	0.54.0
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	shells
 MASTER_SITES=	CRATESIO
 DISTFILES=	${CARGO_DIST_SUBDIR}/${DISTNAME}${CARGO_CRATE_EXT}
@@ -44,7 +44,6 @@ CARGO_CRATES=	\
 		bytes-1.0.1 \
 		cache-padded-1.1.1 \
 		cc-1.0.67 \
-		cfg-if-0.1.10 \
 		cfg-if-1.0.0 \
 		chrono-0.4.19 \
 		clap-2.33.3 \
@@ -116,7 +115,6 @@ CARGO_CRATES=	\
 		memoffset-0.6.3 \
 		native-tls-0.2.7 \
 		nb-connect-1.2.0 \
-		nix-0.17.0 \
 		nix-0.19.1 \
 		nix-0.20.0 \
 		nom-6.1.2 \
@@ -224,7 +222,6 @@ CARGO_CRATES=	\
 		vec_map-0.8.2 \
 		version_check-0.9.3 \
 		versions-3.0.1 \
-		void-1.0.2 \
 		waker-fn-1.1.0 \
 		wasi-0.9.0+wasi-snapshot-preview1 \
 		wasi-0.10.0+wasi-snapshot-preview1 \
@@ -243,6 +240,7 @@ CARGO_CRATES=	\
 		zbus_macros-1.9.1 \
 		zvariant-2.6.0 \
 		zvariant_derive-2.6.0
+CARGO_FEATURES=	notify-rust
 PLIST_FILES=	bin/${PORTNAME}
 
 OPTIONS_DEFINE=		FONTS
diff --git a/shells/starship/distinfo b/shells/starship/distinfo
index ddac7b8c03ef..36e5fb1e78aa 100644
--- a/shells/starship/distinfo
+++ b/shells/starship/distinfo
@@ -51,8 +51,6 @@ SHA256 (rust/crates/cache-padded-1.1.1.crate) = 631ae5198c9be5e753e5cc215e1bd73c
 SIZE (rust/crates/cache-padded-1.1.1.crate) = 8798
 SHA256 (rust/crates/cc-1.0.67.crate) = e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd
 SIZE (rust/crates/cc-1.0.67.crate) = 53486
-SHA256 (rust/crates/cfg-if-0.1.10.crate) = 4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822
-SIZE (rust/crates/cfg-if-0.1.10.crate) = 7933
 SHA256 (rust/crates/cfg-if-1.0.0.crate) = baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd
 SIZE (rust/crates/cfg-if-1.0.0.crate) = 7934
 SHA256 (rust/crates/chrono-0.4.19.crate) = 670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73
@@ -195,8 +193,6 @@ SHA256 (rust/crates/native-tls-0.2.7.crate) = b8d96b2e1c8da3957d58100b09f102c6d9
 SIZE (rust/crates/native-tls-0.2.7.crate) = 24958
 SHA256 (rust/crates/nb-connect-1.2.0.crate) = b1bb540dc6ef51cfe1916ec038ce7a620daf3a111e2502d745197cd53d6bca15
 SIZE (rust/crates/nb-connect-1.2.0.crate) = 8126
-SHA256 (rust/crates/nix-0.17.0.crate) = 50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363
-SIZE (rust/crates/nix-0.17.0.crate) = 195654
 SHA256 (rust/crates/nix-0.19.1.crate) = b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2
 SIZE (rust/crates/nix-0.19.1.crate) = 213462
 SHA256 (rust/crates/nix-0.20.0.crate) = fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a
@@ -411,8 +407,6 @@ SHA256 (rust/crates/version_check-0.9.3.crate) = 5fecdca9a5291cc2b8dcf7dc02453fe
 SIZE (rust/crates/version_check-0.9.3.crate) = 12547
 SHA256 (rust/crates/versions-3.0.1.crate) = 8c60afe0e50fe60619e900fe00367d0208fe05b6fe6221c55bde57fc40afb161
 SIZE (rust/crates/versions-3.0.1.crate) = 14301
-SHA256 (rust/crates/void-1.0.2.crate) = 6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d
-SIZE (rust/crates/void-1.0.2.crate) = 2356
 SHA256 (rust/crates/waker-fn-1.1.0.crate) = 9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca
 SIZE (rust/crates/waker-fn-1.1.0.crate) = 7114
 SHA256 (rust/crates/wasi-0.9.0+wasi-snapshot-preview1.crate) = cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519
diff --git a/shells/starship/files/patch-zbus b/shells/starship/files/patch-zbus
new file mode 100644
index 000000000000..4239e754510c
--- /dev/null
+++ b/shells/starship/files/patch-zbus
@@ -0,0 +1,227 @@
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/01d8f0ec41d3
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/eabad70af2b3
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/807909a6c7bf
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/e3e2f7ddfd6e
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/35d1b8778754
+
+--- cargo-crates/zbus-1.9.1/Cargo.toml.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/Cargo.toml
+@@ -48,7 +48,7 @@ version = "0.3.8"
+ version = "1.0.2"
+ 
+ [dependencies.nix]
+-version = "^0.17"
++version = "0.20.0"
+ 
+ [dependencies.once_cell]
+ version = "1.4.0"
+--- cargo-crates/zbus-1.9.1/src/address.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/address.rs
+@@ -55,8 +55,9 @@ impl Address {
+         match env::var("DBUS_SESSION_BUS_ADDRESS") {
+             Ok(val) => Self::from_str(&val),
+             _ => {
+-                let uid = Uid::current();
+-                let path = format!("unix:path=/run/user/{}/bus", uid);
++                let runtime_dir = env::var("XDG_RUNTIME_DIR")
++                    .unwrap_or_else(|_| format!("/run/user/{}", Uid::current()));
++                let path = format!("unix:path={}/bus", runtime_dir);
+ 
+                 Self::from_str(&path)
+             }
+--- cargo-crates/zbus-1.9.1/src/azync/connection.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/azync/connection.rs
+@@ -177,13 +177,29 @@ where
+     /// Upon successful return, the connection is fully established and negotiated: D-Bus messages
+     /// can be sent and received.
+     pub async fn new_server(stream: S, guid: &Guid) -> Result<Self> {
+-        use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
++        #[cfg(any(target_os = "android", target_os = "linux"))]
++        let client_uid = {
++            use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
+ 
+-        // FIXME: Could and should this be async?
+-        let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
+-            .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
++            let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
++                .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
+ 
+-        let auth = Authenticated::server(Async::new(stream)?, guid.clone(), creds.uid()).await?;
++            creds.uid()
++        };
++        #[cfg(any(
++            target_os = "macos",
++            target_os = "ios",
++            target_os = "freebsd",
++            target_os = "dragonfly",
++            target_os = "openbsd",
++            target_os = "netbsd"
++        ))]
++        let client_uid = nix::unistd::getpeereid(stream.as_raw_fd())
++            .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?
++            .0
++            .into();
++
++        let auth = Authenticated::server(Async::new(stream)?, guid.clone(), client_uid).await?;
+ 
+         Ok(Self::new_authenticated(auth))
+     }
+--- cargo-crates/zbus-1.9.1/src/connection.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/connection.rs
+@@ -160,12 +160,29 @@ impl Connection {
+     /// Upon successful return, the connection is fully established and negotiated: D-Bus messages
+     /// can be sent and received.
+     pub fn new_unix_server(stream: UnixStream, guid: &Guid) -> Result<Self> {
+-        use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
++        #[cfg(any(target_os = "android", target_os = "linux"))]
++        let client_uid = {
++            use nix::sys::socket::{getsockopt, sockopt::PeerCredentials};
+ 
+-        let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
+-            .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
++            let creds = getsockopt(stream.as_raw_fd(), PeerCredentials)
++                .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?;
+ 
+-        let handshake = ServerHandshake::new(stream, guid.clone(), creds.uid());
++            creds.uid()
++        };
++        #[cfg(any(
++            target_os = "macos",
++            target_os = "ios",
++            target_os = "freebsd",
++            target_os = "dragonfly",
++            target_os = "openbsd",
++            target_os = "netbsd"
++        ))]
++        let client_uid = nix::unistd::getpeereid(stream.as_raw_fd())
++            .map_err(|e| Error::Handshake(format!("Failed to get peer credentials: {}", e)))?
++            .0
++            .into();
++
++        let handshake = ServerHandshake::new(stream, guid.clone(), client_uid);
+         handshake
+             .blocking_finish()
+             .map(Connection::new_authenticated_unix)
+--- cargo-crates/zbus-1.9.1/src/handshake.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/handshake.rs
+@@ -124,7 +124,7 @@ impl<S: Socket> ClientHandshake<S> {
+ 
+     fn flush_buffer(&mut self) -> Result<()> {
+         while !self.buffer.is_empty() {
+-            let written = self.socket.sendmsg(&self.buffer, &[])?;
++            let written = self.socket.sendmsg(&self.buffer, &[], false)?;
+             self.buffer.drain(..written);
+         }
+         Ok(())
+@@ -182,6 +182,15 @@ impl<S: Socket> Handshake<S> for ClientHandshake<S> {
+                     self.step = ClientHandshakeStep::SendingOauth;
+                 }
+                 ClientHandshakeStep::SendingOauth => {
++                    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
++                    {
++                        let zero = self.buffer.drain(..1).next().unwrap();
++                        if self.socket.sendmsg(&[zero], &[], true)? != 1 {
++                            return Err(Error::Handshake(
++                                "Could not send zero byte with credentials".to_string(),
++                            ));
++                        }
++                    }
+                     self.flush_buffer()?;
+                     self.step = ClientHandshakeStep::WaitOauth;
+                 }
+@@ -385,7 +394,7 @@ impl<S: Socket> ServerHandshake<S> {
+ 
+     fn flush_buffer(&mut self) -> Result<()> {
+         while !self.buffer.is_empty() {
+-            let written = self.socket.sendmsg(&self.buffer, &[])?;
++            let written = self.socket.sendmsg(&self.buffer, &[], false)?;
+             self.buffer.drain(..written);
+         }
+         Ok(())
+--- cargo-crates/zbus-1.9.1/src/raw/connection.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/raw/connection.rs
+@@ -47,7 +47,7 @@ impl<S: Socket> Connection<S> {
+             // VecDeque should never return an empty front buffer if the VecDeque
+             // itself is not empty
+             debug_assert!(!front.is_empty());
+-            let written = self.socket.sendmsg(front, &[])?;
++            let written = self.socket.sendmsg(front, &[], false)?;
+             self.raw_out_buffer.drain(..written);
+         }
+ 
+@@ -55,14 +55,14 @@ impl<S: Socket> Connection<S> {
+         while let Some(msg) = self.msg_out_buffer.front() {
+             let mut data = msg.as_bytes();
+             let fds = msg.fds();
+-            let written = self.socket.sendmsg(data, &fds)?;
++            let written = self.socket.sendmsg(data, &fds, false)?;
+             // at least some part of the message has been sent, see if we can/need to send more
+             // now the message must be removed from msg_out_buffer and any leftover bytes
+             // must be stored into raw_out_buffer
+             let msg = self.msg_out_buffer.pop_front().unwrap();
+             data = &msg.as_bytes()[written..];
+             while !data.is_empty() {
+-                match self.socket.sendmsg(data, &[]) {
++                match self.socket.sendmsg(data, &[], false) {
+                     Ok(n) => data = &data[n..],
+                     Err(e) => {
+                         // an error occured, we cannot send more, store the remaining into
+--- cargo-crates/zbus-1.9.1/src/raw/socket.rs.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/zbus-1.9.1/src/raw/socket.rs
+@@ -47,7 +47,7 @@ pub trait Socket {
+     ///
+     /// If the underlying transport does not support transmitting file descriptors, this
+     /// will return `Err(ErrorKind::InvalidInput)`.
+-    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize>;
++    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize>;
+ 
+     /// Close the socket.
+     ///
+@@ -74,6 +74,10 @@ impl Socket for UnixStream {
+             Ok(msg) => {
+                 let mut fds = vec![];
+                 for cmsg in msg.cmsgs() {
++                    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
++                    if let ControlMessageOwned::ScmCreds(_) = cmsg {
++                        continue;
++                    }
+                     if let ControlMessageOwned::ScmRights(fd) = cmsg {
+                         fds.extend(fd.iter().map(|&f| unsafe { OwnedFd::from_raw_fd(f) }));
+                     } else {
+@@ -90,12 +94,23 @@ impl Socket for UnixStream {
+         }
+     }
+ 
+-    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize> {
+-        let cmsg = if !fds.is_empty() {
++    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize> {
++        let mut cmsg = if !fds.is_empty() {
+             vec![ControlMessage::ScmRights(fds)]
+         } else {
+             vec![]
+         };
++        #[cfg(any(target_os = "android", target_os = "linux"))]
++        let unix_creds;
++        if creds {
++            #[cfg(any(target_os = "android", target_os = "linux"))]
++            {
++                unix_creds = Some(nix::sys::socket::UnixCredentials::new());
++                cmsg.push(ControlMessage::ScmCredentials(unix_creds.as_ref().unwrap()));
++            }
++            #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
++            cmsg.push(ControlMessage::ScmCreds);
++        }
+         let iov = [IoVec::from_slice(buffer)];
+         match sendmsg(self.as_raw_fd(), &iov, &cmsg, MsgFlags::empty(), None) {
+             // can it really happen?
+@@ -124,8 +139,8 @@ where
+         self.get_mut().recvmsg(buffer)
+     }
+ 
+-    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd]) -> io::Result<usize> {
+-        self.get_mut().sendmsg(buffer, fds)
++    fn sendmsg(&mut self, buffer: &[u8], fds: &[RawFd], creds: bool) -> io::Result<usize> {
++        self.get_mut().sendmsg(buffer, fds, creds)
+     }
+ 
+     fn close(&self) -> io::Result<()> {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108232332.17NNWW2I008122>