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

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