45
# 'abs_path' from Cwd resolves symlinks, and we don't want that to happen
46
# (otherwise it's harder to remove the prefix of the generated output)
47
sub make_absolute_path {
56
# gdk-pixbuf-query-loaders helper (generates a GdkPixbuf loaders module
57
# file on its stdout with *.so passed on its command-line)
59
if ($ENV{GTK_QUERYLOADERS}) {
60
$queryloaders = $ENV{GTK_QUERYLOADERS};
62
$queryloaders = '/@LIBDIR@/libgtk2.0-0/gdk-pixbuf-query-loaders';
65
# gtk-query-immodules-2.0 helper (generates an IM module file on its
66
# stdout with *.so passed on its command-line)
68
if ($ENV{GTK_QUERYIMMODULES}) {
69
$queryimmodules = $ENV{GTK_QUERYIMMODULES};
71
$queryimmodules = '/@LIBDIR@/libgtk2.0-0/gtk-query-immodules-2.0';
74
# relative Gtk base module path
75
my $modules_base_path = '@MODULES_BASE_PATH@';
77
# relative path to GdkPixbuf loaders modules (separated by ":")
78
my $loaders_modules_path = "$modules_base_path/loaders";
79
# relative directory to store the generated loader module file
80
my $loader_module_files_d = "$modules_base_path/loader-files.d";
82
# relative path to IM modules (separated by ":")
83
my $im_modules_path = "$modules_base_path/immodules";
84
# relative directory to store the generated IM module file
85
my $im_module_files_d = "$modules_base_path/immodule-files.d";
87
# Gtk binary version virtual Provide
88
my $gtk_binver_dep = '@GTK_BINVER_DEP@';
91
# where to store the modules we find
92
my $modules_ref = shift;
93
# base directory to prepend to the list of locations
95
# list of locations to search relative to $basedir separated with ":"
98
foreach (map("$basedir/$_", split(/:/, $path))) {
99
# it's necessary to make the path absolute to strip the build-time
101
my $path = make_absolute_path($_);
103
verbose_print("skipping $path.");
107
# if path is a directory (or symlink to a directory), search for
108
# *.so files or symlinks
110
"find '$path' -name '*.so' \\( -type f -or -type l \\) |")
111
or die "Can't run find: $!";
114
push @$modules_ref, $_;
116
close FIND or die "Error while running find: $!";
117
} elsif (-f $path or -l $path) {
118
# if path is a file or symlink, simply add it to the list
119
push @$modules_ref, $path;
121
error("$path has unknown file type.");
127
# absolute pathname to query helper
128
my $querymodules = shift;
129
# base directory to prepend to the output module file and to strip
132
# relative directory where to write the module file
133
my $module_files_d = shift;
134
# relative path of the module file
135
my $module_file = shift;
139
my $do_query = join ' ', $querymodules, @modules;
140
open(QUERY, "$do_query 2>&1 |")
141
or die "Can't query modules with $querymodules: $!";
143
doit("rm", "-f", "$module_file");
144
if (! -d "$basedir/$module_files_d") {
145
doit("install", "-d", "$basedir/$module_files_d");
147
complex_doit("printf '%s\\n' '# automatically generated by dh_gtkmodules, do not edit' >>$module_file");
149
my $absolute_basedir = make_absolute_path($basedir);
154
# if some module couldn't be loaded by the query helper, bail out
155
if (m#^g_module_open\(\) failed for #) {
156
error("$querymodules could not load a module:\n$_\nYou should probably make the libraries built by your package available via LD_LIBRARY_PATH.");
158
# strip build-time prefix from output
159
if (m#^\Q"$absolute_basedir/\E#) {
160
s#^\Q"$absolute_basedir/\E#"/#;
162
complex_doit("printf '%s\\n' '$_' >>$module_file");
165
# nothing written to the module file, fail miserably
167
doit("rm", "-f", "$module_file");
168
error("Internal error: could not find any module in the output of $querymodules.");
171
doit("chmod", 644, "$module_file");
172
doit("chown", "0:0", "$module_file");
174
close QUERY or die "Error while querying modules with $querymodules: $!";
177
foreach my $package (@{$dh{DOPACKAGES}}) {
178
my $tmp = tmpdir($package);
179
my @loaders_modules = ();
182
# if the versionned directory isn't present, give up on package
183
if (! -d "$tmp/$modules_base_path") {
187
# since the versionned module directory exists, generate a dependency
188
# on the Gtk binary version
190
addsubstvar($package, "misc:Depends", $gtk_binver_dep);
193
# search for specific module types
194
find_modules(\@loaders_modules, $tmp, $loaders_modules_path);
195
find_modules(\@im_modules, $tmp, $im_modules_path);
197
warning("Package $package has " . @loaders_modules . " GdkPixbuf loaders and " . @im_modules . " Gtk IM modules.");
199
# if no modules of these types were found, we're done
200
if (0 == @loaders_modules + @im_modules) {
204
if (@loaders_modules) {
205
query_modules($queryloaders,
207
$loader_module_files_d,
208
"$tmp/$loader_module_files_d/$package.loaders",
212
query_modules($queryimmodules,
215
"$tmp/$im_module_files_d/$package.immodules",
45
warning("This program is deprecated, everything is handled by triggers now.");