1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Base subroutines for the Project-Builder project
|
---|
4 | #
|
---|
5 | # $Id$
|
---|
6 | #
|
---|
7 |
|
---|
8 | use strict;
|
---|
9 | use lib qw (lib);
|
---|
10 | use File::Basename;
|
---|
11 | use File::Path;
|
---|
12 | use File::Copy;
|
---|
13 | use File::Temp qw /tempdir/;
|
---|
14 | use Data::Dumper;
|
---|
15 | use POSIX qw(strftime);
|
---|
16 |
|
---|
17 | use ProjectBuilder::Changelog qw (pb_changelog);
|
---|
18 |
|
---|
19 | $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
|
---|
20 |
|
---|
21 | my $debug = 0;
|
---|
22 | my $LOG = \*STDOUT;
|
---|
23 |
|
---|
24 | sub pb_env_init {
|
---|
25 |
|
---|
26 | my $proj=shift || undef;
|
---|
27 | my $pbinit=shift || undef;
|
---|
28 | my $ver;
|
---|
29 | my $tag;
|
---|
30 |
|
---|
31 | #
|
---|
32 | # Check project name
|
---|
33 | # Could be with env var PBPROJ
|
---|
34 | # or option -p
|
---|
35 | # if not define take the first in conf file
|
---|
36 | #
|
---|
37 | if ((defined $ENV{'PBPROJ'}) &&
|
---|
38 | (not (defined $proj))) {
|
---|
39 | $proj = $ENV{'PBPROJ'};
|
---|
40 | }
|
---|
41 |
|
---|
42 | #
|
---|
43 | # We get the pbconf file for that project
|
---|
44 | # and use its content
|
---|
45 | #
|
---|
46 | my ($pbconf) = pb_conf_read("$ENV{'PBETC'}","pbconf");
|
---|
47 | pb_log(2,"DEBUG pbconf: ".Dumper($pbconf)."\n");
|
---|
48 |
|
---|
49 | my %pbconf = %$pbconf;
|
---|
50 | if (not defined $proj) {
|
---|
51 | # Take the first as the default project
|
---|
52 | $proj = (keys %pbconf)[0];
|
---|
53 | if (defined $proj) {
|
---|
54 | pb_log(2,"WARNING: using $proj as default project as none has been specified\n");
|
---|
55 | pb_log(2,"Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n");
|
---|
56 | }
|
---|
57 | }
|
---|
58 | die "No project defined - use env var PBPROJ or -p proj or a pbconf entry in $ENV{'PBETC'}" if (not (defined $proj));
|
---|
59 |
|
---|
60 | # That's always the environment variable that will be used
|
---|
61 | $ENV{'PBPROJ'} = $proj;
|
---|
62 |
|
---|
63 | if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
|
---|
64 | die "Please create a pbconf reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
|
---|
65 | }
|
---|
66 |
|
---|
67 | #
|
---|
68 | # Detect the root dir for hosting all the content generated with pb
|
---|
69 | #
|
---|
70 | # Tree will look like this:
|
---|
71 | #
|
---|
72 | # maint pbdir PBDIR dev dir (optional) PBDEVDIR
|
---|
73 | # | |
|
---|
74 | # ------------------------ --------------------
|
---|
75 | # | | | |
|
---|
76 | # pbproj1 pbproj2 PBPROJ pbproj1 pbproj2 PBDEVPROJ
|
---|
77 | # | |
|
---|
78 | # --------------------------------------------- ----------
|
---|
79 | # * * | | | | * *
|
---|
80 | # 1.0 dev pbconf ... build delivery PBCONF 1.0 dev PBDEVROOT
|
---|
81 | # | | PBDESTDIR
|
---|
82 | # ------ pbrc PBBUILDDIR
|
---|
83 | # | |
|
---|
84 | # 1.0 dev PBROOT
|
---|
85 | # |
|
---|
86 | # ----------------------------------
|
---|
87 | # | | | |
|
---|
88 | # pkg1 pbproj1.pb pbfilter pbcl
|
---|
89 | # |
|
---|
90 | # -----------------
|
---|
91 | # | | |
|
---|
92 | # rpm deb pbfilter
|
---|
93 | #
|
---|
94 | #
|
---|
95 | # (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdir (when appropriate)
|
---|
96 | # Names under a pbproj and the corresponding pbconf should be similar
|
---|
97 | #
|
---|
98 |
|
---|
99 | my ($pbdir) = pb_conf_get_if("pbdir");
|
---|
100 | my %pbdir = %$pbdir;
|
---|
101 |
|
---|
102 | if (not defined $ENV{'PBDIR'}) {
|
---|
103 | if (not defined ($pbdir{$ENV{'PBPROJ'}})) {
|
---|
104 | pb_log(2,"WARNING: no pbdir defined, using /var/cache\n");
|
---|
105 | pb_log(2,"Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n");
|
---|
106 | }
|
---|
107 | # That's always the environment variable that will be used
|
---|
108 | $ENV{'PBDIR'} = $pbdir{$ENV{'PBPROJ'}};
|
---|
109 | }
|
---|
110 | # Expand potential env variable in it
|
---|
111 | eval { $ENV{'PBDIR'} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
112 |
|
---|
113 | #
|
---|
114 | # Set delivery directory
|
---|
115 | #
|
---|
116 | $ENV{'PBDESTDIR'}="$ENV{'PBDIR'}/$ENV{'PBPROJ'}/delivery";
|
---|
117 |
|
---|
118 | #
|
---|
119 | # Removes all directory existing below the delivery dir
|
---|
120 | # as they are temp dir only
|
---|
121 | # Files stay and have to be cleaned up manually if needed
|
---|
122 | # those files serves as communication channels between pb phases
|
---|
123 | # Removing them prevents a following phase to detect what has been done before
|
---|
124 | #
|
---|
125 | if (-d $ENV{'PBDESTDIR'}) {
|
---|
126 | opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
|
---|
127 | foreach my $d (readdir(DIR)) {
|
---|
128 | next if ($d =~ /^\./);
|
---|
129 | next if (-f "$ENV{'PBDESTDIR'}/$d");
|
---|
130 | pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
|
---|
131 | }
|
---|
132 | closedir(DIR);
|
---|
133 | }
|
---|
134 | if (! -d "$ENV{'PBDESTDIR'}") {
|
---|
135 | pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
|
---|
136 | }
|
---|
137 |
|
---|
138 | #
|
---|
139 | # Set build directory
|
---|
140 | #
|
---|
141 | $ENV{'PBBUILDDIR'}="$ENV{'PBDIR'}/$ENV{'PBPROJ'}/build";
|
---|
142 | if (! -d "$ENV{'PBBUILDDIR'}") {
|
---|
143 | pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
|
---|
144 | }
|
---|
145 |
|
---|
146 | #
|
---|
147 | # Set temp directory
|
---|
148 | #
|
---|
149 | if (not defined $ENV{'TMPDIR'}) {
|
---|
150 | $ENV{'TMPDIR'}="/tmp";
|
---|
151 | }
|
---|
152 | $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 );
|
---|
153 |
|
---|
154 | #
|
---|
155 | # Check pbconf compliance
|
---|
156 | #
|
---|
157 | $ENV{'PBCONF'} = "$ENV{'PBDIR'}/$ENV{'PBPROJ'}/pbconf";
|
---|
158 |
|
---|
159 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}});
|
---|
160 |
|
---|
161 | if ((not -d "$ENV{'PBCONF'}") || (defined $pbinit)) {
|
---|
162 | pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
|
---|
163 | } else {
|
---|
164 | my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBCONF'},"URL:");
|
---|
165 | if ($cmsurl !~ /^$scheme/) {
|
---|
166 | pb_rm_rf("$ENV{'PBCONF'}");
|
---|
167 | pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
|
---|
168 | } elsif ($cmsurl ne $pbconf{$ENV{'PBPROJ'}}) {
|
---|
169 | # The local content doesn't correpond to the repository
|
---|
170 | pb_log(2,"ERROR: Inconsistency detected:\n");
|
---|
171 | pb_log(2,"* $ENV{'PBCONF'} refers to $cmsurl but\n");
|
---|
172 | pb_log(2,"* $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n");
|
---|
173 | die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
|
---|
174 | } else {
|
---|
175 | # they match - do nothing - there may be local changes
|
---|
176 | }
|
---|
177 | }
|
---|
178 |
|
---|
179 | # Check where is our PBROOT (release tag name can't be guessed the first time)
|
---|
180 | if (not defined $ENV{'PBROOT'}) {
|
---|
181 | if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
|
---|
182 | opendir(DIR,$ENV{'PBCONF'}) || die "Unable to open directory $ENV{'PBCONF'}: $!";
|
---|
183 | my $maxmtime = 0;
|
---|
184 | foreach my $d (readdir(DIR)) {
|
---|
185 | next if ($d =~ /^\./);
|
---|
186 | next if (! -d $d);
|
---|
187 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
|
---|
188 | = stat($d);
|
---|
189 | # Keep the most recent
|
---|
190 | if ($mtime > $maxmtime) {
|
---|
191 | $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$d";
|
---|
192 | $maxmtime = $mtime;
|
---|
193 | }
|
---|
194 | }
|
---|
195 | closedir(DIR);
|
---|
196 | pb_log(2,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n");
|
---|
197 | pb_log(2,"Please -r release if you want to use another release\n");
|
---|
198 | } else {
|
---|
199 | my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
|
---|
200 | # That's always the environment variable that will be used
|
---|
201 | $ENV{'PBROOT'} = $pbroot->{$ENV{'PBPROJ'}};
|
---|
202 | }
|
---|
203 | } else {
|
---|
204 | # transform in full path if relative
|
---|
205 | $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ /\//);
|
---|
206 | }
|
---|
207 |
|
---|
208 | my %version = ();
|
---|
209 | my %defpkgdir = ();
|
---|
210 | my %extpkgdir = ();
|
---|
211 | my %filteredfiles = ();
|
---|
212 | my %supfiles = ();
|
---|
213 |
|
---|
214 | if ((-f "$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
|
---|
215 | # List of pkg to build by default (mandatory)
|
---|
216 | my ($defpkgdir) = pb_conf_get("defpkgdir");
|
---|
217 | # List of additional pkg to build when all is called (optional)
|
---|
218 | # Valid version names (optional)
|
---|
219 | # List of files to filter (optional)
|
---|
220 | # Project version and tag (optional)
|
---|
221 | my ($extpkgdir, $version, $filteredfiles, $supfiles, $pkgv, $pkgt) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles","projver","projtag");
|
---|
222 | pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
|
---|
223 | pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
|
---|
224 | pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
|
---|
225 | pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
|
---|
226 | pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
|
---|
227 | # Global
|
---|
228 | %defpkgdir = %$defpkgdir;
|
---|
229 | %extpkgdir = %$extpkgdir if (defined $extpkgdir);
|
---|
230 | %version = %$version if (defined $version);
|
---|
231 | %filteredfiles = %$filteredfiles if (defined $filteredfiles);
|
---|
232 | %supfiles = %$supfiles if (defined $supfiles);
|
---|
233 | #
|
---|
234 | # Get global Version/Tag
|
---|
235 | #
|
---|
236 | if (not defined $ENV{'PBVER'}) {
|
---|
237 | if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
|
---|
238 | $ENV{'PBVER'}=$pkgv->{$ENV{'PBPROJ'}};
|
---|
239 | } else {
|
---|
240 | die "No projver found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
241 | }
|
---|
242 | }
|
---|
243 | die "Invalid version name $ENV{'PBVER'} in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBVER'} =~ /$version{$ENV{'PBPROJ'}}/));
|
---|
244 |
|
---|
245 | if (not defined $ENV{'PBTAG'}) {
|
---|
246 | if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
|
---|
247 | $ENV{'PBTAG'}=$pkgt->{$ENV{'PBPROJ'}};
|
---|
248 | } else {
|
---|
249 | die "No projtag found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
250 | }
|
---|
251 | }
|
---|
252 | die "Invalid tag name $ENV{'PBTAG'} in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBTAG'} !~ /[0-9.]+/);
|
---|
253 | } else {
|
---|
254 | if (defined $pbinit) {
|
---|
255 | open(CONF,"> $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
256 | print CONF << "EOF";
|
---|
257 | #
|
---|
258 | # Project Builder configuration file
|
---|
259 | # For project $ENV{'PBPROJ'}
|
---|
260 | #
|
---|
261 | # \$Id\$
|
---|
262 | #
|
---|
263 |
|
---|
264 | #
|
---|
265 | # Which CMS system is used (Subversion, CVS or tar file content extracted)
|
---|
266 | #
|
---|
267 | #cms $ENV{'PBPROJ'} = svn
|
---|
268 | #cms $ENV{'PBPROJ'} = cvs
|
---|
269 | #cms $ENV{'PBPROJ'} = flat
|
---|
270 |
|
---|
271 | #
|
---|
272 | # Packager label
|
---|
273 | #
|
---|
274 | #packager $ENV{'PBPROJ'} = "William Porte <bill\@$ENV{'PBPROJ'}.org>"
|
---|
275 | #
|
---|
276 |
|
---|
277 | # For delivery to a machine by SSH (potentially the FTP server)
|
---|
278 | # Needs hostname, account and directory
|
---|
279 | #
|
---|
280 | #sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
|
---|
281 | #sshlogin $ENV{'PBPROJ'} = bill
|
---|
282 | #sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
|
---|
283 | #sshport $ENV{'PBPROJ'} = 22
|
---|
284 |
|
---|
285 | #
|
---|
286 | # For Virtual machines management
|
---|
287 | # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
|
---|
288 | # followed by '_' and by release number
|
---|
289 | # a .vmtype extension will be added to the resulting string
|
---|
290 | # a QEMU rhel_3 here means that the VM will be named rhel_3.qemu
|
---|
291 | #
|
---|
292 | #vmlist $ENV{'PBPROJ'} = mandrake_10.1,mandrake_10.2,mandriva_2006.0,mandriva_2007.0,mandriva_2007.1,mandriva_2008.0,redhat_7.3,redhat_9,fedora_4,fedora_5,fedora_6,fedora_7,rhel_3,rhel_4,rhel_5,suse_10.0,suse_10.1,suse_10.2,suse_10.3,sles_9,sles_10,gentoo_nover,debian_3.1,debian_4.0,ubuntu_6.06,ubuntu_7.04,ubuntu_7.10
|
---|
293 |
|
---|
294 | #
|
---|
295 | # Valid values for vmtype are
|
---|
296 | # qemu, (vmware, xen, ... TBD)
|
---|
297 | #vmtype $ENV{'PBPROJ'} = qemu
|
---|
298 |
|
---|
299 | # Hash for VM stuff on vmtype
|
---|
300 | #vmntp default = pool.ntp.org
|
---|
301 |
|
---|
302 | # We suppose we can commmunicate with the VM through SSH
|
---|
303 | #vmhost $ENV{'PBPROJ'} = localhost
|
---|
304 | #vmlogin $ENV{'PBPROJ'} = pb
|
---|
305 | #vmport $ENV{'PBPROJ'} = 2222
|
---|
306 |
|
---|
307 | # Timeout to wait when VM is launched/stopped
|
---|
308 | #vmtmout default = 120
|
---|
309 |
|
---|
310 | # per VMs needed paramaters
|
---|
311 | #vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
|
---|
312 | #vmpath $ENV{'PBPROJ'} = /home/qemu
|
---|
313 | #vmsize $ENV{'PBPROJ'} = 5G
|
---|
314 |
|
---|
315 | #
|
---|
316 | # Global version/tag for the project
|
---|
317 | #
|
---|
318 | #projver $ENV{'PBPROJ'} = devel
|
---|
319 | #projtag $ENV{'PBPROJ'} = 1
|
---|
320 |
|
---|
321 | # Adapt to your needs:
|
---|
322 | # Optional if you need to overwrite the global values above
|
---|
323 | #
|
---|
324 | #pkgver pkg1 = stable
|
---|
325 | #pkgtag pkg1 = 3
|
---|
326 | #pkgver nil
|
---|
327 | #pkgtag nil
|
---|
328 |
|
---|
329 | # Hash of default package/package directory
|
---|
330 | #defpkgdir pkg1 = pkg1dir
|
---|
331 |
|
---|
332 | # Hash of additional package/package directory
|
---|
333 | #extpkgdir pkg1-doc = pkg1-docdir
|
---|
334 |
|
---|
335 | # Hash of valid version names
|
---|
336 | #version devel
|
---|
337 | #version stable
|
---|
338 |
|
---|
339 | # List of files per pkg on which to apply filters
|
---|
340 | # Files are mentioned relatively to pbroot/defpkgdir
|
---|
341 | #filteredfiles pkg1 = Makefile.PL
|
---|
342 | #filteredfiles pkg1-doc = configure.in
|
---|
343 | #supfiles pkg1 = pkg1.init
|
---|
344 | EOF
|
---|
345 | close(CONF);
|
---|
346 | pb_mkdir_p("$ENV{'PBROOT'}/pbfilter") || die "Unable to create $ENV{'PBROOT'}/pbfilter";
|
---|
347 | open(CONF,"> $ENV{'PBROOT'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOT'}/pbfilter/all.pbf";
|
---|
348 | print CONF << "EOF";
|
---|
349 | #
|
---|
350 | # \$Id\$
|
---|
351 | #
|
---|
352 | # Filter for all files
|
---|
353 | #
|
---|
354 | # PBSRC is replaced by the source package format
|
---|
355 | #filter PBSRC = ftp://ftp.$ENV{'PBPROJ'}.org/src/%{name}-%{version}.tar.gz
|
---|
356 |
|
---|
357 | # PBVER is replaced by the version (\$pbver in code)
|
---|
358 | #filter PBVER = \$pbver
|
---|
359 |
|
---|
360 | # PBDATE is replaced by the date (\$pbdate in code)
|
---|
361 | #filter PBDATE = \$pbdate
|
---|
362 |
|
---|
363 | # PBLOG is replaced by the changelog if value is yes
|
---|
364 | #filter PBLOG = yes
|
---|
365 |
|
---|
366 | # PBTAG is replaced by the tag (\$pbtag in code)
|
---|
367 | #filter PBTAG = \$pbtag
|
---|
368 |
|
---|
369 | # PBREV is replaced by the revision (\$pbrev in code)
|
---|
370 | #filter PBREV = \$pbrev
|
---|
371 |
|
---|
372 | # PBPKG is replaced by the package name (\$pbpkg in code)
|
---|
373 | #filter PBPKG = \$pbpkg
|
---|
374 |
|
---|
375 | # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
|
---|
376 | #filter PBPACKAGER = \$pbpackager
|
---|
377 |
|
---|
378 | # PBDESC contains the description of the package
|
---|
379 | #filter PBDESC = "Bla-Bla"
|
---|
380 |
|
---|
381 | # PBURL contains the URL of the Web site of the project
|
---|
382 | #filter PBURL = http://www.$ENV{'PBPROJ'}.org
|
---|
383 | EOF
|
---|
384 | close(CONF);
|
---|
385 | open(CONF,"> $ENV{'PBROOT'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOT'}/pbfilter/rpm.pbf";
|
---|
386 | print CONF << "EOF";
|
---|
387 | #
|
---|
388 | # \$Id\$
|
---|
389 | #
|
---|
390 | # Filter for rpm build
|
---|
391 | #
|
---|
392 |
|
---|
393 | # PBGRP is replaced by the RPM group of apps
|
---|
394 | # Cf: http://fedoraproject.org/wiki/RPMGroups
|
---|
395 | #filter PBGRP = Applications/Archiving
|
---|
396 |
|
---|
397 | # PBDEP is replaced by the list of dependencies
|
---|
398 | #filter PBDEP =
|
---|
399 |
|
---|
400 | # PBSUF is replaced by the package name (\$pbpkg in code)
|
---|
401 | #filter PBSUF = \$pbsuf
|
---|
402 |
|
---|
403 | # PBOBS is replaced by the Obsolete line
|
---|
404 | #filter PBOBS =
|
---|
405 |
|
---|
406 | EOF
|
---|
407 | close(CONF);
|
---|
408 | open(CONF,"> $ENV{'PBROOT'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOT'}/pbfilter/deb.pbf";
|
---|
409 | print CONF << "EOF";
|
---|
410 | #
|
---|
411 | # \$Id\$
|
---|
412 | #
|
---|
413 | # Filter for debian build
|
---|
414 | #
|
---|
415 | # PBGRP is replaced by the group of apps
|
---|
416 | #filter PBGRP = utils
|
---|
417 |
|
---|
418 | # PBVER is replaced by the version (\$pbver in code)
|
---|
419 | #filter PBVER = \$pbver
|
---|
420 |
|
---|
421 | # PBDEP is replaced by the list of dependencies
|
---|
422 | #filter PBDEP =
|
---|
423 |
|
---|
424 | # PBSUG is replaced by the list of suggestions
|
---|
425 | #filter PBSUG =
|
---|
426 |
|
---|
427 | # PBREC is replaced by the list of recommandations
|
---|
428 | #filter PBREC =
|
---|
429 |
|
---|
430 | # PBLOG is replaced by the changelog if value is yes
|
---|
431 | #filter PBLOG = yes
|
---|
432 |
|
---|
433 | # PBPKG is replaced by the package name (\$pbpkg in code)
|
---|
434 | #filter PBPKG = \$pbpkg
|
---|
435 |
|
---|
436 | # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
|
---|
437 | #filter PBPACKAGER = \$pbpackager
|
---|
438 |
|
---|
439 | EOF
|
---|
440 | close(CONF);
|
---|
441 | open(CONF,"> $ENV{'PBROOT'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOT'}/pbfilter/md.pbf";
|
---|
442 | print CONF << "EOF";
|
---|
443 | # Specific group for Mandriva for $ENV{'PBPROJ'}
|
---|
444 | filter PBGRP = Archiving/Backup
|
---|
445 | EOF
|
---|
446 | close(CONF);
|
---|
447 | open(CONF,"> $ENV{'PBROOT'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOT'}/pbfilter/novell.pbf";
|
---|
448 | print CONF << "EOF";
|
---|
449 | # Specific group for SuSE for $ENV{'PBPROJ'}
|
---|
450 | filter PBGRP = Productivity/Archiving/Backup
|
---|
451 | EOF
|
---|
452 | close(CONF);
|
---|
453 | pb_mkdir_p("$ENV{'PBROOT'}/pkg1/deb") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb";
|
---|
454 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/control") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/control";
|
---|
455 | print CONF << "EOF";
|
---|
456 | Source: PBPKG
|
---|
457 | Section: PBGRP
|
---|
458 | Priority: optional
|
---|
459 | Maintainer: PBPACKAGER
|
---|
460 | Build-Depends: debhelper (>= 4.2.20), PBDEP
|
---|
461 | Standards-Version: 3.6.1
|
---|
462 |
|
---|
463 | Package: PBPKG
|
---|
464 | Architecture: amd64 i386 ia64
|
---|
465 | Section: PBGRP
|
---|
466 | Priority: optional
|
---|
467 | Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
|
---|
468 | Recommends: PBREC
|
---|
469 | Suggests: PBSUG
|
---|
470 | Description:
|
---|
471 | PBDESC
|
---|
472 | .
|
---|
473 | Homepage: PBURL
|
---|
474 |
|
---|
475 | EOF
|
---|
476 | close(CONF);
|
---|
477 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/copyright") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/copyright";
|
---|
478 | print CONF << "EOF";
|
---|
479 | This package is debianized by PBPACKAGER
|
---|
480 | `date`
|
---|
481 |
|
---|
482 | The current upstream source was downloaded from
|
---|
483 | ftp://ftp.$ENV{'PBPROJ'}.org/src/.
|
---|
484 |
|
---|
485 | Upstream Authors: Put their name here
|
---|
486 |
|
---|
487 | Copyright:
|
---|
488 |
|
---|
489 | This package is free software; you can redistribute it and/or modify
|
---|
490 | it under the terms of the GNU General Public License as published by
|
---|
491 | the Free Software Foundation; version 2 dated June, 1991.
|
---|
492 |
|
---|
493 | This package is distributed in the hope that it will be useful,
|
---|
494 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
495 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
496 | GNU General Public License for more details.
|
---|
497 |
|
---|
498 | You should have received a copy of the GNU General Public License
|
---|
499 | along with this package; if not, write to the Free Software
|
---|
500 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
---|
501 | MA 02110-1301, USA.
|
---|
502 |
|
---|
503 | On Debian systems, the complete text of the GNU General
|
---|
504 | Public License can be found in /usr/share/common-licenses/GPL.
|
---|
505 |
|
---|
506 | EOF
|
---|
507 | close(CONF);
|
---|
508 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/changelog") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/changelog";
|
---|
509 | print CONF << "EOF";
|
---|
510 | PBLOG
|
---|
511 | EOF
|
---|
512 | close(CONF);
|
---|
513 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/compat") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/compat";
|
---|
514 | print CONF << "EOF";
|
---|
515 | 4
|
---|
516 | EOF
|
---|
517 | close(CONF);
|
---|
518 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/pkg1.dirs") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/pkg1.dirs";
|
---|
519 | print CONF << "EOF";
|
---|
520 | EOF
|
---|
521 | close(CONF);
|
---|
522 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/pkg1.docs") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/pkg1.docs";
|
---|
523 | print CONF << "EOF";
|
---|
524 | INSTALL
|
---|
525 | COPYING
|
---|
526 | AUTHORS
|
---|
527 | NEWS
|
---|
528 | README
|
---|
529 | EOF
|
---|
530 | close(CONF);
|
---|
531 | open(CONF,"> $ENV{'PBROOT'}/pkg1/deb/rules") || die "Unable to create $ENV{'PBROOT'}/pkg1/deb/rules";
|
---|
532 | print CONF << 'EOF';
|
---|
533 | #!/usr/bin/make -f
|
---|
534 | # -*- makefile -*-
|
---|
535 | # Sample debian/rules that uses debhelper.
|
---|
536 | # GNU copyright 1997 to 1999 by Joey Hess.
|
---|
537 | #
|
---|
538 | # $Id$
|
---|
539 | #
|
---|
540 |
|
---|
541 | # Uncomment this to turn on verbose mode.
|
---|
542 | #export DH_VERBOSE=1
|
---|
543 |
|
---|
544 | # Define package name variable for a one-stop change.
|
---|
545 | PACKAGE_NAME = PBPKG
|
---|
546 |
|
---|
547 | # These are used for cross-compiling and for saving the configure script
|
---|
548 | # from having to guess our platform (since we know it already)
|
---|
549 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
---|
550 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
---|
551 |
|
---|
552 | CFLAGS = -Wall -g
|
---|
553 |
|
---|
554 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
---|
555 | CFLAGS += -O0
|
---|
556 | else
|
---|
557 | CFLAGS += -O2
|
---|
558 | endif
|
---|
559 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
|
---|
560 | INSTALL_PROGRAM += -s
|
---|
561 | endif
|
---|
562 | config.status: configure
|
---|
563 | dh_testdir
|
---|
564 |
|
---|
565 | # Configure the package.
|
---|
566 | CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
|
---|
567 | --mandir=\$${prefix}/share/man
|
---|
568 |
|
---|
569 | # Build both architecture dependent and independent
|
---|
570 | build: build-arch build-indep
|
---|
571 |
|
---|
572 | # Build architecture dependent
|
---|
573 | build-arch: build-arch-stamp
|
---|
574 |
|
---|
575 | build-arch-stamp: config.status
|
---|
576 | dh_testdir
|
---|
577 |
|
---|
578 | # Compile the package.
|
---|
579 | $(MAKE)
|
---|
580 |
|
---|
581 | touch build-stamp
|
---|
582 |
|
---|
583 | # Build architecture independent
|
---|
584 | build-indep: build-indep-stamp
|
---|
585 |
|
---|
586 | build-indep-stamp: config.status
|
---|
587 | # Nothing to do, the only indep item is the manual which is available as html in original source
|
---|
588 | touch build-indep-stamp
|
---|
589 |
|
---|
590 | # Clean up
|
---|
591 | clean:
|
---|
592 | dh_testdir
|
---|
593 | dh_testroot
|
---|
594 | rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
|
---|
595 | # Clean temporary document directory
|
---|
596 | rm -rf debian/doc-temp
|
---|
597 | # Clean up.
|
---|
598 | -$(MAKE) distclean
|
---|
599 | rm -f config.log
|
---|
600 | ifneq "$(wildcard /usr/share/misc/config.sub)" ""
|
---|
601 | cp -f /usr/share/misc/config.sub config.sub
|
---|
602 | endif
|
---|
603 | ifneq "$(wildcard /usr/share/misc/config.guess)" ""
|
---|
604 | cp -f /usr/share/misc/config.guess config.guess
|
---|
605 | endif
|
---|
606 |
|
---|
607 | dh_clean
|
---|
608 |
|
---|
609 | # Install architecture dependent and independent
|
---|
610 | install: install-arch install-indep
|
---|
611 |
|
---|
612 | # Install architecture dependent
|
---|
613 | install-arch: build-arch
|
---|
614 | dh_testdir
|
---|
615 | dh_testroot
|
---|
616 | dh_clean -k -s
|
---|
617 | dh_installdirs -s
|
---|
618 |
|
---|
619 | # Install the package files into build directory:
|
---|
620 | # - start with upstream make install
|
---|
621 | $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
|
---|
622 | r/share/man
|
---|
623 | # - copy html manual to temporary location for renaming
|
---|
624 | mkdir -p debian/doc-temp
|
---|
625 | dh_install -s
|
---|
626 |
|
---|
627 | # Install architecture independent
|
---|
628 | install-indep: build-indep
|
---|
629 | dh_testdir
|
---|
630 | dh_testroot
|
---|
631 | dh_clean -k -i
|
---|
632 | dh_installdirs -i
|
---|
633 | dh_install -i
|
---|
634 |
|
---|
635 | # Must not depend on anything. This is to be called by
|
---|
636 | # binary-arch/binary-indep
|
---|
637 | # in another 'make' thread.
|
---|
638 | binary-common:
|
---|
639 | dh_testdir
|
---|
640 | dh_testroot
|
---|
641 | dh_installchangelogs ChangeLog
|
---|
642 | dh_installdocs
|
---|
643 | dh_installman
|
---|
644 | dh_link
|
---|
645 | dh_strip
|
---|
646 | dh_compress
|
---|
647 | dh_fixperms
|
---|
648 | dh_installdeb
|
---|
649 | dh_shlibdeps
|
---|
650 | dh_gencontrol
|
---|
651 | dh_md5sums
|
---|
652 | dh_builddeb
|
---|
653 |
|
---|
654 | # Build architecture independant packages using the common target.
|
---|
655 | binary-indep: build-indep install-indep
|
---|
656 | $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
|
---|
657 |
|
---|
658 | # Build architecture dependant packages using the common target.
|
---|
659 | binary-arch: build-arch install-arch
|
---|
660 | $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
|
---|
661 |
|
---|
662 | # Build architecture depdendent and independent packages
|
---|
663 | binary: binary-arch binary-indep
|
---|
664 | .PHONY: clean binary
|
---|
665 |
|
---|
666 | EOF
|
---|
667 | close(CONF);
|
---|
668 | pb_mkdir_p("$ENV{'PBROOT'}/pkg1/rpm") || die "Unable to create $ENV{'PBROOT'}/pkg1/rpm";
|
---|
669 | open(CONF,"> $ENV{'PBROOT'}/pkg1/rpm/pkg1.spec") || die "Unable to create $ENV{'PBROOT'}/pkg1/rpm/pkg1.spec";
|
---|
670 | print CONF << 'EOF';
|
---|
671 | #
|
---|
672 | # $Id$
|
---|
673 | #
|
---|
674 |
|
---|
675 | Summary: bla-bla
|
---|
676 | Summary(fr): french bla-bla
|
---|
677 |
|
---|
678 | Name: PBPKG
|
---|
679 | Version: PBVER
|
---|
680 | Release: PBTAGPBSUF
|
---|
681 | License: GPL
|
---|
682 | Group: PBGRP
|
---|
683 | Url: PBURL
|
---|
684 | Source: PBSRC
|
---|
685 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
|
---|
686 | Requires: PBDEP
|
---|
687 |
|
---|
688 | %description
|
---|
689 | PBDESC
|
---|
690 |
|
---|
691 | %description -l fr
|
---|
692 | french desc
|
---|
693 |
|
---|
694 | %prep
|
---|
695 | %setup -q
|
---|
696 |
|
---|
697 | %build
|
---|
698 | %configure
|
---|
699 | make %{?_smp_mflags}
|
---|
700 |
|
---|
701 | %install
|
---|
702 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
703 | make DESTDIR=$RPM_BUILD_ROOT install
|
---|
704 |
|
---|
705 | %clean
|
---|
706 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
707 |
|
---|
708 | %files
|
---|
709 | %defattr(-,root,root)
|
---|
710 | %doc ChangeLog
|
---|
711 | %doc INSTALL COPYING README AUTHORS NEWS
|
---|
712 |
|
---|
713 | %changelog
|
---|
714 | PBLOG
|
---|
715 |
|
---|
716 | EOF
|
---|
717 | close(CONF);
|
---|
718 | pb_mkdir_p("$ENV{'PBROOT'}/pkg1/pbfilter") || die "Unable to create $ENV{'PBROOT'}/pkg1/pbfilter";
|
---|
719 |
|
---|
720 | pb_log(2,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
|
---|
721 | pb_log(2,"After having renamed the pkg1 directory to your package's name \n\n");
|
---|
722 | } else {
|
---|
723 | die "Unable to open $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
724 | }
|
---|
725 | }
|
---|
726 | umask 0022;
|
---|
727 | return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
|
---|
728 | }
|
---|
729 |
|
---|
730 | # Internal mkdir -p function
|
---|
731 | sub pb_mkdir_p {
|
---|
732 | my @dir = @_;
|
---|
733 | my $ret = mkpath(@dir, 0, 0755);
|
---|
734 | return($ret);
|
---|
735 | }
|
---|
736 |
|
---|
737 | # Internal rm -rf function
|
---|
738 | sub pb_rm_rf {
|
---|
739 | my @dir = @_;
|
---|
740 | my $ret = rmtree(@dir, 0, 0);
|
---|
741 | return($ret);
|
---|
742 | }
|
---|
743 |
|
---|
744 | # Internal system function
|
---|
745 | sub pb_system {
|
---|
746 |
|
---|
747 | my $cmd=shift;
|
---|
748 | my $cmt=shift || $cmd;
|
---|
749 |
|
---|
750 | pb_log(2,"$cmt... ");
|
---|
751 | #system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
|
---|
752 | system($cmd);
|
---|
753 | if ($? == -1) {
|
---|
754 | pb_log(2,"failed to execute ($cmd) : $!\n");
|
---|
755 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
756 | } elsif ($? & 127) {
|
---|
757 | pb_log(2, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n");
|
---|
758 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
759 | } elsif ($? == 0) {
|
---|
760 | pb_log(2,"OK\n");
|
---|
761 | } else {
|
---|
762 | pb_log(2, "child ($cmd) exited with value ".($? >> 8)."\n");
|
---|
763 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
764 | }
|
---|
765 | }
|
---|
766 |
|
---|
767 | sub pb_display_file {
|
---|
768 |
|
---|
769 | my $file=shift;
|
---|
770 |
|
---|
771 | return if (not -f $file);
|
---|
772 | open(FILE,"$file");
|
---|
773 | while (<FILE>) {
|
---|
774 | print $_;
|
---|
775 | }
|
---|
776 | close(FILE);
|
---|
777 | }
|
---|
778 |
|
---|
779 | # Function which returns a pointer on a table
|
---|
780 | # corresponding to a set of values queried in the conf file
|
---|
781 | # and test the returned vaue as they need to exist in that case
|
---|
782 | sub pb_conf_get {
|
---|
783 |
|
---|
784 | my @param = @_;
|
---|
785 | my @return = pb_conf_get_if(@param);
|
---|
786 |
|
---|
787 | die "No params found for $ENV{'PBPROJ'}" if (not @return);
|
---|
788 |
|
---|
789 | foreach my $i (0..$#param) {
|
---|
790 | die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $return[$i]);
|
---|
791 | }
|
---|
792 | return(@return);
|
---|
793 | }
|
---|
794 |
|
---|
795 | # Function which returns a pointer on a table
|
---|
796 | # corresponding to a set of values queried in the conf file
|
---|
797 | # Those value may be undef if they do not exist
|
---|
798 | sub pb_conf_get_if {
|
---|
799 |
|
---|
800 | my @param = @_;
|
---|
801 |
|
---|
802 | # Everything is returned via ptr1
|
---|
803 | my @ptr1 = pb_conf_read_if("$ENV{'PBETC'}", @param);
|
---|
804 | my @ptr2 = pb_conf_read_if("$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb", @param);
|
---|
805 |
|
---|
806 | my $p1;
|
---|
807 | my $p2;
|
---|
808 |
|
---|
809 | pb_log(2,"DEBUG: param1: ".Dumper(@ptr1)."\n");
|
---|
810 | pb_log(2,"DEBUG: param2: ".Dumper(@ptr2)."\n");
|
---|
811 |
|
---|
812 | foreach my $i (0..$#param) {
|
---|
813 | $p1 = $ptr1[$i];
|
---|
814 | $p2 = $ptr2[$i];
|
---|
815 | # Always try to take the param from the home dir conf file in priority
|
---|
816 | # in order to mask what could be defined under the CMS to allow for overloading
|
---|
817 | if (not defined $p2) {
|
---|
818 | # No ref in CMS project conf file so use the home dir one.
|
---|
819 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (not defined $p1->{$ENV{'PBPROJ'}});
|
---|
820 | } else {
|
---|
821 | # Ref found in CMS project conf file
|
---|
822 | if (not defined $p1) {
|
---|
823 | # No ref in home dir project conf file so use the CMS one.
|
---|
824 | $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if (not defined $p2->{$ENV{'PBPROJ'}});
|
---|
825 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
|
---|
826 | } else {
|
---|
827 | # Both are defined - handling the overloading
|
---|
828 | if (not defined $p1->{'default'}) {
|
---|
829 | if (defined $p2->{'default'}) {
|
---|
830 | $p1->{'default'} = $p2->{'default'};
|
---|
831 | }
|
---|
832 | }
|
---|
833 |
|
---|
834 | if (not defined $p1->{$ENV{'PBPROJ'}}) {
|
---|
835 | if (defined $p2->{$ENV{'PBPROJ'}}) {
|
---|
836 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
|
---|
837 | } else {
|
---|
838 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'};
|
---|
839 | }
|
---|
840 | }
|
---|
841 | }
|
---|
842 | }
|
---|
843 | $ptr1[$i] = $p1;
|
---|
844 | pb_log(2,"DEBUG: param ptr1: ".Dumper(@ptr1)."\n");
|
---|
845 | }
|
---|
846 | return(@ptr1);
|
---|
847 | }
|
---|
848 |
|
---|
849 | # Function which returns a pointer on a hash
|
---|
850 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
851 | # if that conf file doesn't exist returns undef
|
---|
852 | sub pb_conf_read_if {
|
---|
853 |
|
---|
854 | my $conffile = shift;
|
---|
855 | my @param = @_;
|
---|
856 |
|
---|
857 | open(CONF,$conffile) || return((undef));
|
---|
858 | close(CONF);
|
---|
859 | return(pb_conf_read($conffile,@param));
|
---|
860 | }
|
---|
861 |
|
---|
862 | # Function which returns a pointer on a hash
|
---|
863 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
864 | sub pb_conf_read {
|
---|
865 |
|
---|
866 | my $conffile = shift;
|
---|
867 | my @param = @_;
|
---|
868 | my $trace;
|
---|
869 | my @ptr;
|
---|
870 | my %h;
|
---|
871 |
|
---|
872 | open(CONF,$conffile) || die "Unable to open $conffile";
|
---|
873 | while(<CONF>) {
|
---|
874 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
875 | pb_log(2,"DEBUG: 1:$1 2:$2 3:$3\n");
|
---|
876 | $h{$1}{$2}=$3;
|
---|
877 | }
|
---|
878 | }
|
---|
879 | close(CONF);
|
---|
880 |
|
---|
881 | for my $param (@param) {
|
---|
882 | push @ptr,$h{$param};
|
---|
883 | }
|
---|
884 | pb_log(2,"DEBUG: h:".Dumper(%h)." param:".Dumper(@param)." ptr:".Dumper(@ptr)."\n");
|
---|
885 | return(@ptr);
|
---|
886 | }
|
---|
887 |
|
---|
888 | # Analyze a url passed and return protocol, account, password, server, port, path
|
---|
889 | sub pb_get_uri {
|
---|
890 |
|
---|
891 | my $uri = shift || undef;
|
---|
892 |
|
---|
893 | # A URL has the format protocol://[ac@]host[:port][path[?query][#fragment]].
|
---|
894 | # Cf man URI
|
---|
895 | my ($scheme, $authority, $path, $query, $fragment) =
|
---|
896 | $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
|
---|
897 | my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?|;
|
---|
898 | pb_log(2,"DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n");
|
---|
899 | return($scheme, $account, $host, $port, $path);
|
---|
900 | }
|
---|
901 |
|
---|
902 |
|
---|
903 | # Setup environment for CMS system for URL passed
|
---|
904 | sub pb_cms_init {
|
---|
905 |
|
---|
906 | my $proj = shift || undef;
|
---|
907 |
|
---|
908 | # Use the project URI
|
---|
909 | my ($uri) = pb_conf_get("pburl");
|
---|
910 |
|
---|
911 | # Extract values from that URI
|
---|
912 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri->{$ENV{'PBPROJ'}});
|
---|
913 |
|
---|
914 | if ($scheme =~ /^svn/) {
|
---|
915 | $ENV{'PBREVISION'}= pb_cms_getinfo($scheme,$uri->{$ENV{'PBPROJ'}},"Revision:");
|
---|
916 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBDEVDIR'}" ; svnversion .)`;
|
---|
917 | $ENV{'PBCMSLOGFILE'}="svn.log";
|
---|
918 | } elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
919 | $ENV{'PBREVISION'}="flat";
|
---|
920 | $ENV{'PBCMSLOGFILE'}="flat.log";
|
---|
921 | } elsif ($scheme eq "cvs") {
|
---|
922 | # Way too slow
|
---|
923 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
|
---|
924 | #chomp($ENV{'PBREVISION'});
|
---|
925 | $ENV{'PBREVISION'}="CVS";
|
---|
926 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
927 | #
|
---|
928 | # Export content if needed
|
---|
929 | #
|
---|
930 | my ($cvsrsh) = pb_conf_get_if("cvsrsh");
|
---|
931 | $ENV{'CVS_RSH'} = $cvsrsh->{$proj} if (defined $cvsrsh->{$proj});
|
---|
932 | } else {
|
---|
933 | die "cms $scheme unknown";
|
---|
934 | }
|
---|
935 |
|
---|
936 | #
|
---|
937 | #if (not defined $scheme) {
|
---|
938 | # We're an upstream guy
|
---|
939 | # Try to make it easy for us
|
---|
940 | #pb_log(2,"WARNING: Assuming a local project under $ENV{'PBDIR'}/$ENV{'PBPROJ'}:\n");
|
---|
941 | #pb_log(2,"If not, pleaase setup a pbproj entry in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb\n");
|
---|
942 | #return("");
|
---|
943 | #}
|
---|
944 |
|
---|
945 | return($scheme,$uri->{$ENV{'PBPROJ'}});
|
---|
946 | }
|
---|
947 |
|
---|
948 | sub pb_get_date {
|
---|
949 |
|
---|
950 | return(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
951 | }
|
---|
952 |
|
---|
953 | sub pb_cms_export {
|
---|
954 |
|
---|
955 | my $scheme = shift;
|
---|
956 | my $source = shift;
|
---|
957 | my $destdir = shift;
|
---|
958 | my $tmp;
|
---|
959 | my $tmp1;
|
---|
960 |
|
---|
961 | my @date = pb_get_date();
|
---|
962 |
|
---|
963 | if ($scheme eq "svn") {
|
---|
964 | if (-d $source) {
|
---|
965 | $tmp = $destdir;
|
---|
966 | } else {
|
---|
967 | $tmp = $destdir."/".basename($source);
|
---|
968 | }
|
---|
969 | pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
|
---|
970 | } elsif ($scheme eq "flat") {
|
---|
971 | if (-d $source) {
|
---|
972 | $tmp = $destdir;
|
---|
973 | } else {
|
---|
974 | $tmp = $destdir."/".basename($source);
|
---|
975 | }
|
---|
976 | pb_system("cp -a $source $tmp","Exporting $source from DIR to $tmp");
|
---|
977 | } elsif ($scheme eq "cvs") {
|
---|
978 | my $dir=dirname($destdir);
|
---|
979 | my $base=basename($destdir);
|
---|
980 | if (-d $source) {
|
---|
981 | $tmp1 = $source;
|
---|
982 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
983 | } else {
|
---|
984 | $tmp1 = dirname($source);
|
---|
985 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
986 | $tmp1 = $tmp1."/".basename($source);
|
---|
987 | }
|
---|
988 | # CVS needs a relative path !
|
---|
989 | my ($cvsroot) = pb_conf_get("cvsroot");
|
---|
990 | my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
991 | pb_system("cd $dir ; cvs -d $cvsroot->{$ENV{'PBPROJ'}} export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir");
|
---|
992 | } else {
|
---|
993 | die "cms $scheme unknown";
|
---|
994 | }
|
---|
995 | }
|
---|
996 |
|
---|
997 |
|
---|
998 | sub pb_create_authors {
|
---|
999 |
|
---|
1000 | my $authors=shift;
|
---|
1001 | my $dest=shift;
|
---|
1002 | my $scheme=shift;
|
---|
1003 |
|
---|
1004 | return if ($authors eq "/dev/null");
|
---|
1005 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
1006 | open(DAUTH,"> $dest/AUTHORS") || die "Unable to create $dest/AUTHORS";
|
---|
1007 | print DAUTH "Authors of the project are:\n";
|
---|
1008 | print DAUTH "===========================\n";
|
---|
1009 | while (<SAUTH>) {
|
---|
1010 | my ($nick,$gcos) = split(/:/);
|
---|
1011 | chomp($gcos);
|
---|
1012 | print DAUTH "$gcos";
|
---|
1013 | if (defined $scheme) {
|
---|
1014 | print DAUTH " ($nick under $scheme)\n";
|
---|
1015 | } else {
|
---|
1016 | print DAUTH "\n";
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 | close(DAUTH);
|
---|
1020 | close(SAUTH);
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | sub pb_cms_log {
|
---|
1024 | my $scheme = shift;
|
---|
1025 | my $pkgdir = shift;
|
---|
1026 | my $dest = shift;
|
---|
1027 | my $chglog = shift;
|
---|
1028 | my $authors = shift;
|
---|
1029 |
|
---|
1030 | pb_create_authors($authors,$dest,$scheme);
|
---|
1031 |
|
---|
1032 | if ($scheme eq "svn") {
|
---|
1033 | if (! -f "$dest/ChangeLog") {
|
---|
1034 | if (-x "/usr/bin/svn2cl") {
|
---|
1035 | pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
|
---|
1036 | } else {
|
---|
1037 | # To be written from pbcl
|
---|
1038 | pb_system("svn log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
1039 | }
|
---|
1040 | }
|
---|
1041 | } elsif ($scheme eq "flat") {
|
---|
1042 | if (! -f "$dest/ChangeLog") {
|
---|
1043 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
1044 | }
|
---|
1045 | } elsif ($scheme eq "cvs") {
|
---|
1046 | my $tmp=basename($pkgdir);
|
---|
1047 | # CVS needs a relative path !
|
---|
1048 | if (! -f "$dest/ChangeLog") {
|
---|
1049 | if (-x "/usr/bin/cvs2cl") {
|
---|
1050 | pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
|
---|
1051 | } else {
|
---|
1052 | # To be written from pbcl
|
---|
1053 | pb_system("cvs log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
1054 | }
|
---|
1055 | }
|
---|
1056 | } else {
|
---|
1057 | die "cms $scheme unknown";
|
---|
1058 | }
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | sub pb_cms_getinfo {
|
---|
1062 | my $scheme = shift;
|
---|
1063 | my $dir = shift;
|
---|
1064 | my $info = shift || "URL:";
|
---|
1065 |
|
---|
1066 | my $res = "";
|
---|
1067 | my $void = "";
|
---|
1068 |
|
---|
1069 | if ($scheme =~ /^svn/) {
|
---|
1070 | open(PIPE,"LANGUAGE=C svn info $dir |") || return("");
|
---|
1071 | while (<PIPE>) {
|
---|
1072 | ($void,$res) = split(/^$info/) if (/^$info/);
|
---|
1073 | }
|
---|
1074 | close(PIPE);
|
---|
1075 | chomp($res);
|
---|
1076 | } elsif ($scheme eq "flat") {
|
---|
1077 | } elsif ($scheme eq "cvs") {
|
---|
1078 | } else {
|
---|
1079 | die "cms $scheme unknown";
|
---|
1080 | }
|
---|
1081 | return($res);
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | sub pb_cms_copy {
|
---|
1085 | my $scheme = shift;
|
---|
1086 | my $oldurl = shift;
|
---|
1087 | my $newurl = shift;
|
---|
1088 |
|
---|
1089 | if ($scheme eq "svn") {
|
---|
1090 | pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");
|
---|
1091 | } elsif ($scheme eq "flat") {
|
---|
1092 | } elsif ($scheme eq "cvs") {
|
---|
1093 | } else {
|
---|
1094 | die "cms $scheme unknown";
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | sub pb_cms_checkout {
|
---|
1099 | my $scheme = shift;
|
---|
1100 | my $url = shift;
|
---|
1101 | my $destination = shift;
|
---|
1102 |
|
---|
1103 | if ($scheme =~ /^svn/) {
|
---|
1104 | pb_system("svn co $url $destination","Checking $url to $destination ");
|
---|
1105 | } elsif ($scheme eq "flat") {
|
---|
1106 | } elsif ($scheme eq "cvs") {
|
---|
1107 | } else {
|
---|
1108 | die "cms $scheme unknown";
|
---|
1109 | }
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | sub pb_cms_checkin {
|
---|
1113 | my $scheme = shift;
|
---|
1114 | my $dir = shift;
|
---|
1115 |
|
---|
1116 | my $ver = basename($dir);
|
---|
1117 | if ($scheme eq "svn") {
|
---|
1118 | pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir");
|
---|
1119 | pb_system("svn up $dir","Updating $dir");
|
---|
1120 | } elsif ($scheme eq "flat") {
|
---|
1121 | } elsif ($scheme eq "cvs") {
|
---|
1122 | } else {
|
---|
1123 | die "cms $scheme unknown";
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | sub pb_cms_isdiff {
|
---|
1128 | my $scheme = shift;
|
---|
1129 |
|
---|
1130 | if ($scheme eq "svn") {
|
---|
1131 | open(PIPE,"svn diff $ENV{'PBROOT'} |") || die "Unable to get svn diff from $ENV{'PBROOT'}";
|
---|
1132 | my $l = 0;
|
---|
1133 | while (<PIPE>) {
|
---|
1134 | $l++;
|
---|
1135 | }
|
---|
1136 | return($l);
|
---|
1137 | } elsif ($scheme eq "flat") {
|
---|
1138 | } elsif ($scheme eq "cvs") {
|
---|
1139 | } else {
|
---|
1140 | die "cms $scheme unknown";
|
---|
1141 | }
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | # Get all filters to apply
|
---|
1145 | # They're cumulative from less specific to most specific
|
---|
1146 | # suffix is .pbf
|
---|
1147 |
|
---|
1148 | sub pb_get_filters {
|
---|
1149 |
|
---|
1150 | my @ffiles;
|
---|
1151 | my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3);
|
---|
1152 | my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3);
|
---|
1153 | my $pbpkg = shift || die "No package specified";
|
---|
1154 | my $dtype = shift || "";
|
---|
1155 | my $dfam = shift || "";
|
---|
1156 | my $ddir = shift || "";
|
---|
1157 | my $dver = shift || "";
|
---|
1158 | my $ptr; # returned value pointer on the hash of filters
|
---|
1159 | my %ptr;
|
---|
1160 | my %h;
|
---|
1161 |
|
---|
1162 | # Global filter files first, then package specificities
|
---|
1163 | if (-d "$ENV{'PBROOT'}/pbfilter") {
|
---|
1164 | $mfile00 = "$ENV{'PBROOT'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/all.pbf");
|
---|
1165 | $mfile0 = "$ENV{'PBROOT'}/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$dtype.pbf");
|
---|
1166 | $mfile1 = "$ENV{'PBROOT'}/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$dfam.pbf");
|
---|
1167 | $mfile2 = "$ENV{'PBROOT'}/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$ddir.pbf");
|
---|
1168 | $mfile3 = "$ENV{'PBROOT'}/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$ddir-$dver.pbf");
|
---|
1169 |
|
---|
1170 | push @ffiles,$mfile00 if (defined $mfile00);
|
---|
1171 | push @ffiles,$mfile0 if (defined $mfile0);
|
---|
1172 | push @ffiles,$mfile1 if (defined $mfile1);
|
---|
1173 | push @ffiles,$mfile2 if (defined $mfile2);
|
---|
1174 | push @ffiles,$mfile3 if (defined $mfile3);
|
---|
1175 | }
|
---|
1176 |
|
---|
1177 | if (-d "$ENV{'PBROOT'}/$pbpkg/pbfilter") {
|
---|
1178 | $ffile00 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/all.pbf");
|
---|
1179 | $ffile0 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dtype.pbf");
|
---|
1180 | $ffile1 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dfam.pbf");
|
---|
1181 | $ffile2 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir.pbf");
|
---|
1182 | $ffile3 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir-$dver.pbf");
|
---|
1183 |
|
---|
1184 | push @ffiles,$ffile00 if (defined $ffile00);
|
---|
1185 | push @ffiles,$ffile0 if (defined $ffile0);
|
---|
1186 | push @ffiles,$ffile1 if (defined $ffile1);
|
---|
1187 | push @ffiles,$ffile2 if (defined $ffile2);
|
---|
1188 | push @ffiles,$ffile3 if (defined $ffile3);
|
---|
1189 | }
|
---|
1190 | if (@ffiles) {
|
---|
1191 | pb_log(2,"DEBUG ffiles: ".Dumper(\@ffiles)."\n");
|
---|
1192 |
|
---|
1193 | foreach my $f (@ffiles) {
|
---|
1194 | open(CONF,$f) || next;
|
---|
1195 | while(<CONF>) {
|
---|
1196 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
1197 | $h{$1}{$2}=$3;
|
---|
1198 | }
|
---|
1199 | }
|
---|
1200 | close(CONF);
|
---|
1201 |
|
---|
1202 | $ptr = $h{"filter"};
|
---|
1203 | pb_log(2,"DEBUG f:".Dumper($ptr)."\n");
|
---|
1204 | }
|
---|
1205 | } else {
|
---|
1206 | $ptr = { };
|
---|
1207 | }
|
---|
1208 | %ptr = %$ptr;
|
---|
1209 | return(\%ptr);
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | # Function which applies filter on pb build files
|
---|
1213 | sub pb_filter_file_pb {
|
---|
1214 |
|
---|
1215 | my $f=shift;
|
---|
1216 | my $ptr=shift;
|
---|
1217 | my %filter=%$ptr;
|
---|
1218 | my $destfile=shift;
|
---|
1219 | my $dtype=shift;
|
---|
1220 | my $pbsuf=shift;
|
---|
1221 | my $pbproj=shift;
|
---|
1222 | my $pbpkg=shift;
|
---|
1223 | my $pbver=shift;
|
---|
1224 | my $pbtag=shift;
|
---|
1225 | my $pbrev=shift;
|
---|
1226 | my $pbdate=shift;
|
---|
1227 | my $defpkgdir = shift;
|
---|
1228 | my $extpkgdir = shift;
|
---|
1229 | my $pbpackager = shift;
|
---|
1230 | my $chglog = shift || undef;
|
---|
1231 |
|
---|
1232 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
1233 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
1234 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
1235 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
1236 | while (<FILE>) {
|
---|
1237 | my $line = $_;
|
---|
1238 | foreach my $s (keys %filter) {
|
---|
1239 | # Process single variables
|
---|
1240 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
1241 | my $tmp = $filter{$s};
|
---|
1242 | next if (not defined $tmp);
|
---|
1243 | # Expand variables if any single one found
|
---|
1244 | pb_log(2,"DEBUG tmp: $tmp\n");
|
---|
1245 | if ($tmp =~ /\$/) {
|
---|
1246 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
1247 | # special case for ChangeLog only for pb
|
---|
1248 | } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
|
---|
1249 | my $p = $defpkgdir->{$pbpkg};
|
---|
1250 | $p = $extpkgdir->{$pbpkg} if (not defined $p);
|
---|
1251 | pb_changelog($dtype, $pbpkg, $pbver, $pbtag, $pbsuf, $p, \*DEST, $tmp, $chglog);
|
---|
1252 | $tmp = "";
|
---|
1253 | }
|
---|
1254 | $line =~ s|$s|$tmp|;
|
---|
1255 | }
|
---|
1256 | print DEST $line;
|
---|
1257 | }
|
---|
1258 | close(FILE);
|
---|
1259 | close(DEST);
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | # Function which applies filter on files (external call)
|
---|
1263 | sub pb_filter_file_inplace {
|
---|
1264 |
|
---|
1265 | my $ptr=shift;
|
---|
1266 | my %filter=%$ptr;
|
---|
1267 | my $destfile=shift;
|
---|
1268 | my $pbproj=shift;
|
---|
1269 | my $pbpkg=shift;
|
---|
1270 | my $pbver=shift;
|
---|
1271 | my $pbtag=shift;
|
---|
1272 | my $pbrev=shift;
|
---|
1273 | my $pbdate=shift;
|
---|
1274 | my $pbpackager=shift;
|
---|
1275 |
|
---|
1276 | my $cp = "$ENV{'PBTMP'}/".basename($destfile);
|
---|
1277 | copy($destfile,$cp) || die "Unable to create $cp";
|
---|
1278 |
|
---|
1279 | pb_filter_file($cp,$ptr,$destfile,$pbproj,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
|
---|
1280 | unlink $cp;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 | # Function which applies filter on files (external call)
|
---|
1284 | sub pb_filter_file {
|
---|
1285 |
|
---|
1286 | my $f=shift;
|
---|
1287 | my $ptr=shift;
|
---|
1288 | my %filter=%$ptr;
|
---|
1289 | my $destfile=shift;
|
---|
1290 | my $pbproj=shift;
|
---|
1291 | my $pbpkg=shift;
|
---|
1292 | my $pbver=shift;
|
---|
1293 | my $pbtag=shift;
|
---|
1294 | my $pbrev=shift;
|
---|
1295 | my $pbdate=shift;
|
---|
1296 | my $pbpackager=shift;
|
---|
1297 |
|
---|
1298 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
1299 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
1300 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
1301 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
1302 | while (<FILE>) {
|
---|
1303 | my $line = $_;
|
---|
1304 | foreach my $s (keys %filter) {
|
---|
1305 | # Process single variables
|
---|
1306 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
1307 | my $tmp = $filter{$s};
|
---|
1308 | next if (not defined $tmp);
|
---|
1309 | # Expand variables if any single one found
|
---|
1310 | if ($tmp =~ /\$/) {
|
---|
1311 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
1312 | }
|
---|
1313 | $line =~ s|$s|$tmp|;
|
---|
1314 | }
|
---|
1315 | print DEST $line;
|
---|
1316 | }
|
---|
1317 | close(FILE);
|
---|
1318 | close(DEST);
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | sub pb_log_init {
|
---|
1322 |
|
---|
1323 | $debug = shift || 0;
|
---|
1324 | $LOG = shift || \*STDOUT;
|
---|
1325 |
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | sub pb_log {
|
---|
1329 |
|
---|
1330 | my $dlevel = shift;
|
---|
1331 | my $msg = shift;
|
---|
1332 |
|
---|
1333 | print $LOG "$msg\n" if ($dlevel >= $debug);
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | 1;
|
---|