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

Last change on this file since 736 was 736, checked in by Bruno Cornec, 15 years ago

Fix #35 by forcing the usage of a -r release option, and by exporting only that version tree from the VCS.

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