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

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