2
* JB, the Jean-Yves Lefort's Build System
3
* Copyright (C) 2008 Jean-Yves Lefort <jylefort@brutele.be>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
#include "jb-install-options.h"
21
#include "jb-action.h"
22
#include "jb-variable.h"
25
jb_install_options_init (JBInstallOptions *self)
27
g_return_if_fail(self != NULL);
29
self->installdir = NULL;
36
jb_install_options_set_installdir (JBInstallOptions *self,
37
const char *installdir)
39
g_return_if_fail(self != NULL);
41
g_free(self->installdir);
42
self->installdir = g_strdup(installdir);
46
jb_install_options_set_owner (JBInstallOptions *self, const char *owner)
48
g_return_if_fail(self != NULL);
51
self->owner = g_strdup(owner);
55
jb_install_options_set_group (JBInstallOptions *self, const char *group)
57
g_return_if_fail(self != NULL);
60
self->group = g_strdup(group);
64
jb_install_options_set_extra_mode (JBInstallOptions *self, mode_t extra_mode)
66
g_return_if_fail(self != NULL);
68
self->extra_mode = extra_mode;
72
jb_install_options_install (JBInstallOptions *self,
75
const char *default_owner,
76
const char *default_group,
83
g_return_if_fail(self != NULL);
84
g_return_if_fail(srcfile != NULL);
86
if (self->installdir == NULL)
89
owner = self->owner != NULL ? self->owner : default_owner;
90
group = self->group != NULL ? self->group : default_group;
91
mode = default_mode | self->extra_mode;
94
jb_action_install_file(srcfile,
103
full_dstfile = g_strdup_printf("%s/%s", self->installdir, dstfile);
104
jb_action_install_to_file(srcfile,
109
g_free(full_dstfile);
114
jb_install_options_install_data (JBInstallOptions *self,
118
g_return_if_fail(self != NULL);
119
g_return_if_fail(srcfile != NULL);
121
jb_install_options_install(self,
124
jb_variable_get_string_or_null("data-owner"),
125
jb_variable_get_string_or_null("data-group"),
126
jb_variable_get_mode("data-mode"));
130
jb_install_options_install_program (JBInstallOptions *self,
134
g_return_if_fail(self != NULL);
135
g_return_if_fail(srcfile != NULL);
137
jb_install_options_install(self,
140
jb_variable_get_string_or_null("program-owner"),
141
jb_variable_get_string_or_null("program-group"),
142
jb_variable_get_mode("program-mode"));
146
jb_install_options_install_library (JBInstallOptions *self,
150
g_return_if_fail(self != NULL);
151
g_return_if_fail(srcfile != NULL);
153
jb_install_options_install(self,
156
jb_variable_get_string_or_null("library-owner"),
157
jb_variable_get_string_or_null("library-group"),
158
jb_variable_get_mode("library-mode"));