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

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