5 dh_pangomodules - create a Pango Module file for all Pango modules
10 use Debian::Debhelper::Dh_Lib;
15 B<dh_pangomodules> [S<I<debhelper options>>] [S<I<directory or module>> ...]
19 B<dh_pangomodules> is a debhelper program that handles correctly
20 generating Pango Module files with modules that it finds in the
21 Pango Modules Path, in directories you pass on the command line,
22 and on the command line.
24 This command scans the specified packages for Pango modules thanks to
25 pango-querymodules. When any module is found, the generated
26 <package>.modules file is installed into the corresponding package and a
27 dependency on the Module API version of pango is added to
36 Do not generate any dependencies in ${misc:Depends}.
42 # 'abs_path' from Cwd resolves symlinks, and we don't want that to happen
43 # (otherwise it's harder to remove the prefix of the generated output)
44 sub make_absolute_path {
53 # pango-querymodules helper (generates a Pango Module File on its stdout with
54 # *.so passed on its command-line)
56 if ($ENV{PANGO_QUERYMODULES}) {
57 $querymodules = $ENV{PANGO_QUERYMODULES};
59 $querymodules = '/usr/bin/pango-querymodules';
62 # relative Pango Modules Path (separated by ":")
63 my $modules_path = '@MODULES_PATH@';
65 # relative directory to store the generated Pango Module File
66 my $module_files_d = '@MODULE_FILES_D@';
68 # Pango Module API version virtual Provide
69 my $pango_modver_dep = '@PANGO_MODVER_DEP@';
71 foreach my $package (@{$dh{DOPACKAGES}}) {
72 my $tmp = tmpdir($package);
75 # locations to search for modules
76 my @module_search_locations;
79 foreach my $dir (split(/:/, $modules_path)) {
80 push @module_search_locations, "$tmp/$dir"
83 # append the remaining command line arguments (either modules or
84 # directories to scan for *.so modules)
85 push @module_search_locations, @ARGV if @ARGV;
87 foreach (@module_search_locations) {
88 # it's necessary to make the path absolute to strip the build-time
90 my $path = make_absolute_path($_);
92 verbose_print("skipping $path.");
96 # if path is a directory (or symlink to a directory), search for
97 # *.so files or symlinks
99 "find '$path' -name '*.so' \\( -type f -or -type l \\) |")
100 or die "Can't run find: $!";
106 } elsif (-f $path or -l $path) {
107 # if path is a file or symlink, simply add it to the list
108 push @modules, $path;
110 error("$path has unknown file type.");
115 warning("couldn't find any Pango Modules for package $package.");
119 # since there's at least one module, generate a dependency on the
120 # Pango binary version
122 addsubstvar($package, "misc:Depends", $pango_modver_dep);
125 my $do_query = join ' ', $querymodules, @modules;
126 open(QUERY, "$do_query |")
127 or die "Can't query modules: $!";
129 my $module_file = "$tmp/$module_files_d/$package.modules";
130 doit("rm", "-f", "$module_file");
131 if (! -d "$tmp/$module_files_d") {
132 doit("install", "-d", "$tmp/$module_files_d");
134 complex_doit("printf '%s\\n' '# automatically generated by dh_pangomodules, do not edit' >>$module_file");
136 my $absolute_tmp = make_absolute_path($tmp);
141 # strip build-time prefix from output
142 if (m#^\Q$absolute_tmp/\E#) {
143 s#^\Q$absolute_tmp/\E#/#;
144 complex_doit("printf '%s\\n' '$_' >>$module_file");
147 error("can't strip $absolute_tmp from output.");
150 doit("chmod", 644, "$module_file");
151 doit("chown", "0:0", "$module_file");
162 This program relies on Debhelper, but is shipped with the Pango
167 Loic Minier <lool@dooz.org>