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

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