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

Last change on this file since 592 was 592, checked in by Bruno Cornec, 16 years ago

Improve newver for fedora older versions

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