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

Last change on this file since 1176 was 1176, checked in by Bruno Cornec, 13 years ago

r4160@eelzbach2: bruno | 2011-02-06 13:30:39 +0100

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