git: ca67a20f93e1 - main - audio/ncspot: enable desktop notifications
Jan Beich
jbeich at FreeBSD.org
Sun Sep 12 11:59:01 UTC 2021
The branch main has been updated by jbeich:
URL: https://cgit.FreeBSD.org/ports/commit/?id=ca67a20f93e10ece67d1c4d8af9746fadf0b5e93
commit ca67a20f93e10ece67d1c4d8af9746fadf0b5e93
Author: Jan Beich <jbeich at FreeBSD.org>
AuthorDate: 2021-08-23 06:49:54 +0000
Commit: Jan Beich <jbeich at FreeBSD.org>
CommitDate: 2021-09-12 11:56:28 +0000
audio/ncspot: enable desktop notifications
PR: 258000
Inspired by: upstream default
Approved by: maintainer timeout (3 weeks)
---
audio/ncspot/Makefile | 10 +-
audio/ncspot/distinfo | 4 +-
audio/ncspot/files/patch-zbus | 226 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 234 insertions(+), 6 deletions(-)
diff --git a/audio/ncspot/Makefile b/audio/ncspot/Makefile
index 0cee65c80c8d..0bacb7b9443a 100644
--- a/audio/ncspot/Makefile
+++ b/audio/ncspot/Makefile
@@ -1,7 +1,7 @@
PORTNAME= ncspot
DISTVERSIONPREFIX= v
DISTVERSION= 0.6.0
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= audio
MAINTAINER= rodrigo at FreeBSD.org
@@ -213,7 +213,7 @@ CARGO_CRATES= addr2line-0.14.1 \
ncurses-5.101.0 \
net2-0.2.37 \
nix-0.9.0 \
- nix-0.17.0 \
+ nix-0.20.0 \
nom-5.1.2 \
notify-rust-4.3.0 \
num-0.3.1 \
@@ -467,8 +467,8 @@ CARGO_FEATURES= --no-default-features cursive/pancurses-backend
PLIST_FILES= bin/ncspot
PORTDOCS= README.md
-OPTIONS_DEFINE= CLIPBOARD DOCS MPRIS PORTAUDIO PULSEAUDIO
-OPTIONS_DEFAULT= CLIPBOARD MPRIS PORTAUDIO
+OPTIONS_DEFINE= CLIPBOARD DOCS MPRIS NOTIFY PORTAUDIO PULSEAUDIO
+OPTIONS_DEFAULT= CLIPBOARD MPRIS NOTIFY PORTAUDIO
CLIPBOARD_DESC= Support for accessing X11 clipboard
MPRIS_DESC= D-Bus MPRIS support
@@ -480,6 +480,8 @@ CLIPBOARD_VARS= CARGO_FEATURES+=share_clipboard
MPRIS_VARS= CARGO_FEATURES+=mpris
+NOTIFY_VARS= CARGO_FEATURES+=notify
+
PORTAUDIO_LIB_DEPENDS= libportaudio.so:audio/portaudio
PORTAUDIO_VARS= CARGO_FEATURES+=portaudio_backend
diff --git a/audio/ncspot/distinfo b/audio/ncspot/distinfo
index 23e338fe5094..e5fde8c3bc29 100644
--- a/audio/ncspot/distinfo
+++ b/audio/ncspot/distinfo
@@ -393,8 +393,8 @@ SHA256 (rust/crates/net2-0.2.37.tar.gz) = 391630d12b68002ae1e25e8f97430647496655
SIZE (rust/crates/net2-0.2.37.tar.gz) = 21311
SHA256 (rust/crates/nix-0.9.0.tar.gz) = a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32
SIZE (rust/crates/nix-0.9.0.tar.gz) = 103078
-SHA256 (rust/crates/nix-0.17.0.tar.gz) = 50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363
-SIZE (rust/crates/nix-0.17.0.tar.gz) = 195654
+SHA256 (rust/crates/nix-0.20.0.tar.gz) = fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a
+SIZE (rust/crates/nix-0.20.0.tar.gz) = 216983
SHA256 (rust/crates/nom-5.1.2.tar.gz) = ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af
SIZE (rust/crates/nom-5.1.2.tar.gz) = 136174
SHA256 (rust/crates/notify-rust-4.3.0.tar.gz) = 00c16afe17474a42a59062f3409a63160c63d41985b25e9e613400685b839cb6
diff --git a/audio/ncspot/files/patch-zbus b/audio/ncspot/files/patch-zbus
new file mode 100644
index 000000000000..b80b1f6418b4
--- /dev/null
+++ b/audio/ncspot/files/patch-zbus
@@ -0,0 +1,226 @@
+https://gitlab.freedesktop.org/dbus/zbus/-/commit/01d8f0ec41d3
+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<()> {
More information about the dev-commits-ports-all
mailing list