Skip to content

Commit

Permalink
build: allow installing default.json to sysconfdir (linuxmint#208)
Browse files Browse the repository at this point in the history
In NixOS, packages are installed to their own prefix and
we are not allowed to install this file to /etc.
bobby285271 authored Jul 4, 2023

Unverified

This user has not yet uploaded their public signing key.
1 parent 863e734 commit 81359ef
Showing 5 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion files/meson.build
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
install_data(sources : 'timeshift.json', rename : 'default.json', install_dir : '/etc/timeshift')
install_data(
sources: 'timeshift.json',
rename: 'default.json',
install_dir: get_option('sysconfdir') / 'timeshift',
)
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ project(
'timeshift', 'vala', 'c',
version: '23.06.2',
license : 'GPL-2.0-or-later',
meson_version: '>= 0.54.0',
default_options: ['c_std=c99', 'build.c_std=c99'])

dependencies = [
6 changes: 5 additions & 1 deletion src/Core/Main.vala
Original file line number Diff line number Diff line change
@@ -285,7 +285,7 @@ public class Main : GLib.Object{
this.share_folder = "/usr/share";
this.app_conf_path = "/etc/timeshift/timeshift.json";
this.app_conf_path_old = "/etc/timeshift.json";
this.app_conf_path_default = "/etc/timeshift/default.json";
this.app_conf_path_default = GLib.Path.build_path (GLib.Path.DIR_SEPARATOR_S, Constants.SYSCONFDIR, "timeshift", "default.json");
//sys_root and sys_home will be initialized by update_partition_list()

// check if running locally ------------------------
@@ -3268,6 +3268,10 @@ public class Main : GLib.Object{
file_move(app_conf_path_old, app_conf_path);
}
else if (file_exists(app_conf_path_default)){
// /etc/timeshift might not pre-exist when sysconfdir is not /etc
if (!dir_exists(file_parent(app_conf_path))){
dir_create(file_parent(app_conf_path));
}
// copy default file
file_copy(app_conf_path_default, app_conf_path);
}
1 change: 1 addition & 0 deletions src/config.vala.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
namespace Constants {
public const string VERSION = "@VERSION@";
public const string SYSCONFDIR = "@SYSCONFDIR@";
}
13 changes: 10 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -2,10 +2,17 @@ conf_data = configuration_data()
conf_data.set('GETTEXT_PACKAGE', meson.project_name())
conf_data.set('VERSION', meson.project_version())

fs = import('fs')
if (fs.is_absolute(get_option('sysconfdir')))
conf_data.set('SYSCONFDIR', get_option('sysconfdir'))
else
conf_data.set('SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
endif

config_header = configure_file(
input: 'config.vala.in',
output: 'config.vala',
configuration: conf_data
input: 'config.vala.in',
output: 'config.vala',
configuration: conf_data
)

sources_core = files([

0 comments on commit 81359ef

Please sign in to comment.