source: ProjectBuilder/devel/pb/lib/ProjectBuilder/Env.pm@ 416

Last change on this file since 416 was 416, checked in by Bruno Cornec, 16 years ago

move the pb_env_init function to a separate module to allow pbinit usage

File size: 26.8 KB
Line 
1#!/usr/bin/perl -w
2#
3# Project Builder Env module
4# Env subroutines brought by the the Project-Builder project
5# which can be easily used by pbinit scripts
6#
7# $Id$
8#
9# Copyright B. Cornec 2007
10# Provided under the GPL v2
11
12package ProjectBuilder::Env;
13
14use strict 'vars';
15use Data::Dumper;
16use English;
17use File::Basename;
18use POSIX qw(strftime);
19use lib qw (lib);
20use ProjectBuilder::Base;
21use ProjectBuilder::Conf;
22
23# Inherit from the "Exporter" module which handles exporting functions.
24
25use Exporter;
26
27# Export, by default, all the functions into the namespace of
28# any code which uses this module.
29
30our @ISA = qw(Exporter);
31our @EXPORT = qw(pb_env_init);
32
33=pod
34
35=head1 NAME
36
37ProjectBuilder::Env, part of the project-builder.org
38
39=head1 DESCRIPTION
40
41This modules provides environment functions suitable for pbinit calls.
42
43=head1 USAGE
44
45=over 4
46
47=item B<pb_env_init>
48
49This function setup the environment for project-builder.
50The first parameter is the project if givent on the command line.
51The second parameter is a flag indicating whether we should setup up the pbconf environment or not.
52The third parameter is the action passed to bp.
53It sets up environement variables (PBETC, PBPROJ, PBDEFDIR, PBBUILDDIR, PBROOTDIR, PBDESTDIR, PBCONFDIR, PBPROJVER)
54
55=cut
56
57sub pb_env_init {
58
59my $proj=shift || undef;
60my $pbinit=shift || undef;
61my $action=shift;
62my $ver;
63my $tag;
64
65$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
66
67# We only have one configuration file for now.
68pb_conf_add("$ENV{'PBETC'}");
69
70#
71# Check project name
72# Could be with env var PBPROJ
73# or option -p
74# if not define take the first in conf file
75#
76if ((defined $ENV{'PBPROJ'}) &&
77 (not (defined $proj))) {
78 $proj = $ENV{'PBPROJ'};
79}
80
81#
82# We get the pbconf file for that project
83# and use its content
84#
85my ($pbconf) = pb_conf_get("pbconfurl");
86pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
87
88my %pbconf = %$pbconf;
89if (not defined $proj) {
90 # Take the first as the default project
91 $proj = (keys %pbconf)[0];
92 if (defined $proj) {
93 pb_log(1,"WARNING: using $proj as default project as none has been specified\n");
94 pb_log(1," Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
95 pb_log(1," or call pb with the -p project option or use the env var PBPROJ\n");
96 pb_log(1," if you want to use another project\n");
97 }
98}
99die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
100
101# That's always the environment variable that will be used
102$ENV{'PBPROJ'} = $proj;
103pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
104
105if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
106 die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
107}
108
109# Adds a potential conf file now as it's more
110# important than the project conf file
111my ($vmpath,$vepath) = pb_conf_get("vmpath","vepath");
112pb_conf_add("$vmpath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vmpath->{$ENV{'PBPROJ'}}/.pbrc");
113pb_conf_add("$vepath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vepath->{$ENV{'PBPROJ'}}/.pbrc");
114
115#
116# Detect the root dir for hosting all the content generated with pb
117#
118# Tree will look like this:
119#
120# maint pbdefdir PBDEFDIR dev dir (optional)
121# | |
122# ------------------------ --------------------
123# | | | |
124# pbproj1 pbproj2 PBPROJ pbproj1 pbproj2 PBPROJDIR
125# | |
126# --------------------------------------------- ----------
127# * * * | | | * *
128# tag dev pbconf ... build delivery PBCONFDIR dev tag
129# | | | PBDESTDIR |
130# --- ------ pbrc PBBUILDDIR -------
131# | | | | |
132# 1.1 dev tag 1.0 1.1 PBDIR
133# |
134# -------
135# | |
136# 1.0 1.1 PBROOTDIR
137# |
138# ----------------------------------
139# | | | |
140# pkg1 pbproj1.pb pbfilter pbcl
141# |
142# -----------------
143# | | |
144# rpm deb pbfilter
145#
146#
147# (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
148# Names under a pbproj and the corresponding pbconf should be similar
149#
150
151my ($pbdefdir) = pb_conf_get_if("pbdefdir");
152
153if (not defined $ENV{'PBDEFDIR'}) {
154 if ((not defined $pbdefdir) || (not defined $pbdefdir->{$ENV{'PBPROJ'}})) {
155 pb_log(1,"WARNING: no pbdefdir defined, using /var/cache\n");
156 pb_log(1," Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
157 pb_log(1," if you want to use another directory\n");
158 $ENV{'PBDEFDIR'} = "/var/cache";
159 } else {
160 # That's always the environment variable that will be used
161 $ENV{'PBDEFDIR'} = $pbdefdir->{$ENV{'PBPROJ'}};
162 }
163}
164# Expand potential env variable in it
165eval { $ENV{'PBDEFDIR'} =~ s/(\$ENV.+\})/$1/eeg };
166
167pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n");
168#
169# Set delivery directory
170#
171$ENV{'PBDESTDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/delivery";
172
173pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n");
174#
175# Removes all directory existing below the delivery dir
176# as they are temp dir only
177# Files stay and have to be cleaned up manually if needed
178# those files serves as communication channels between pb phases
179# Removing them prevents a following phase to detect what has been done before
180#
181if (-d $ENV{'PBDESTDIR'}) {
182 opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
183 foreach my $d (readdir(DIR)) {
184 next if ($d =~ /^\./);
185 next if (-f "$ENV{'PBDESTDIR'}/$d");
186 pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
187 }
188 closedir(DIR);
189}
190if (! -d "$ENV{'PBDESTDIR'}") {
191 pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
192}
193
194#
195# Set build directory
196#
197$ENV{'PBBUILDDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/build";
198if (! -d "$ENV{'PBBUILDDIR'}") {
199 pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
200}
201
202pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
203
204pb_temp_init();
205pb_log(2,"PBTMP: $ENV{'PBTMP'}\n");
206
207#
208# The following part is only useful when in cms2something of newver
209# In VMs/VEs we want to skip that by providing good env vars.
210# return values in that case are useless
211#
212if (($action =~ /^cms2/) || ($action =~ /^newver$/)) {
213
214 #
215 # Check pbconf cms compliance
216 #
217 pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
218
219 # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
220 #
221 if (not defined $ENV{'PBROOTDIR'}) {
222 if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
223 opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
224 my $maxmtime = 0;
225 foreach my $d (readdir(DIR)) {
226 pb_log(3,"Looking at \'$d\'...");
227 next if ($d =~ /^\./);
228 next if (! -d "$ENV{'PBCONFDIR'}/$d");
229 my $s = stat("$ENV{'PBCONFDIR'}/$d");
230 next if (not defined $s);
231 pb_log(3,"KEEP\n");
232 # Keep the most recent
233 pb_log(2," $s->mtime\n");
234 if ($s->mtime > $maxmtime) {
235 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
236 $maxmtime = $s->mtime;
237 }
238 }
239 closedir(DIR);
240 die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
241 pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
242 pb_log(1," Please use -r release if you want to use another release\n");
243 } else {
244 my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
245 # That's always the environment variable that will be used
246 die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
247 $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
248 }
249 } else {
250 # transform in full path if relative
251 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
252 pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
253 die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
254 }
255
256 # Adds that conf file to the list to consider
257 pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb");
258
259 return if ($action =~ /^newver$/);
260
261 my %version = ();
262 my %defpkgdir = ();
263 my %extpkgdir = ();
264 my %filteredfiles = ();
265 my %supfiles = ();
266
267 if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
268
269 # List of pkg to build by default (mandatory)
270 my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
271 # List of additional pkg to build when all is called (optional)
272 # Valid version names (optional)
273 # List of files to filter (optional)
274 # Project version and tag (optional)
275 my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
276 pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
277 pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
278 pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
279 pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
280 pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
281 # Global
282 %defpkgdir = %$defpkgdir;
283 %extpkgdir = %$extpkgdir if (defined $extpkgdir);
284 %version = %$version if (defined $version);
285 %filteredfiles = %$filteredfiles if (defined $filteredfiles);
286 %supfiles = %$supfiles if (defined $supfiles);
287 #
288 # Get global Version/Tag
289 #
290 if (not defined $ENV{'PBPROJVER'}) {
291 if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
292 $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
293 } else {
294 die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
295 }
296 }
297 die "Invalid version name $ENV{'PBPROJVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBPROJVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBPROJVER'} =~ /$version{$ENV{'PBPROJ'}}/));
298
299 if (not defined $ENV{'PBPROJTAG'}) {
300 if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
301 $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
302 } else {
303 die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
304 }
305 }
306 die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
307
308
309 if (not defined $ENV{'PBPACKAGER'}) {
310 if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
311 $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
312 } else {
313 die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
314 }
315 }
316 } else {
317 if (defined $pbinit) {
318 my $ptr = pb_get_pkg();
319 my @pkgs = @$ptr;
320 @pkgs = ("pkg1") if (not @pkgs);
321
322 open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
323 print CONF << "EOF";
324#
325# Project Builder configuration file
326# For project $ENV{'PBPROJ'}
327#
328# \$Id\$
329#
330
331#
332# What is the project URL
333#
334#pburl $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
335#pburl $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
336#pburl $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
337#pburl $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
338#pburl $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
339#pburl $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
340#pburl $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
341
342# Check whether project is well formed
343# (containing already a directory with the project-version name)
344#pbwf $ENV{'PBPROJ'} = 1
345
346#
347# Packager label
348#
349#pbpackager $ENV{'PBPROJ'} = William Porte <bill\@$ENV{'PBPROJ'}.org>
350#
351
352# For delivery to a machine by SSH (potentially the FTP server)
353# Needs hostname, account and directory
354#
355#sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
356#sshlogin $ENV{'PBPROJ'} = bill
357#sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
358#sshport $ENV{'PBPROJ'} = 22
359
360#
361# For Virtual machines management
362# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
363# followed by '-' and by release number
364# followed by '-' and by architecture
365# a .vmtype extension will be added to the resulting string
366# a QEMU rhel-3-i286 here means that the VM will be named rhel-3-i386.qemu
367#
368#vmlist $ENV{'PBPROJ'} = mandrake-10.1-i386,mandrake-10.2-i386,mandriva-2006.0-i386,mandriva-2007.0-i386,mandriva-2007.1-i386,mandriva-2008.0-i386,redhat-7.3-i386,redhat-9-i386,fedora-4-i386,fedora-5-i386,fedora-6-i386,fedora-7-i386,fedora-8-i386,rhel-3-i386,rhel-4-i386,rhel-5-i386,suse-10.0-i386,suse-10.1-i386,suse-10.2-i386,suse-10.3-i386,sles-9-i386,sles-10-i386,gentoo-nover-i386,debian-3.1-i386,debian-4.0-i386,ubuntu-6.06-i386,ubuntu-7.04-i386,ubuntu-7.10-i386,mandriva-2007.0-x86_64,mandriva-2007.1-x86_64,mandriva-2008.0-x86_64,fedora-6-x86_64,fedora-7-x86_64,fedora-8-x86_64,rhel-4-x86_64,rhel-5-x86_64,suse-10.2-x86_64,suse-10.3-x86_64,sles-10-x86_64,gentoo-nover-x86_64,debian-4.0-x86_64,ubuntu-7.04-x86_64,ubuntu-7.10-x86_64
369
370#
371# Valid values for vmtype are
372# qemu, (vmware, xen, ... TBD)
373#vmtype $ENV{'PBPROJ'} = qemu
374
375# Hash for VM stuff on vmtype
376#vmntp default = pool.ntp.org
377
378# We suppose we can commmunicate with the VM through SSH
379#vmhost $ENV{'PBPROJ'} = localhost
380#vmlogin $ENV{'PBPROJ'} = pb
381#vmport $ENV{'PBPROJ'} = 2222
382
383# Timeout to wait when VM is launched/stopped
384#vmtmout default = 120
385
386# per VMs needed paramaters
387#vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
388#vmpath $ENV{'PBPROJ'} = /home/qemu
389#vmsize $ENV{'PBPROJ'} = 5G
390
391#
392# For Virtual environment management
393# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
394# followed by '-' and by release number
395# followed by '-' and by architecture
396# a .vetype extension will be added to the resulting string
397# a chroot rhel-3-i286 here means that the VE will be named rhel-3-i386.chroot
398#
399#velist $ENV{'PBPROJ'} = fedora-7-i386
400
401# VE params
402#vetype $ENV{'PBPROJ'} = chroot
403#ventp default = pool.ntp.org
404#velogin $ENV{'PBPROJ'} = pb
405#vepath $ENV{'PBPROJ'} = /var/lib/mock
406#veconf $ENV{'PBPROJ'} = /etc/mock
407#verebuild $ENV{'PBPROJ'} = false
408
409#
410# Global version/tag for the project
411#
412#projver $ENV{'PBPROJ'} = devel
413#projtag $ENV{'PBPROJ'} = 1
414
415# Hash of valid version names
416#version $ENV{'PBPROJ'} = devel,stable
417
418# Adapt to your needs:
419# Optional if you need to overwrite the global values above
420#
421EOF
422
423 foreach my $pp (@pkgs) {
424 print CONF << "EOF";
425#pkgver $pp = stable
426#pkgtag $pp = 3
427EOF
428 }
429 foreach my $pp (@pkgs) {
430 print CONF << "EOF";
431# Hash of default package/package directory
432#defpkgdir $pp = dir-$pp
433EOF
434 }
435
436 print CONF << "EOF";
437# Hash of additional package/package directory
438#extpkgdir minor-pkg = dir-minor-pkg
439
440# List of files per pkg on which to apply filters
441# Files are mentioned relatively to pbroot/defpkgdir
442EOF
443 foreach my $pp (@pkgs) {
444 print CONF << "EOF";
445#filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
446#supfiles $pp = $pp.init
447EOF
448 }
449 close(CONF);
450 pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
451 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
452 print CONF << "EOF";
453#
454# \$Id\$
455#
456# Filter for all files
457#
458# PBSRC is replaced by the source package format
459#filter PBSRC = ftp://ftp.$ENV{'PBPROJ'}.org/src/%{name}-%{version}.tar.gz
460
461# PBVER is replaced by the version (\$pbver in code)
462filter PBVER = \$pbver
463
464# PBDATE is replaced by the date (\$pbdate in code)
465filter PBDATE = \$pbdate
466
467# PBLOG is replaced by the changelog if value is yes
468#filter PBLOG = yes
469
470# PBTAG is replaced by the tag (\$pbtag in code)
471filter PBTAG = \$pbtag
472
473# PBREV is replaced by the revision (\$pbrev in code)
474filter PBREV = \$pbrev
475
476# PBPKG is replaced by the package name (\$pbpkg in code)
477filter PBPKG = \$pbpkg
478
479# PBPACKAGER is replaced by the packager name (\$pbpackager in code)
480filter PBPACKAGER = \$pbpackager
481
482# PBDESC contains the description of the package
483#filter PBDESC = "Bla-Bla"
484
485# PBURL contains the URL of the Web site of the project
486#filter PBURL = http://www.$ENV{'PBPROJ'}.org
487EOF
488 close(CONF);
489 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
490 print CONF << "EOF";
491#
492# \$Id\$
493#
494# Filter for rpm build
495#
496
497# PBGRP is replaced by the RPM group of apps
498# Cf: http://fedoraproject.org/wiki/RPMGroups
499#filter PBGRP = Applications/Archiving
500
501# PBLIC is replaced by the license of the application
502# Cf: http://fedoraproject.org/wiki/Licensing
503#filter PBLIC = GPL
504
505# PBDEP is replaced by the list of dependencies
506#filter PBDEP =
507
508# PBSUF is replaced by the package suffix (\$pbsuf in code)
509filter PBSUF = \$pbsuf
510
511# PBOBS is replaced by the Obsolete line
512#filter PBOBS =
513
514EOF
515 close(CONF);
516 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
517 print CONF << "EOF";
518#
519# \$Id\$
520#
521# Filter for debian build
522#
523# PBGRP is replaced by the group of apps
524filter PBGRP = utils
525
526# PBLIC is replaced by the license of the application
527# Cf:
528#filter PBLIC = GPL
529
530# PBDEP is replaced by the list of dependencies
531#filter PBDEP =
532
533# PBSUG is replaced by the list of suggestions
534#filter PBSUG =
535
536# PBREC is replaced by the list of recommandations
537#filter PBREC =
538
539EOF
540 close(CONF);
541 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
542 print CONF << "EOF";
543# Specific group for Mandriva for $ENV{'PBPROJ'}
544# Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
545#filter PBGRP = Archiving/Backup
546
547# PBLIC is replaced by the license of the application
548# Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses
549#filter PBLIC = GPL
550
551EOF
552 close(CONF);
553 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
554 print CONF << "EOF";
555# Specific group for SuSE for $ENV{'PBPROJ'}
556# Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
557#filter PBGRP = Productivity/Archiving/Backup
558
559# PBLIC is replaced by the license of the application
560# Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag
561#filter PBLIC = GPL
562
563EOF
564 close(CONF);
565 foreach my $pp (@pkgs) {
566 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
567 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
568 print CONF << "EOF";
569Source: PBPKG
570Section: PBGRP
571Priority: optional
572Maintainer: PBPACKAGER
573Build-Depends: debhelper (>= 4.2.20), PBDEP
574Standards-Version: 3.6.1
575
576Package: PBPKG
577Architecture: amd64 i386 ia64
578Section: PBGRP
579Priority: optional
580Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
581Recommends: PBREC
582Suggests: PBSUG
583Description:
584 PBDESC
585 .
586 Homepage: PBURL
587
588EOF
589 close(CONF);
590 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
591 print CONF << "EOF";
592This package is debianized by PBPACKAGER
593`date`
594
595The current upstream source was downloaded from
596ftp://ftp.$ENV{'PBPROJ'}.org/src/.
597
598Upstream Authors: Put their name here
599
600Copyright:
601
602 This package is free software; you can redistribute it and/or modify
603 it under the terms of the GNU General Public License as published by
604 the Free Software Foundation; version 2 dated June, 1991.
605
606 This package is distributed in the hope that it will be useful,
607 but WITHOUT ANY WARRANTY; without even the implied warranty of
608 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
609 GNU General Public License for more details.
610
611 You should have received a copy of the GNU General Public License
612 along with this package; if not, write to the Free Software
613 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
614 MA 02110-1301, USA.
615
616On Debian systems, the complete text of the GNU General
617Public License can be found in /usr/share/common-licenses/GPL.
618
619EOF
620 close(CONF);
621 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
622 print CONF << "EOF";
623PBLOG
624EOF
625 close(CONF);
626 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
627 print CONF << "EOF";
6284
629EOF
630 close(CONF);
631 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
632 print CONF << "EOF";
633EOF
634 close(CONF);
635 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
636 print CONF << "EOF";
637INSTALL
638COPYING
639AUTHORS
640NEWS
641README
642EOF
643 close(CONF);
644 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
645 print CONF << 'EOF';
646#!/usr/bin/make -f
647# -*- makefile -*-
648# Sample debian/rules that uses debhelper.
649# GNU copyright 1997 to 1999 by Joey Hess.
650#
651# $Id$
652#
653
654# Uncomment this to turn on verbose mode.
655#export DH_VERBOSE=1
656
657# Define package name variable for a one-stop change.
658PACKAGE_NAME = PBPKG
659
660# These are used for cross-compiling and for saving the configure script
661# from having to guess our platform (since we know it already)
662DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
663DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
664
665CFLAGS = -Wall -g
666
667ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
668 CFLAGS += -O0
669else
670 CFLAGS += -O2
671endif
672ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
673 INSTALL_PROGRAM += -s
674endif
675config.status: configure
676 dh_testdir
677
678 # Configure the package.
679 CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
680 --mandir=\$${prefix}/share/man
681
682# Build both architecture dependent and independent
683build: build-arch build-indep
684
685# Build architecture dependent
686build-arch: build-arch-stamp
687
688build-arch-stamp: config.status
689 dh_testdir
690
691 # Compile the package.
692 $(MAKE)
693
694 touch build-stamp
695
696# Build architecture independent
697build-indep: build-indep-stamp
698
699build-indep-stamp: config.status
700 # Nothing to do, the only indep item is the manual which is available as html in original source
701 touch build-indep-stamp
702
703# Clean up
704clean:
705 dh_testdir
706 dh_testroot
707 rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
708 # Clean temporary document directory
709 rm -rf debian/doc-temp
710 # Clean up.
711 -$(MAKE) distclean
712 rm -f config.log
713ifneq "$(wildcard /usr/share/misc/config.sub)" ""
714 cp -f /usr/share/misc/config.sub config.sub
715endif
716ifneq "$(wildcard /usr/share/misc/config.guess)" ""
717 cp -f /usr/share/misc/config.guess config.guess
718endif
719
720 dh_clean
721
722# Install architecture dependent and independent
723install: install-arch install-indep
724
725# Install architecture dependent
726install-arch: build-arch
727 dh_testdir
728 dh_testroot
729 dh_clean -k -s
730 dh_installdirs -s
731
732 # Install the package files into build directory:
733 # - start with upstream make install
734 $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
735r/share/man
736 # - copy html manual to temporary location for renaming
737 mkdir -p debian/doc-temp
738 dh_install -s
739
740# Install architecture independent
741install-indep: build-indep
742 dh_testdir
743 dh_testroot
744 dh_clean -k -i
745 dh_installdirs -i
746 dh_install -i
747
748# Must not depend on anything. This is to be called by
749# binary-arch/binary-indep
750# in another 'make' thread.
751binary-common:
752 dh_testdir
753 dh_testroot
754 dh_installchangelogs ChangeLog
755 dh_installdocs
756 dh_installman
757 dh_link
758 dh_strip
759 dh_compress
760 dh_fixperms
761 dh_installdeb
762 dh_shlibdeps
763 dh_gencontrol
764 dh_md5sums
765 dh_builddeb
766
767# Build architecture independant packages using the common target.
768binary-indep: build-indep install-indep
769 $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
770
771# Build architecture dependant packages using the common target.
772binary-arch: build-arch install-arch
773 $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
774
775# Build architecture depdendent and independent packages
776binary: binary-arch binary-indep
777.PHONY: clean binary
778
779EOF
780 close(CONF);
781 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
782 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
783 print CONF << 'EOF';
784#
785# $Id$
786#
787
788Summary: bla-bla
789Summary(fr): french bla-bla
790
791Name: PBPKG
792Version: PBVER
793Release: PBTAGPBSUF
794License: PBLIC
795Group: PBGRP
796Url: PBURL
797Source: PBSRC
798BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
799#Requires: PBDEP
800
801%description
802PBDESC
803
804%description -l fr
805french desc
806
807%prep
808%setup -q
809
810%build
811%configure
812make %{?_smp_mflags}
813
814%install
815%{__rm} -rf $RPM_BUILD_ROOT
816make DESTDIR=$RPM_BUILD_ROOT install
817
818%clean
819%{__rm} -rf $RPM_BUILD_ROOT
820
821%files
822%defattr(-,root,root)
823%doc ChangeLog
824%doc INSTALL COPYING README AUTHORS NEWS
825
826%changelog
827PBLOG
828
829EOF
830 close(CONF);
831 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
832
833 pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
834 }
835 } else {
836 die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
837 }
838 }
839 umask 0022;
840 return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
841} else {
842 # Setup the variables from what has been stored at the end of cms2build
843 my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
844 $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
845
846 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
847 $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
848
849 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
850 $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
851
852 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
853 $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
854
855 return;
856}
857}
858
859=back
860
861=head1 WEB SITES
862
863The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
864
865=head1 USER MAILING LIST
866
867None exists for the moment.
868
869=head1 AUTHORS
870
871The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
872
873=head1 COPYRIGHT
874
875Project-Builder.org is distributed under the GPL v2.0 license
876described in the file C<COPYING> included with the distribution.
877
878=cut
879
8801;
Note: See TracBrowser for help on using the repository browser.