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

Last change on this file since 986 was 986, checked in by Bruno Cornec, 14 years ago

r3700@localhost: bruno | 2010-02-20 16:35:59 +0100

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