/usr/bin/dh_installzope is in zope-debhelper 0.3.15.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | #!/usr/bin/perl -w
=head1 NAME
dh_installzope - install zope product and extension files into package build
directories
=cut
use strict;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<dh_installzope> [S<I<debhelper options>>] [B<-n>] [B<-X>I<item>] [S<I<dir ...>>]
=head1 DESCRIPTION
dh_installzope is a debhelper program that is responsible for installing
zope products and extensions into package build directories.
Directory names are interpreted as zope product names and will be
installed into the first package dh_installzope is told to act on. By
default, this is the first binary package in debian/control, but if
you use B<-p>, B<-i>, or B<-a> flags, it will be the first package
specified by those flags.
dh_installzope automatically installs debian/dzproduct and debian/dzextension
if it exists. If dh_installzope is acting on multiple packages, debian/dzproduct
and debian/dzextension files will be installed into the first package.
Use debian/package.dzproduct and debian/package.dzextension for different
binary packages.
If your package needs to register more than one product or extension,
you need multiple files. To accomplish this, you can use files named
debian/package.dzproduct.* and debian/package.dzextension.*
Missing dzproduct and dzextension files for the first package dh_installzope
is told to act on are generated and installed automatically.
The substitution variable zope:Depends is replaced by a list of the available
zope versions.
=head1 OPTIONS
=over 4
=item B<-n>, B<--noscripts>
Do not modify postinst/prerm scripts.
=item B<-Xitem>, B<--exclude=item>
Exclude files that contain "item" anywhere in their filename from
being installed.
=item I<directory ...>
Install these directories as products into the first package acted on.
=back
=head1 EXAMPLES
This is an example of a debian/package.dzproduct file:
Package: zope-cmfdefault1.4
Name: CMFDefault
Directory: CMFDefault:1.4
Depends: CMFTopic:1.4
Version: 1.4.7-1
ZopeVersions: 2.9 2.8
The Version field is added or updated by dh_installzope. If Name
and Directory match, the latter can be omitted. A deviating
Directory is used to install different product versions. A Directory
has the form <product name>[:<suffix>].
It is possible to specify the list of zope versions for the 2.x serie
using a >= relation, like in this example:
Package: zope-psycopgda
ZopeVersions: >= 2.7
This allows bin-NMUs of zope products on new Zope 2.x major versions,
and for this reason it should be the preferred syntax.
=head1 NOTES
Note that this command is not idempotent. "dh_clean B<-k>" should be called
between invocations of this command. Otherwise, it may cause multiple
instances of the same text to be added to maintainer scripts.
=cut
init();
my @zope_versions = ('2.6', '2.7', '2.8', '2.9', '2.10', '2.11', '2.12', '2.13', '2.14', '3');
my %python_versions = ('3', '2.4', '2.5', '2.6', '2.7');
sub read_dzfile {
my $fn = shift;
my %fields=();
open (DZ, "debian/$fn") || error("cannot read debian/$fn: $!\n");
while (<DZ>) {
chomp;
s/\s+$//;
if (/^([^:]+):\s*(.*)/) {
$fields{$1} = $2;
}
}
close DZ;
return %fields;
}
sub write_dzfile {
my ($fn, %fields) = @_;
my ($out) = "";
open (DZ, ">$fn") || error("cannot write $fn: $!\n");
foreach (keys %fields) {
$out = "$_: $fields{$_}\n" . $out;
}
print DZ $out;
close DZ;
}
sub addzopesubstvars {
my ($package, %fields) = @_;
my ($var) = "zope-common (>= 0.5.49), ";
my (@versions) = ();
my ($minor) = "0";
if ($fields{'ZopeVersions'}) {
my (@vers) = split(/ /, $fields{'ZopeVersions'});
if ($vers[0] eq '>=') {
@versions = ();
if ($vers[1] =~ m/^[0-9]\.([0-9]+)$/) {
$minor = $1;
}
foreach (@zope_versions) {
if ($_ =~ m/[0-9]\.([0-9]+)/ && int($1) >= int($minor)) {
push(@versions, $_);
}
}
} else {
@versions = @vers;
}
} else {
@versions = @zope_versions;
}
foreach (reverse(@versions)) {
$var .= "zope" . $_ . " | ";
}
$var = substr($var, 0, length($var)-3);
addsubstvar($package, "zope:Depends", $var);
return join(" ", reverse(@versions));
}
my @autoscripts = ('preinst', 'postinst', 'prerm', 'postrm');
foreach my $package (@{$dh{DOPACKAGES}}) {
next if is_udeb($package);
my $tmp=tmpdir($package);
my $dzproductfile=pkgfile($package,"dzproduct");
my $dzextensionfile=pkgfile($package,"dzextension");
my $archdir=package_arch($package) eq 'all' ? 'share' : 'lib';
# needed to get $dh{VERSION}
my $isnative = isnative($package);
my $addon_version;
my @dirs;
if ($package eq $dh{FIRSTPACKAGE} && @ARGV) {
push @dirs, @ARGV;
}
if ($dh{V_FLAG}) {
$addon_version = $dh{V_FLAG};
}
# Handle dzproduct and dzextension files. There are two filename formats,
# the usual plus an extended format (debian/package.*).
my @dzpr_files;
my @dzex_files;
opendir(DEB,"debian/") || error("can't read debian directory: $!");
# If this is the main package, we need to handle unprefixed filenames.
# For all packages, we must support both the usual filename format plus
# that format with a period an something appended.
my $regexp="\Q$package\E\.";
if ($package eq $dh{MAINPACKAGE}) {
$regexp="(|$regexp)";
}
foreach my $fn (grep {/^${regexp}dz(product|extension)(\..*)?$/} readdir(DEB)) {
# .EX are example files, generated by eg, dh-make
next if $fn=~/\.EX$/;
if ($fn=~/dzproduct/) {
push @dzpr_files, $fn;
}
else {
push @dzex_files, $fn;
}
}
closedir(DEB);
if (@dirs > 0 && @dzpr_files > 1) {
error("unable to handle directories and multiple dzproduct/dzextension files");
}
if (@dirs > 1 && @dzpr_files > 0) {
error("unable to handle multiple directories and dzproduct/dzextension files");
}
if (@dirs) {
my %tdzproduct;
if (@dzpr_files) {
%tdzproduct = read_dzfile(shift @dzpr_files);
if (not exists $tdzproduct{'Package'}) {
$tdzproduct{'Package'} = $package;
}
}
else {
$tdzproduct{'Package'} = $package;
}
$tdzproduct{'Version'} = $dh{VERSION};
$tdzproduct{'ZopeVersions'} = addzopesubstvars($package, %tdzproduct);
my $exclude = '';
if ($dh{EXCLUDE_FIND}) {
$exclude = ' -and -not \( '.$dh{EXCLUDE_FIND}.' \)';
}
doit("install","-d","$tmp/usr/$archdir/zope/Products");
foreach my $dir (@dirs) {
my %dzproduct = %tdzproduct;
my ($dir_basename) = basename($dir);
if (!$dzproduct{'Name'}) {
if ($dir ne '.') {
$dzproduct{'Name'} = $dir_basename;
} else {
error("you have to specify the product name in the dzproduct file");
}
}
my $target;
if ($dzproduct{'Directory'}) {
$target = $dzproduct{'Directory'};
}
else {
$target = $dzproduct{'Name'};
if ($addon_version) {
$dzproduct{'Directory'} = $package;
}
}
my ($exclude_debian) = '';
$exclude_debian = ' -and -not \( -path \'*/debian/*\' -or -path \'*-stamp\' \)' if ($dir eq ".");
doit("install","-d","$tmp/usr/$archdir/zope/Products/$target");
my $pwd=`pwd`; chop($pwd);
if (exists $dzproduct{'Global'} && $dzproduct{'Global'} eq 'yes') {
if ($dzproduct{'ZopeVersions'} != '3') {
error("global products are supported only for zope3");
}
my ($pyver) = $python_versions{$dzproduct{'ZopeVersions'}};
addsubstvar($package, "zope:PythonVersion", $pyver);
complex_doit("cd $dir && find -type f$exclude$exclude_debian " .
"-exec install -D --mode=644 {} $pwd/$tmp/usr/lib/python$pyver/" .
"site-packages/$target/{} \\;");
complex_doit("mkdir -p $pwd/$tmp/usr/$archdir/zope/Products/$target");
complex_doit("find $pwd/$tmp/usr/lib/python$pyver/site-packages/$target".
" \\( -name \\*-configure.zcml -o -name \\*-ftesting.meta -o -name " .
"\\*-meta.zcml \\) -exec mv {} $pwd/$tmp/usr/$archdir/zope/Products" .
"/$target/ \\;");
} else {
complex_doit("cd $dir && find -type f$exclude$exclude_debian -exec install -D ".
"--mode=644 {} $pwd/$tmp/usr/$archdir/zope/Products/$target/{} \\;");
}
write_dzfile("$tmp/usr/$archdir/zope/Products/$target/.dzproduct", %dzproduct);
if (! $dh{NOSCRIPTS}) {
foreach my $script (@autoscripts) {
autoscript($package,$script,"$script-dzproduct",
"s,#DZ-DIR#,/usr/$archdir/zope/Products/$target,;"
. "s,#DZ-ADDON#,$dzproduct{'Name'},;"
. "s,#PACKAGE#,$package,",
);
}
}
}
doit("chown","-R","0:0","$tmp/usr/$archdir/zope/Products");
doit("chmod","-R","go=rX","$tmp/usr/$archdir/zope/Products");
doit("chmod","-R","u+rw","$tmp/usr/$archdir/zope/Products");
}
foreach my $fn (@dzpr_files) {
my %dzproduct = read_dzfile($fn);
my $target = $dzproduct{'Directory'} ? $dzproduct{'Directory'} : $dzproduct{'Name'};
if (! $target) {
error("no Name or Directory key in debian/$fn")
}
if (not exists $dzproduct{'Package'}) {
$dzproduct{'Package'} = $package;
}
if (! -d "$tmp/usr/$archdir/zope/Products/$target") {
doit("install","-g",0,"-o",0,"-d","$tmp/usr/$archdir/zope/Products/$target");
}
doit("install","-g",0,"-o",0,"-m644","-p","debian/$fn",
"$tmp/usr/$archdir/zope/Products/$target/.dzproduct");
$dzproduct{'Version'} = $dh{VERSION};
$dzproduct{'ZopeVersions'} = addzopesubstvars($package, %dzproduct) if exists $dzproduct{'ZopeVersions'};
write_dzfile("$tmp/usr/$archdir/zope/Products/$target/.dzproduct", %dzproduct);
if (! $dh{NOSCRIPTS}) {
foreach my $script (@autoscripts) {
autoscript($package,$script,"$script-dzproduct",
"s,#DZ-DIR#,/usr/$archdir/zope/Products/$target,;"
. "s,#DZ-ADDON#,$dzproduct{'Name'},;"
. "s,#PACKAGE#,$package,",
);
}
}
}
foreach my $fn (@dzex_files) {
my %dzext = read_dzfile($fn);
my $target = $dzext{'Directory'} ? $dzext{'Directory'} : $dzext{'Name'};
if (! $target) {
error("no Extension or Directory key in debian/$fn")
}
if (not exists $dzext{'Package'}) {
$dzext{'Package'} = $package;
}
if (! -d "$tmp/usr/$archdir/zope/Extensions/$target") {
doit("install","-g",0,"-o",0,"-d","$tmp/usr/$archdir/zope/Extensions/$target");
}
doit("install","-g",0,"-o",0,"-m644","-p","debian/$fn",
"$tmp/usr/$archdir/zope/Extensions/$target/.dzextension");
$dzext{'Version'} = $dh{VERSION};
$dzext{'ZopeVersions'} = addzopesubstvars($package, %dzext) if exists $dzext{'ZopeVersions'};
write_dzfile("$tmp/usr/$archdir/zope/Extensions/$target/.dzextension", %dzext);
if (! $dh{NOSCRIPTS}) {
foreach my $script (@autoscripts) {
autoscript($package,$script,"$script-dzextension",
"s,#DZ-DIR#,/usr/$archdir/zope/Extensions/$target,;"
. "s,#DZ-ADDON#,$dzext{'Name'},;"
. "s,#PACKAGE#,$package,",
);
}
}
}
}
=head1 SEE ALSO
L<debhelper(7)>
This program is a part of zope-debhelper.
=head1 AUTHOR
Matthias Klose <doko@ubuntu.com>
Fabio Tranchitella <kobold@debian.org>
=cut
|