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

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