[arch-commits] Commit in deepin-daemon/trunk (3 files)

Felix Yan fyan at archlinux.org
Thu Nov 26 04:20:10 UTC 2015


    Date: Thursday, November 26, 2015 @ 05:20:10
  Author: fyan
Revision: 147811

upgpkg: deepin-daemon 2.93.1-3

Added:
  deepin-daemon/trunk/get-distro-info.patch
  deepin-daemon/trunk/ishuman-via-login-defs.patch
Modified:
  deepin-daemon/trunk/PKGBUILD

------------------------------+
 PKGBUILD                     |   13 ++--
 get-distro-info.patch        |  119 ++++++++++++++++++++++++++++++++++++
 ishuman-via-login-defs.patch |  132 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 260 insertions(+), 4 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2015-11-26 03:18:15 UTC (rev 147810)
+++ PKGBUILD	2015-11-26 04:20:10 UTC (rev 147811)
@@ -9,7 +9,7 @@
 _golibrev=238151791673412dedf333363b3a37343c461acb
 _deepinapiver=2.92.1
 _dbusfactoryver=2.92.1
-pkgrel=2
+pkgrel=3
 pkgdesc='Daemon handling the DDE session settings'
 arch=('i686' 'x86_64')
 url="https://github.com/linuxdeepin/dde-daemon"
@@ -17,7 +17,7 @@
 depends=('deepin-desktop-schemas' 'gvfs' 'libcanberra-pulse' 'metacity' 'poppler-glib'
          'rfkill' 'acpid' 'bluez' 'deepin-notifications' 'iso-codes' 'lsb-release'
          'mobile-broadband-provider-info' 'polkit-gnome' 'udisks2' 'upower' 'gcc-go'
-         'libxkbfile') # 'xcur2png')
+         'libxkbfile' 'accountsservice')
 makedepends=('deepin-dbus-generator' 'sqlite' 'git' 'mercurial')
 optdepends=('networkmanager: Network Management daemon'
             'deepin-grub2-themes: deepin theme for grub menu')
@@ -30,13 +30,15 @@
         "git+https://github.com/linuxdeepin/go-lib.git#commit=$_golibrev"
         "git+https://github.com/linuxdeepin/dbus-factory.git#tag=$_dbusfactoryver"
         "git+https://github.com/linuxdeepin/dde-api.git#tag=$_deepinapiver"
-        'fix-i686-compile.patch' 'deepin-daemon.sysusers')
+        'fix-i686-compile.patch' 'deepin-daemon.sysusers' 'ishuman-via-login-defs.patch' 'get-distro-info.patch')
 sha256sums=('SKIP'
             'SKIP'
             'SKIP'
             'SKIP'
             '1dccf88c5ce480560a4a2d73134e69f05135703fe34ccd5d9e2e5d7fe852efc5'
-            '4482f2c82c3652040021dd43515f131184a0417e341dc37db487117012245e25')
+            '4482f2c82c3652040021dd43515f131184a0417e341dc37db487117012245e25'
+            '182fd299b9f222ce8f94da9137fb671f95fbd32bd28becfaf8c97b9fdd488c65'
+            '4b3f743b8cffc591ab5582aa4ba6a56f464cd7c279a3594e637fffac0a14df63')
 
 prepare() {
   export GOPATH="$srcdir/build"
@@ -56,6 +58,9 @@
   if [[ $CARCH == "i686" ]]; then
     patch -p1 -i ../fix-i686-compile.patch
   fi
+
+  patch -p1 -i ../ishuman-via-login-defs.patch
+  patch -p1 -i ../get-distro-info.patch
 }
 
 build() {

Added: get-distro-info.patch
===================================================================
--- get-distro-info.patch	                        (rev 0)
+++ get-distro-info.patch	2015-11-26 04:20:10 UTC (rev 147811)
@@ -0,0 +1,119 @@
+commit a39042ae318f404ac44196cc028e234e6b01d489
+Author: Felix Yan <felixonmars at archlinux.org>
+Date:   Wed Nov 25 12:55:31 2015 +0800
+
+    Add methods to get distribution info
+    
+    Change-Id: I915fa4a5f429430e5c183ade58bd727c7d5a2478
+
+diff --git a/systeminfo/distro.go b/systeminfo/distro.go
+new file mode 100644
+index 0000000..cfd5bc5
+--- /dev/null
++++ b/systeminfo/distro.go
+@@ -0,0 +1,51 @@
++package systeminfo
++
++import (
++	"fmt"
++)
++
++const (
++	distroFileLSB    = "/etc/lsb-release"
++
++	distroIdKeyLSB   = "DISTRIB_ID"
++	distroDescKeyLSB = "DISTRIB_DESCRIPTION"
++	distroVerKeyLSB  = "DISTRIB_RELEASE"
++	distroKeyDelim   = "="
++)
++
++func getDistro() (string, string, string, error) {
++	distroId, distroDesc, distroVer, err := getDistroFromLSB(distroFileLSB)
++	if err == nil {
++		return distroId, distroDesc, distroVer, nil
++	}
++
++	return "", "", "", err
++}
++
++func getDistroFromLSB(file string) (string, string, string, error) {
++	ret, err := parseInfoFile(file, distroKeyDelim)
++	if err != nil {
++		return "", "", "", err
++	}
++
++	distroId, ok := ret[distroIdKeyLSB]
++	if !ok {
++		return "", "", "", fmt.Errorf("Cannot find the key '%s'", distroIdKeyLSB)
++	}
++
++	distroDesc, ok := ret[distroDescKeyLSB]
++	if !ok {
++		return "", "", "", fmt.Errorf("Cannot find the key '%s'", distroDescKeyLSB)
++	}
++
++	if distroDesc[0] == '"' && distroDesc[len(distroDesc) - 1] == '"' {
++		distroDesc = distroDesc[1:len(distroDesc) - 1]
++	}
++
++	distroVer, ok := ret[distroVerKeyLSB]
++	if !ok {
++		return "", "", "", fmt.Errorf("Cannot find the key '%s'", distroVerKeyLSB)
++	}
++
++	return distroId, distroDesc, distroVer, nil
++}
+diff --git a/systeminfo/info.go b/systeminfo/info.go
+index c905cab..808ffb7 100644
+--- a/systeminfo/info.go
++++ b/systeminfo/info.go
+@@ -7,8 +7,14 @@ import (
+ )
+ 
+ type SystemInfo struct {
+-	// Current version, ex: "2015 Desktop"
++	// Current deepin version, ex: "2015 Desktop"
+ 	Version string
++	// Distribution ID
++	DistroID string
++	// Distribution Description
++	DistroDesc string
++	// Distribution Version
++	DistroVer string
+ 	// CPU information
+ 	Processor string
+ 	// Disk capacity
+@@ -82,6 +88,11 @@ func NewSystemInfo() *SystemInfo {
+ 		logger.Warning("Get version failed:", err)
+ 	}
+ 
++	info.DistroID, info.DistroDesc, info.DistroVer, err = getDistro()
++	if err != nil {
++		logger.Warning("Get distribution failed:", err)
++	}
++
+ 	info.MemoryCap, err = getMemoryFromFile("/proc/meminfo")
+ 	if err != nil {
+ 		logger.Warning("Get memory capacity failed:", err)
+diff --git a/systeminfo/info_test.go b/systeminfo/info_test.go
+index 11bffb7..56700b0 100644
+--- a/systeminfo/info_test.go
++++ b/systeminfo/info_test.go
+@@ -42,3 +42,17 @@ func TestVersion(t *testing.T) {
+ 		So(err, ShouldBeNil)
+ 	})
+ }
++
++func TestDistro(t *testing.T) {
++	Convey("Test os distro", t, func() {
++		lang := os.Getenv("LANGUAGE")
++		os.Setenv("LANGUAGE", "en_US")
++		defer os.Setenv("LANGUAGE", lang)
++
++		distroId, distroDesc, distroVer, err := getDistroFromLSB("testdata/lsb-release")
++		So(distroId, ShouldEqual, "Deepin")
++		So(distroDesc, ShouldEqual, "Deepin 2014.3")
++		So(distroVer, ShouldEqual, "2014.3")
++		So(err, ShouldBeNil)
++	})
++}

Added: ishuman-via-login-defs.patch
===================================================================
--- ishuman-via-login-defs.patch	                        (rev 0)
+++ ishuman-via-login-defs.patch	2015-11-26 04:20:10 UTC (rev 147811)
@@ -0,0 +1,132 @@
+commit 50844ff5338feeaa1e59af72eb3d0a624f3e4791
+Author: Felix Yan <felixonmars at archlinux.org>
+Date:   Wed Nov 25 00:27:27 2015 +0800
+
+    Add support to check login.defs for isHuman
+    
+    Change-Id: Ic18e289d02b208a4c28f64a7362a082f5280556e
+
+diff --git a/accounts/users/list.go b/accounts/users/list.go
+index 4b6d563..e5038e4 100644
+--- a/accounts/users/list.go
++++ b/accounts/users/list.go
+@@ -25,16 +25,19 @@ import (
+ 	"fmt"
+ 	"io/ioutil"
+ 	"strings"
++	"strconv"
+ )
+ 
+ const (
+-	userFilePasswd = "/etc/passwd"
+-	userFileShadow = "/etc/shadow"
+-	userFileGroup  = "/etc/group"
+-
+-	itemLenPasswd = 7
+-	itemLenShadow = 9
+-	itemLenGroup  = 4
++	userFilePasswd    = "/etc/passwd"
++	userFileShadow    = "/etc/shadow"
++	userFileGroup     = "/etc/group"
++	userFileLoginDefs = "/etc/login.defs"
++
++	itemLenPasswd    = 7
++	itemLenShadow    = 9
++	itemLenGroup     = 4
++	itemLenLoginDefs = 2
+ )
+ 
+ var (
+@@ -137,7 +140,7 @@ func (infos UserInfos) GetUserNames() []string {
+ func (infos UserInfos) filterUserInfos() UserInfos {
+ 	var tmp UserInfos
+ 	for _, info := range infos {
+-		if !info.isHumanUser(userFileShadow) {
++		if !info.isHumanUser(userFileShadow, userFileLoginDefs) {
+ 			continue
+ 		}
+ 
+@@ -147,7 +150,7 @@ func (infos UserInfos) filterUserInfos() UserInfos {
+ 	return tmp
+ }
+ 
+-func (info UserInfo) isHumanUser(config string) bool {
++func (info UserInfo) isHumanUser(configShadow string, configLoginDefs string) bool {
+ 	if info.Name == "root" {
+ 		return false
+ 	}
+@@ -156,7 +159,11 @@ func (info UserInfo) isHumanUser(config string) bool {
+ 		return false
+ 	}
+ 
+-	if !info.isHumanViaShadow(config) {
++	if !info.isHumanViaShadow(configShadow) {
++		return false
++	}
++
++	if !info.isHumanViaLoginDefs(configLoginDefs) {
+ 		return false
+ 	}
+ 
+@@ -214,3 +221,60 @@ func (info UserInfo) isHumanViaShadow(config string) bool {
+ 
+ 	return false
+ }
++
++func (info UserInfo) isHumanViaLoginDefs(config string) bool {
++	var uidMin, uidMax string
++	content, err := ioutil.ReadFile(config)
++	if err != nil {
++		return false
++	}
++
++	lines := strings.Split(string(content), "\n")
++	for _, line := range lines {
++		if len(line) == 0 {
++			continue
++		}
++
++		if line[0] == '#' {
++			continue
++		}
++
++		items := strings.Fields(line)
++		if len(items) != itemLenLoginDefs {
++			continue
++		}
++
++		if items[0] == "UID_MIN" {
++			uidMin = items[1]
++		}
++
++		if items[0] == "UID_MAX" {
++			uidMax = items[1]
++		}
++	}
++
++	if len(uidMax) == 0 || len(uidMin) == 0 {
++		return false
++	}
++
++	uidMinInt, err := strconv.Atoi(uidMin)
++	if err != nil {
++		return false
++	}
++
++	uidMaxInt, err := strconv.Atoi(uidMax)
++	if err != nil {
++		return false
++	}
++
++	uidInt, err := strconv.Atoi(info.Uid)
++	if err != nil {
++		return false
++	}
++
++	if uidInt > uidMaxInt || uidInt < uidMinInt {
++		return false
++	}
++
++	return true
++}
+\ No newline at end of file



More information about the arch-commits mailing list