Hello community, here is the log from the commit of package xsettingsd for openSUSE:Factory checked in at 2015-06-23 11:59:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xsettingsd (Old) and /work/SRC/openSUSE:Factory/.xsettingsd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xsettingsd" Changes: -------- --- /work/SRC/openSUSE:Factory/xsettingsd/xsettingsd.changes 2014-12-03 22:48:17.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.xsettingsd.new/xsettingsd.changes 2015-06-23 11:59:07.000000000 +0200 @@ -1,0 +2,7 @@ +Sat Jun 20 12:02:43 UTC 2015 - sor.ale...@meowr.ru + +- Update to 0.0~git20150615: + * Make tests work with source-only libgtest. + * Fall back to checking XDG locations for config files. + +------------------------------------------------------------------- Old: ---- xsettingsd-0.0~git20141123.tar.gz New: ---- xsettingsd-0.0~git20150615.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xsettingsd.spec ++++++ --- /var/tmp/diff_new_pack.26Qio1/_old 2015-06-23 11:59:07.000000000 +0200 +++ /var/tmp/diff_new_pack.26Qio1/_new 2015-06-23 11:59:07.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package xsettingsd # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: xsettingsd -Version: 0.0~git20141123 +Version: 0.0~git20150615 Release: 0 Summary: Provides settings to X11 applications License: BSD-3-Clause @@ -40,6 +40,10 @@ %prep %setup -q +%if 0%{?suse_version} < 1210 +# -Wno-narrowing makes build to fail. +sed -i 's/ -Wno-narrowing//' SConstruct +%endif %build CFLAGS='%{optflags}' CXXFLAGS='%{optflags}' scons %{?_smp_mflags} @@ -55,7 +59,7 @@ %doc COPYING README %{_bindir}/%{name} %{_bindir}/dump_xsettings -%{_mandir}/man1/%{name}.1.* -%{_mandir}/man1/dump_xsettings.1.* +%{_mandir}/man?/%{name}.?%{?ext_man} +%{_mandir}/man?/dump_xsettings.?%{?ext_man} %changelog ++++++ xsettingsd-0.0~git20141123.tar.gz -> xsettingsd-0.0~git20150615.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/README new/xsettingsd-0.0~git20150615/README --- old/xsettingsd-0.0~git20141123/README 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/README 2015-06-15 03:02:00.000000000 +0200 @@ -6,7 +6,7 @@ GTK+ applications and want to configure things such as themes, font antialiasing/hinting, and UI sound effects. -Documentation is available at http://code.google.com/p/xsettingsd/ +Documentation is available at https://github.com/derat/xsettingsd/wiki. --- Daniel Erat <dan-xsettin...@erat.org> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/SConstruct new/xsettingsd-0.0~git20150615/SConstruct --- old/xsettingsd-0.0~git20141123/SConstruct 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/SConstruct 2015-06-15 03:02:00.000000000 +0200 @@ -41,12 +41,12 @@ 'RunTests': run_tests_builder, }) -env.Append(CPPFLAGS = os.environ.get('CPPFLAGS', ''), - CFLAGS = os.environ.get('CFLAGS', ''), - CXXFLAGS = os.environ.get('CXXFLAGS', ''), - LDFLAGS = os.environ.get('LDFLAGS', '')) +env.Append(CPPFLAGS=os.environ.get('CPPFLAGS', ''), + CFLAGS=os.environ.get('CFLAGS', ''), + CXXFLAGS=os.environ.get('CXXFLAGS', ''), + LDFLAGS=os.environ.get('LDFLAGS', '')) -env.Append(CCFLAGS = '-Wall -Werror') +env.Append(CCFLAGS='-Wall -Werror -Wno-narrowing') srcs = Split('''\ @@ -67,8 +67,14 @@ Default([xsettingsd, dump_xsettings]) +gtest_env = env.Clone() +gtest_env.Append(CCFLAGS='-I/usr/src/gtest') +gtest_env.VariantDir('.', '/usr/src/gtest/src', duplicate=0) +libgtest = gtest_env.Library('gtest', 'gtest-all.cc') + test_env = env.Clone() -test_env.Append(CCFLAGS=' -D__TESTING', LINKFLAGS=' -lgtest') +test_env.Append(CCFLAGS='-D__TESTING') +test_env['LIBS'] += [libgtest, 'pthread'] tests = [] for file in Glob('*_test.cc', strings=True): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/common.cc new/xsettingsd-0.0~git20150615/common.cc --- old/xsettingsd-0.0~git20141123/common.cc 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/common.cc 2015-06-15 03:02:00.000000000 +0200 @@ -5,18 +5,44 @@ #include <cstdarg> #include <cstdio> +#include <cstdlib> using std::string; +using std::vector; namespace xsettingsd { -std::string StringPrintf(const char* format, ...) { +string StringPrintf(const char* format, ...) { char buffer[1024]; va_list argp; va_start(argp, format); vsnprintf(buffer, sizeof(buffer), format, argp); va_end(argp); - return std::string(buffer); + return string(buffer); +} + +vector<string> SplitString(const string& str, const string& delim) { + if (str.empty()) + return vector<string>(); + if (delim.empty()) + return vector<string>(1, str); + + vector<string> parts; + size_t start = 0; + while (start <= str.size()) { + if (start == str.size()) { + parts.push_back(string()); + break; + } + size_t next = str.find(delim, start); + if (next == string::npos) { + parts.push_back(str.substr(start, str.size() - start)); + break; + } + parts.push_back(str.substr(start, next - start)); + start = next + delim.size(); + } + return parts; } bool IsLittleEndian() { @@ -33,6 +59,40 @@ //return ((n + m - 1) & (~(m - 1))); } +vector<string> GetDefaultConfigFilePaths() { + vector<string> paths; + + // Try ~/.xsettingsd first. + const char* home_dir = getenv("HOME"); + if (home_dir) + paths.push_back(StringPrintf("%s/.xsettingsd", home_dir)); + + // Next look under $XDG_CONFIG_HOME, or in $HOME/.config if $XDG_CONFIG_HOME + // is unset. + vector<string> xdg_dirs; + const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); + if (xdg_config_home && xdg_config_home[0] != '\0') + xdg_dirs.push_back(xdg_config_home); + else if (home_dir) + xdg_dirs.push_back(StringPrintf("%s/.config", home_dir)); + + // Finally split the colon-delimited $XDG_CONFIG_DIRS variable. + const char* xdg_config_dirs = getenv("XDG_CONFIG_DIRS"); + if (xdg_config_dirs) { + vector<string> split_dirs = SplitString(xdg_config_dirs, ":"); + xdg_dirs.insert(xdg_dirs.end(), split_dirs.begin(), split_dirs.end()); + } else { + xdg_dirs.push_back("/etc"); + } + + for (size_t i = 0; i < xdg_dirs.size(); ++i) { + paths.push_back(StringPrintf("%s/xsettingsd/xsettingsd.conf", + xdg_dirs[i].c_str())); + } + + return paths; +} + const char* kProgName = "xsettingsd"; } // namespace xsettingsd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/common.h new/xsettingsd-0.0~git20150615/common.h --- old/xsettingsd-0.0~git20141123/common.h 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/common.h 2015-06-15 03:02:00.000000000 +0200 @@ -5,6 +5,7 @@ #define __XSETTINGSD_COMMON_H__ #include <string> +#include <vector> namespace xsettingsd { @@ -14,10 +15,21 @@ std::string StringPrintf(const char* format, ...); +// Splits |str| along |delim|. Repeated occurrences of |delim| in |str| will +// result in empty strings in the output. An empty |delim| will result in |str| +// being returned unsplit. An empty |str| will result in an empty vector. +std::vector<std::string> SplitString(const std::string& str, + const std::string& delim); + bool IsLittleEndian(); int GetPadding(int length, int increment); +// Returns $HOME/.xsettingsd followed by all of the config file locations +// specified by the XDG Base Directory Specification +// (http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html). +std::vector<std::string> GetDefaultConfigFilePaths(); + extern const char* kProgName; } // namespace xsettingsd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/common_test.cc new/xsettingsd-0.0~git20150615/common_test.cc --- old/xsettingsd-0.0~git20141123/common_test.cc 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/common_test.cc 2015-06-15 03:02:00.000000000 +0200 @@ -1,11 +1,45 @@ // Copyright 2009 Daniel Erat <d...@erat.org> // All rights reserved. +#include <cstdlib> +#include <string> +#include <vector> + #include <gtest/gtest.h> #include "common.h" +using std::string; +using std::vector; + namespace xsettingsd { +namespace { + +// Returns |parts| joined by '|'. +string Join(const vector<string>& parts) { + string out; + for (size_t i = 0; i < parts.size(); ++i) + out += (i > 0 ? "|" : "") + parts[i]; + return out; +} + +} // namespace + +TEST(CommonTest, SplitString) { + EXPECT_EQ("a|b|c", Join(SplitString("a,b,c", ","))); + EXPECT_EQ("a|b|", Join(SplitString("a,b,", ","))); + EXPECT_EQ("|a|b", Join(SplitString(",a,b", ","))); + EXPECT_EQ("|a|b|", Join(SplitString(",a,b,", ","))); + EXPECT_EQ("a||b", Join(SplitString("a,,b", ","))); + EXPECT_EQ("|", Join(SplitString(",", ","))); + EXPECT_EQ("foo", Join(SplitString("foo", ","))); + EXPECT_EQ("foo|bar", Join(SplitString("fooabcbar", "abc"))); + EXPECT_EQ("|foo", Join(SplitString("abcfoo", "abc"))); + EXPECT_EQ("foo|", Join(SplitString("fooabc", "abc"))); + EXPECT_EQ(0, SplitString("", ",").size()); + EXPECT_EQ(0, SplitString("", "").size()); + EXPECT_EQ("abc", Join(SplitString("abc", ""))); +} TEST(CommonTest, GetPadding) { EXPECT_EQ(0, GetPadding(0, 4)); @@ -19,6 +53,38 @@ EXPECT_EQ(0, GetPadding(8, 4)); } +TEST(CommonTest, GetDefaultConfigFilePath) { + // With $HOME missing and none of the XDG vars, we should just use /etc. + ASSERT_EQ(0, unsetenv("HOME")); + ASSERT_EQ(0, unsetenv("XDG_CONFIG_HOME")); + ASSERT_EQ(0, unsetenv("XDG_CONFIG_DIRS")); + EXPECT_EQ("/etc/xsettingsd/xsettingsd.conf", + Join(GetDefaultConfigFilePaths())); + + // Now set $HOME. It should be searched first, followed by the default XDG + // paths. + ASSERT_EQ(0, setenv("HOME", "/home/user", 1 /* overwrite */)); + EXPECT_EQ("/home/user/.xsettingsd|" + "/home/user/.config/xsettingsd/xsettingsd.conf|" + "/etc/xsettingsd/xsettingsd.conf", + Join(GetDefaultConfigFilePaths())); + + // Use a custom $XDG_CONFIG_HOME. + ASSERT_EQ(0, setenv("XDG_CONFIG_HOME", "/home/user/.myconf", 1)); + EXPECT_EQ("/home/user/.xsettingsd|" + "/home/user/.myconf/xsettingsd/xsettingsd.conf|" + "/etc/xsettingsd/xsettingsd.conf", + Join(GetDefaultConfigFilePaths())); + + // Now put a few paths in $XDG_CONFIG_DIRS. + ASSERT_EQ(0, setenv("XDG_CONFIG_DIRS", "/etc2:/etc3", 1)); + EXPECT_EQ("/home/user/.xsettingsd|" + "/home/user/.myconf/xsettingsd/xsettingsd.conf|" + "/etc2/xsettingsd/xsettingsd.conf|" + "/etc3/xsettingsd/xsettingsd.conf", + Join(GetDefaultConfigFilePaths())); +} + } // namespace xsettingsd int main(int argc, char** argv) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xsettingsd-0.0~git20141123/xsettingsd.cc new/xsettingsd-0.0~git20150615/xsettingsd.cc --- old/xsettingsd-0.0~git20141123/xsettingsd.cc 2014-11-23 06:12:49.000000000 +0100 +++ new/xsettingsd-0.0~git20150615/xsettingsd.cc 2015-06-15 03:02:00.000000000 +0200 @@ -1,25 +1,41 @@ // Copyright 2009 Daniel Erat <d...@erat.org> // All rights reserved. +#include <getopt.h> +#include <unistd.h> + #include <cerrno> #include <csignal> #include <cstdio> #include <cstdlib> #include <cstring> -#include <getopt.h> #include <string> -#include <unistd.h> #include "common.h" #include "config_parser.h" #include "settings_manager.h" -using namespace xsettingsd; using std::string; +using std::vector; + +namespace { void HandleSignal(int signum) { } +// Returns the first path in |paths| that is readable, or an empty string if +// none of the paths can be read. +string GetFirstReadablePath(const vector<string>& paths) { + for (size_t i = 0; i < paths.size(); ++i) { + if (access(paths[i].c_str(), R_OK) == 0) { + return paths[i]; + } + } + return string(); +} + +} // namespace + int main(int argc, char** argv) { static const char* kUsage = "Usage: xsettingsd [OPTION] ...\n" @@ -32,7 +48,7 @@ " -s, --screen=SCREEN screen to use (default is all)\n"; int screen = -1; - string config_file = ""; + string config_file; struct option options[] = { { "config", 1, NULL, 'c', }, @@ -61,17 +77,20 @@ } } - // Use the default config file if one wasn't supplied via a flag. + // Check default config file locations if one wasn't supplied via a flag. if (config_file.empty()) { - const char* home_dir = getenv("HOME"); - if (!home_dir) { - fprintf(stderr, "%s: $HOME undefined; use --config=FILE\n", kProgName); + const vector<string> paths = xsettingsd::GetDefaultConfigFilePaths(); + config_file = GetFirstReadablePath(paths); + if (config_file.empty()) { + fprintf(stderr, "%s: Couldn't find config file. Tried the following:\n", + xsettingsd::kProgName); + for (size_t i = 0; i < paths.size(); ++i) + fprintf(stderr, " %s\n", paths[i].c_str()); return 1; } - config_file = StringPrintf("%s/.xsettingsd", home_dir); } - SettingsManager manager(config_file); + xsettingsd::SettingsManager manager(config_file); if (!manager.LoadConfig()) return 1; if (!manager.InitX11(screen, true))