[arch-commits] Commit in deepin-go-lib/trunk (PKGBUILD dbus-fix.patch)
Felix Yan
felixonmars at archlinux.org
Sat Dec 29 17:11:11 UTC 2018
Date: Saturday, December 29, 2018 @ 17:11:09
Author: felixonmars
Revision: 418870
upgpkg: deepin-go-lib 1.7.0-1
Modified:
deepin-go-lib/trunk/PKGBUILD
deepin-go-lib/trunk/dbus-fix.patch
----------------+
PKGBUILD | 8 +--
dbus-fix.patch | 141 ++++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 122 insertions(+), 27 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2018-12-29 17:09:55 UTC (rev 418869)
+++ PKGBUILD 2018-12-29 17:11:09 UTC (rev 418870)
@@ -1,8 +1,8 @@
# Maintainer: Felix Yan <felixonmars at archlinux.org>
pkgname=deepin-go-lib
-pkgver=1.6.0
-pkgrel=2
+pkgver=1.7.0
+pkgrel=1
pkgdesc='A library containing many useful go routines for things such as glib, gettext, archive, graphic,etc.'
arch=('any')
url="https://github.com/linuxdeepin/go-lib"
@@ -10,8 +10,8 @@
depends=('libpulse' 'gdk-pixbuf2' 'mobile-broadband-provider-info' 'libx11')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/go-lib/archive/$pkgver.tar.gz"
dbus-fix.patch)
-sha512sums=('c350792d5a445d0f235f0402e36952c7ff9e5a88bf39b41fa2ae6a31f9cbd67e73c6426f4bc76bc14d465fc84750ee2f65f4450ecbe725a0d5ce7169a7c2182c'
- '80a540358c2d9c51b647d7afa1b9c2a075677b596861fdb894f97298ba580b242f8cfcaa3d0ac7b8a4fdd18d39fb9eee8c62ef20d0efb5f928a88117b6fa8a9c')
+sha512sums=('edfc5f50e3126a2ef563027c2b000d60c25f5eee540fa49fb69c36a100bbc4bb3b46e1aa2b161fa93e8fee5223c95d4a7e241697cbb43044c61a60b3ce7ab1a7'
+ '7cd2f41d0b26fce32a775043c4da2328e899f6bb8f34557e3c6f8f1d9a14ef9a218def555dabadb3e57ae501795c84c86e19172c39053b704c281277507bf181')
prepare() {
cd go-lib-$pkgver
Modified: dbus-fix.patch
===================================================================
--- dbus-fix.patch 2018-12-29 17:09:55 UTC (rev 418869)
+++ dbus-fix.patch 2018-12-29 17:11:09 UTC (rev 418870)
@@ -1,23 +1,36 @@
+From e9e0a68a7eb72da7dfa181375e6ec891be89d662 Mon Sep 17 00:00:00 2001
+From: electricface <songwentai at deepin.com>
+Date: Sat, 29 Dec 2018 09:42:54 +0800
+Subject: [PATCH] fix(dbus): failed to find session bus address in systemd 240+
+
+Change-Id: I401cf471ad396003b950fc9fc038bbee0b60bc6c
+---
+
diff --git a/dbus/conn.go b/dbus/conn.go
-index 20f65b1..01da4e3 100644
+index 20f65b1..41bb6e5 100644
--- a/dbus/conn.go
+++ b/dbus/conn.go
-@@ -26,6 +26,7 @@ import (
- "reflect"
- "strings"
- "sync"
-+ dbus1 "pkg.deepin.io/lib/dbus1"
- )
+@@ -110,14 +110,25 @@
+ return
+ }
- const defaultSystemBusAddress = "unix:path=/var/run/dbus/system_bus_socket"
-@@ -112,12 +113,12 @@ func SessionBus() (conn *Conn, err error) {
-
++func getSessionBusAddress() (string, error) {
++ if address := os.Getenv("DBUS_SESSION_BUS_ADDRESS"); address != "" && address != "autolaunch:" {
++ return address, nil
++
++ } else if address := tryDiscoverDbusSessionBusAddress(); address != "" {
++ os.Setenv("DBUS_SESSION_BUS_ADDRESS", address)
++ return address, nil
++ }
++ return getSessionBusPlatformAddress()
++}
++
// SessionBusPrivate returns a new private connection to the session bus.
func SessionBusPrivate() (*Conn, error) {
- address := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
- if address != "" && address != "autolaunch:" {
- return Dial(address)
-+ address, err := dbus1.GetSessionBusAddress()
++ address, err := getSessionBusAddress()
+ if err != nil {
+ return nil, err
}
@@ -27,18 +40,100 @@
}
// SystemBus returns a shared connection to the system bus, connecting to it if
-diff --git a/dbus1/conn.go b/dbus1/conn.go
-index 2737621..ac89088 100644
---- a/dbus1/conn.go
-+++ b/dbus1/conn.go
-@@ -77,6 +77,10 @@ func SessionBus() (conn *Conn, err error) {
- return
- }
+diff --git a/dbus/conn_other.go b/dbus/conn_other.go
+index 293d8cb..d8d1adf 100644
+--- a/dbus/conn_other.go
++++ b/dbus/conn_other.go
+@@ -24,23 +24,87 @@
+ import (
+ "bytes"
+ "errors"
++ "fmt"
++ "io/ioutil"
++ "os"
+ "os/exec"
++ "os/user"
++ "path"
++ "strings"
+ )
-+func GetSessionBusAddress() (string, error) {
-+ return getSessionBusAddress()
+-func sessionBusPlatform() (*Conn, error) {
+- cmd := exec.Command("/usr/bin/dbus-launch")
++func getSessionBusPlatformAddress() (string, error) {
++ cmd := exec.Command("dbus-launch")
+ b, err := cmd.CombinedOutput()
+
+ if err != nil {
+- return nil, err
++ return "", err
+ }
+
+ i := bytes.IndexByte(b, '=')
+ j := bytes.IndexByte(b, '\n')
+
+ if i == -1 || j == -1 {
+- return nil, errors.New("dbus: couldn't determine address of session bus")
++ return "", errors.New("dbus: couldn't determine address of session bus")
+ }
+
+- return Dial(string(b[i+1 : j]))
++ env, addr := string(b[0:i]), string(b[i+1:j])
++ os.Setenv(env, addr)
++
++ return addr, nil
+}
+
- func getSessionBusAddress() (string, error) {
- if address := os.Getenv("DBUS_SESSION_BUS_ADDRESS"); address != "" && address != "autolaunch:" {
- return address, nil
++// tryDiscoverDbusSessionBusAddress tries to discover an existing dbus session
++// and return the value of its DBUS_SESSION_BUS_ADDRESS.
++// It tries different techniques employed by different operating systems,
++// returning the first valid address it finds, or an empty string.
++//
++// * /run/user/<uid>/bus if this exists, it *is* the bus socket. present on
++// Ubuntu 18.04
++// * /run/user/<uid>/dbus-session: if this exists, it can be parsed for the bus
++// address. present on Ubuntu 16.04
++//
++// See https://dbus.freedesktop.org/doc/dbus-launch.1.html
++func tryDiscoverDbusSessionBusAddress() string {
++ if runtimeDirectory, err := getRuntimeDirectory(); err == nil {
++
++ if runUserBusFile := path.Join(runtimeDirectory, "bus"); fileExists(runUserBusFile) {
++ // if /run/user/<uid>/bus exists, that file itself
++ // *is* the unix socket, so return its path
++ return fmt.Sprintf("unix:path=%s", runUserBusFile)
++ }
++ if runUserSessionDbusFile := path.Join(runtimeDirectory, "dbus-session"); fileExists(runUserSessionDbusFile) {
++ // if /run/user/<uid>/dbus-session exists, it's a
++ // text file // containing the address of the socket, e.g.:
++ // DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E1c73yNqrG
++
++ if f, err := ioutil.ReadFile(runUserSessionDbusFile); err == nil {
++ fileContent := string(f)
++
++ prefix := "DBUS_SESSION_BUS_ADDRESS="
++
++ if strings.HasPrefix(fileContent, prefix) {
++ address := strings.TrimRight(strings.TrimPrefix(fileContent, prefix), "\n\r")
++ return address
++ }
++ }
++ }
++ }
++ return ""
++}
++
++func getRuntimeDirectory() (string, error) {
++ if currentUser, err := user.Current(); err != nil {
++ return "", err
++ } else {
++ return fmt.Sprintf("/run/user/%s", currentUser.Uid), nil
++ }
++}
++
++func fileExists(filename string) bool {
++ if _, err := os.Stat(filename); !os.IsNotExist(err) {
++ return true
++ } else {
++ return false
++ }
+ }
More information about the arch-commits
mailing list