From 336440cddb110596b6ae30417f5496b711f3b4f7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 5 Mar 2019 12:52:20 +1000 Subject: [PATCH] Install the device files in the top-level datadir Now that the SVGs are gone, we don't need the subfolder anymore Signed-off-by: Peter Hutterer --- circle.yml | 2 +- meson.build | 4 ++-- src/libratbag-data.c | 9 +++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/circle.yml b/circle.yml index 4da54ce4..290564b8 100644 --- a/circle.yml +++ b/circle.yml @@ -34,7 +34,7 @@ libratbag_references: name: Checking installation command: | PREFIX=/usr/local/ - diff -u <(cd data/devices; ls *.device) <(cd $PREFIX/share/libratbag/devices; ls *.device) + diff -u <(cd data/devices; ls *.device) <(cd $PREFIX/share/libratbag; ls *.device) check_uninstall: &check_uninstall run: name: Checking if any files are left after uninstall diff --git a/meson.build b/meson.build index 49d38bd7..84ff3623 100644 --- a/meson.build +++ b/meson.build @@ -43,7 +43,7 @@ config_h.set_quoted('FALLBACK_SVG_NAME', 'fallback.svg') libratbag_data_dir = join_paths(get_option('prefix'), get_option('datadir'), 'libratbag') -libratbag_data_dir_devel = join_paths(meson.source_root(), 'data') +libratbag_data_dir_devel = join_paths(meson.source_root(), 'data', 'devices') config_h.set_quoted('LIBRATBAG_DATA_DIR', libratbag_data_dir) # Coverity breaks because it doesn't define _Float128 correctly, you'll end @@ -316,7 +316,7 @@ data_files = files( ) install_data(data_files, - install_dir : join_paths(get_option('datadir'), 'libratbag', 'devices')) + install_dir : join_paths(get_option('datadir'), 'libratbag')) data_parse_test = find_program(join_paths(meson.source_root(), 'data/devices/data-parse-test.py')) test('data-parse-test', data_parse_test, args: data_files) diff --git a/src/libratbag-data.c b/src/libratbag-data.c index 825abd3d..78e31872 100644 --- a/src/libratbag-data.c +++ b/src/libratbag-data.c @@ -465,19 +465,16 @@ ratbag_device_data_new_for_id(struct ratbag *ratbag, const struct input_id *id) struct dirent **files; int n, nfiles; const char *datadir; - char devicedir[PATH_MAX] = {0}; datadir = getenv("LIBRATBAG_DATA_DIR"); if (!datadir) datadir = LIBRATBAG_DATA_DIR; log_debug(ratbag, "Using data directory '%s'\n", datadir); - snprintf(devicedir, sizeof(devicedir), "%s/devices", datadir); - - n = scandir(devicedir, &files, filter_device_files, alphasort); + n = scandir(datadir, &files, filter_device_files, alphasort); if (n <= 0) { log_error(ratbag, "Unable to locate device files in %s: %s\n", - devicedir, n == 0 ? "No files found" : strerror(errno)); + datadir, n == 0 ? "No files found" : strerror(errno)); return NULL; } @@ -486,7 +483,7 @@ ratbag_device_data_new_for_id(struct ratbag *ratbag, const struct input_id *id) _cleanup_(freep) char *file = NULL; int rc; - rc = xasprintf(&file, "%s/%s", devicedir, files[n]->d_name); + rc = xasprintf(&file, "%s/%s", datadir, files[n]->d_name); if (rc == -1) goto out; if (file_data_matches(ratbag, file, id, &data))