Make udev hwdb optional by using pnp.ids as fallback
FreeBSD libudev-devd doesn't implement udev hwdb, and I cannot find any
way to do the conversion in the FreeBSD source tree. Therefore, the
fallback code removed in commit c9650c0bb7324c32d82fa6d7d898e236f10ea63b
is brought back to use the pnp.ids file.
Ting-Wei Lan authored 6 years ago
Richard Hughes committed 6 years ago
105 | 105 |
static gchar *
|
106 | 106 |
cd_edid_convert_pnp_id_to_string (const gchar *pnp_id)
|
107 | 107 |
{
|
|
108 |
#ifndef PNP_IDS
|
108 | 109 |
gchar *vendor = NULL;
|
109 | 110 |
struct udev_hwdb *hwdb = NULL;
|
110 | 111 |
struct udev_list_entry *e;
|
|
139 | 140 |
if (udev != NULL)
|
140 | 141 |
udev_unref (udev);
|
141 | 142 |
return vendor;
|
|
143 |
#else
|
|
144 |
g_autofree gchar *data = NULL;
|
|
145 |
|
|
146 |
/* load pnp.ids */
|
|
147 |
if (!g_file_get_contents (PNP_IDS, &data, NULL, NULL))
|
|
148 |
return NULL;
|
|
149 |
if (data == NULL)
|
|
150 |
return NULL;
|
|
151 |
|
|
152 |
/* get the vendor name from the tab delimited data */
|
|
153 |
for (gchar *idx = data; idx != NULL; ) {
|
|
154 |
if (strncmp (idx, pnp_id, 3) == 0) {
|
|
155 |
gchar *idx2 = g_strstr_len (idx, -1, "\n");
|
|
156 |
if (idx2 != NULL)
|
|
157 |
*idx2 = '\0';
|
|
158 |
return g_strdup (idx + 4);
|
|
159 |
}
|
|
160 |
idx = g_strstr_len (idx, -1, "\n");
|
|
161 |
if (idx != NULL)
|
|
162 |
idx++;
|
|
163 |
}
|
|
164 |
return NULL;
|
|
165 |
#endif
|
142 | 166 |
}
|
143 | 167 |
|
144 | 168 |
/**
|
181 | 181 |
message('RUNNING THIS AS root IS NOT A GOOD IDEA SEE --with-daemon-user')
|
182 | 182 |
endif
|
183 | 183 |
|
|
184 |
if get_option('with-pnp-ids') != ''
|
|
185 |
conf.set_quoted('PNP_IDS', get_option('with-pnp-ids'))
|
|
186 |
endif
|
|
187 |
|
184 | 188 |
polkit = dependency('polkit-gobject-1', version : '>= 0.103')
|
185 | 189 |
if polkit.version().version_compare('>= 0.114')
|
186 | 190 |
conf.set('POLKIT_HAS_AUTOPTR_MACROS', '1')
|
10 | 10 |
option('enable-tests', type : 'boolean', value : true, description : 'Build self tests')
|
11 | 11 |
option('enable-installed-tests', type : 'boolean', value : false, description : 'Install tests')
|
12 | 12 |
option('with-daemon-user', type : 'string', value : 'root', description : 'User for running the colord daemon')
|
|
13 |
option('with-pnp-ids', type : 'string', value : '', description : 'Location of pnp.ids if hwdb is not available')
|
13 | 14 |
option('enable-man', type : 'boolean', value : true, description : 'Generate man pages')
|
14 | 15 |
option('enable-docs', type : 'boolean', value : true, description : 'Generate documentation')
|