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