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

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