source: ProjectBuilder/devel/pb-modules/lib/ProjectBuilder/Env.pm@ 2205

Last change on this file since 2205 was 2205, checked in by Bruno Cornec, 7 years ago

Improve newproj action review skeletons, fix some tests)
Use PBPROJDIR to allow having a different project dir than the project name

File size: 41.8 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# Copyright B. Cornec 2007-2016
8# Eric Anderson's changes are (c) Copyright 2012 Hewlett Packard
9# Provided under the GPL v2
10#
11# $Id$
12#
13
14package ProjectBuilder::Env;
15
16use strict 'vars';
17use Data::Dumper;
18use English;
19use File::Basename;
20use File::stat;
21use POSIX qw(strftime);
22use lib qw (lib);
23use ProjectBuilder::Version;
24use ProjectBuilder::Base;
25use ProjectBuilder::Conf;
26use ProjectBuilder::VCS;
27
28# Inherit from the "Exporter" module which handles exporting functions.
29
30use vars qw($VERSION $REVISION @ISA @EXPORT);
31use Exporter;
32
33# Export, by default, all the functions into the namespace of
34# any code which uses this module.
35
36our @ISA = qw(Exporter);
37our @EXPORT = qw(pb_env_init pb_env_init_pbrc);
38($VERSION,$REVISION) = pb_version_init();
39
40=pod
41
42=head1 NAME
43
44ProjectBuilder::Env, part of the project-builder.org
45
46=head1 DESCRIPTION
47
48This modules provides environment functions suitable for pbinit calls.
49
50=head1 USAGE
51
52=over 4
53
54=item B<pb_env_init_pbrc>
55
56This function setup/use the configuration file in the HOME directory
57It sets up environment variables (PBETC)
58
59=cut
60
61sub pb_env_init_pbrc {
62
63# if sudo, then get the real id of the user launching the context
64# to point to the right conf file
65# Mandatory for rpmbootstrap calls
66my $dir;
67
68if (defined $ENV{'SUDO_USER'}) {
69 # Home dir is the 8th field in list context
70 $dir = (getpwnam($ENV{'SUDO_USER'}))[7];
71} else {
72 $dir = $ENV{'HOME'};
73}
74
75$ENV{'PBETC'} = "$dir/.pbrc";
76
77if (! -f $ENV{'PBETC'}) {
78 pb_log(0, "No existing $ENV{'PBETC'} found, creating one as template\n");
79 open(PBRC, "> $ENV{'PBETC'}") || die "Unable to create $ENV{'PBETC'}";
80 print PBRC << "EOF";
81#
82# Define for each project the URL of its pbconf repository
83# No default option allowed here as they need to be all different
84#
85#pbconfurl example = svn+ssh://svn.example.org/svn/pb/projects/example/pbconf
86#pbconfurl pb = svn+ssh://svn.project-builder.org/mondo/svn/pb/pbconf
87
88# Under that dir will take place everything related to pb
89# If you want to use VMs/chroot/..., then use \$ENV{'HOME'} to make it portable
90# to your VMs/chroot/...
91# if not defined then /var/cache
92#pbdefdir default = \$ENV{'HOME'}/pb/projects
93#pbdefdir pb = \$ENV{'HOME'}
94
95# If not defined, pbconfdir is under pbdefdir/pbproj/pbconf
96#pbconfdir pb = \$ENV{'HOME'}/pb/pbconf
97
98# If not defined, pbprojdir is under pbdefdir/pbproj
99# Only defined if we have access to the dev of the project
100#pbprojdir example = \$ENV{'HOME'}/example/svn
101
102# We have commit acces to these
103#pburl example = cvs+ssh://user\@example.cvs.sourceforge.net:/cvsroot/example
104#pburl pb = svn+ssh://svn.project-builder.org/mondo/svn/pb
105
106# I mask my real login on the ssh machines here
107#sshlogin example = user
108
109# where to find Build System infos:
110#vmpath default = /home/qemu
111#vepath default = /home/rpmbootstrap
112#rmpath default = /home/remote
113
114# Overwrite generic setup
115#vmport pb = 2223
116#vmport example = 2224
117
118# Info on who is packaging
119#pbpackager default = William Porte <bill\@porte.org>
120#pbpassphrase default = TheScretePassPhrase
121#pbpassfile default = /home/williamporte/secret/passfile
122EOF
123 }
124
125# We only have one configuration file for now.
126pb_conf_add("$ENV{'PBETC'}");
127}
128
129=item B<pb_env_init>
130
131This function setup the environment for project-builder.
132The first parameter is the project if given on the command line.
133The second parameter is a flag indicating whether we should setup up the pbconf environment or not.
134The third parameter is the action passed to pb.
135It sets up environement variables (PBETC, PBPROJ, PBDEFDIR, PBBUILDDIR, PBROOTDIR, PBDESTDIR, PBCONFDIR, PBPROJVER)
136
137=cut
138
139sub pb_env_init {
140
141my $proj=shift;
142my $pbinit=shift;
143my $action=shift;
144my $pbkeep=shift || 0;
145my $ver;
146my $tag;
147
148pb_conf_init($proj);
149pb_env_init_pbrc();
150
151#
152# We get the pbconf file for that project
153# and use its content
154#
155my ($pbconf) = pb_conf_get("pbconfurl");
156pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
157
158my %pbconf = %$pbconf;
159if (not defined $proj) {
160 # Take the first as the default project
161 $proj = (keys %pbconf)[0];
162 if (defined $proj) {
163 pb_log(1,"WARNING: using $proj as default project as none has been specified\n");
164 pb_log(1," Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
165 pb_log(1," or call pb with the -p project option or use the env var PBPROJ\n");
166 pb_log(1," if you want to use another project\n");
167 }
168}
169die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
170
171# That's always the environment variable that will be used
172$ENV{'PBPROJ'} = $proj;
173pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
174
175if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
176 die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
177}
178
179# Adds a potential conf file now as it's less
180# important than the project conf file
181my ($vmpath,$vepath,$rmpath) = pb_conf_get_if("vmpath","vepath","rmpath");
182foreach my $p ($vmpath,$vepath,$rmpath) {
183 if ((defined $p) && (defined $p->{$ENV{'PBPROJ'}})) {
184 $p->{$ENV{'PBPROJ'}} = pb_path_expand($p->{$ENV{'PBPROJ'}});
185 # TODO: should we add the conf files pointed by project default as well ?
186 pb_conf_add("$p->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$p->{$ENV{'PBPROJ'}}/.pbrc");
187 }
188}
189
190#
191# Detect the root dir for hosting all the content generated with pb
192#
193=pod
194
195 Tree will look like this:
196
197 maint pbdefdir PBDEFDIR dev dir (optional)
198 | |
199 ------------------------ --------------------
200 | | | |
201 pbproj1 pbproj2 PBPROJ pbproj1 pbproj2 PBPROJDIR
202 | |
203 --------------------------------------------- ----------
204 * * * | | | * *
205 tag dev pbconf ... bpbuild pbdelivery PBCONFDIR dev tag
206 | | | PBDESTDIR |
207 --- ------ pbrc PBBUILDDIR -------
208 | | | | |
209 1.1 dev tag 1.0 1.1 PBDIR
210 |
211 -------
212 | |
213 1.0 1.1 PBROOTDIR
214 |
215 ----------------------------------
216 | | | |
217 pkg1 pbproj1.pb pbfilter pbcl
218 |
219 -----------------
220 | | |
221 rpm deb pbfilter
222
223
224 (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
225 Names under a pbproj and the corresponding pbconf should be similar
226
227=back
228
229=cut
230
231my ($pbdefdir) = pb_conf_get_if("pbdefdir");
232
233if (not defined $ENV{'PBDEFDIR'}) {
234 if ((not defined $pbdefdir) || (not defined $pbdefdir->{$ENV{'PBPROJ'}})) {
235 pb_log(1,"WARNING: no pbdefdir defined, using /var/cache\n");
236 pb_log(1," Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
237 pb_log(1," if you want to use another directory\n");
238 $ENV{'PBDEFDIR'} = "/var/cache";
239 } else {
240 # That's always the environment variable that will be used
241 $ENV{'PBDEFDIR'} = $pbdefdir->{$ENV{'PBPROJ'}};
242 }
243}
244# Expand potential env variable in it
245$ENV{PBDEFDIR} = pb_path_expand($ENV{PBDEFDIR});
246pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n");
247
248# Need to do that earlier as it's used potentialy in pb_vcs_add
249pb_temp_init($pbkeep);
250pb_log(2,"PBTMP: $ENV{'PBTMP'}\n");
251
252my ($pbprojdir) = pb_conf_get_if("pbprojdir");
253if (not defined $ENV{'PBPROJDIR'}) {
254 if ((not defined $pbprojdir) || (not defined $pbprojdir->{$ENV{'PBPROJ'}})) {
255 pb_log(1,"WARNING: no pbprojdir defined, using $ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}\n");
256 pb_log(1," Please create a pbprojdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
257 pb_log(1," if you want to use another directory\n");
258 $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";
259 } else {
260 # That's always the environment variable that will be used
261 $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}};
262 }
263}
264
265# Put under CMS the PBPROJ dir
266if ($action =~ /^newproj$/) {
267 if (! -d "$ENV{'PBPROJDIR'}") {
268 # TODO: There is also the need to do
269 # svn import svn://repo "$ENV{'PBPROJDIR'}
270 # in case it doesn't exist there
271 pb_mkdir_p("$ENV{'PBPROJDIR'}");
272 }
273 pb_vcs_add($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBPROJDIR'}");
274}
275
276#
277# Set delivery directory
278#
279$ENV{'PBDESTDIR'}="$ENV{'PBPROJDIR'}/pbdelivery";
280
281pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n");
282#
283# Removes all directory existing below the delivery dir
284# as they are temp dir only except when called from newproj
285# Files stay and have to be cleaned up manually if needed
286# those files serves as communication channels between pb phases
287# Removing them prevents a following phase to detect what has been done before
288#
289if ((-d $ENV{'PBDESTDIR'}) && (not defined $pbinit)) {
290 opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
291 foreach my $d (readdir(DIR)) {
292 next if ($d =~ /^\./);
293 next if (-f "$ENV{'PBDESTDIR'}/$d");
294 pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
295 }
296 closedir(DIR);
297}
298if (! -d "$ENV{'PBDESTDIR'}") {
299 pb_mkdir_p($ENV{'PBDESTDIR'});
300}
301
302#
303# Set build directory
304#
305$ENV{'PBBUILDDIR'}="$ENV{'PBPROJDIR'}/pbbuild";
306if (! -d "$ENV{'PBBUILDDIR'}") {
307 pb_mkdir_p($ENV{'PBBUILDDIR'});
308}
309
310pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
311
312return if ($action =~ /^clean$/);
313#
314# The following part is only useful when in sbx|cms2something or newsomething
315# In VMs/VEs/RMs we want to skip that by providing good env vars.
316# return values in that case are useless
317#
318
319if ($action =~ /^(cms2|sbx2|newver|newproj|announce|checkssh|cleanssh|getconf|setupve)/) {
320
321 #
322 # Check pbconf cms compliance
323 #
324 pb_vcs_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBPROJDIR'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
325 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}});
326
327 # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
328 #
329 if (not defined $ENV{'PBROOTDIR'}) {
330 if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
331 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}";
332 pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
333 pb_log(1," Please use -r release if you want to use another release\n");
334 die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
335 } else {
336 my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
337 # That's always the environment variable that will be used
338 die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
339 $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
340 }
341 } else {
342 # transform in full path if relative
343 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
344 # If git, then versions are in branch not in dirs, except for git+svn
345 $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}" if (($scheme =~ /^git/) && ($scheme =~ /svn/));
346 pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
347 die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
348 }
349 pb_log(1,"PBROOTDIR=$ENV{'PBROOTDIR'}\n");
350
351 # Adds that conf file to the list to consider
352 pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb");
353
354 return if ($action =~ /^(newver|getconf|setupve)$/);
355
356 my %version = ();
357 my %defpkgdir = ();
358 my %extpkgdir = ();
359 my %filteredfiles = ();
360 my %supfiles = ();
361
362 if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
363
364 # List of pkg to build by default (mandatory)
365 # TODO: projtag could be with a 1 default value
366 my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
367 # List of additional pkg to build when all is called (optional)
368 # Valid version names (optional)
369 # List of files to filter (optional)
370 # Project version and tag (optional)
371 my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
372 pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
373 pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
374 pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
375 pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
376 pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
377 # Global
378 %defpkgdir = %$defpkgdir;
379 %extpkgdir = %$extpkgdir if (defined $extpkgdir);
380 %version = %$version if (defined $version);
381 %filteredfiles = %$filteredfiles if (defined $filteredfiles);
382 %supfiles = %$supfiles if (defined $supfiles);
383 #
384 # Get global Version/Tag
385 #
386 if (not defined $ENV{'PBPROJVER'}) {
387 if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
388 $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
389 } else {
390 die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
391 }
392 }
393 die "Invalid version name $ENV{'PBPROJVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBPROJVER'} !~ /[0-9.]+/) && (defined $version) && ($ENV{'PBPROJVER'} =~ /$version{$ENV{'PBPROJ'}}/));
394
395 if (not defined $ENV{'PBPROJTAG'}) {
396 if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
397 $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
398 } else {
399 die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
400 }
401 }
402 die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
403
404
405 if (not defined $ENV{'PBPACKAGER'}) {
406 if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
407 $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
408 } else {
409 die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
410 }
411 }
412 } else {
413 if (defined $pbinit) {
414 my @pkgs = @ARGV;
415 @pkgs = ("pkg1") if (not @pkgs);
416
417 open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
418 print CONF << "EOF";
419#
420# Project Builder configuration file
421# For project $ENV{'PBPROJ'}
422#
423# \$Id\$
424#
425
426#
427# What is the project URL
428#
429#pburl $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
430#pburl $ENV{'PBPROJ'} = svn+ssh://user\@svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
431#pburl $ENV{'PBPROJ'} = git+ssh//user\@git.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
432#pburl $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
433#pburl $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
434#pburl $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
435#pburl $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
436#pburl $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
437
438# Repository
439#pbrepo $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org
440#pbml $ENV{'PBPROJ'} = $ENV{'PBPROJ'}-announce\@lists.$ENV{'PBPROJ'}.org
441#pbsmtp $ENV{'PBPROJ'} = localhost
442#pbgpgcheck $ENV{'PBPROJ'} = 1
443# For distro supporting it, which area is used
444#projcomponent $ENV{'PBPROJ'} = main
445
446# Check whether project is well formed
447# when downloading from ftp/http/...
448# (containing already a directory with the project-version name)
449#pbwf $ENV{'PBPROJ'} = 1
450
451# Do we check GPG keys
452#pbgpgcheck $ENV{'PBPROJ'} = 1
453
454#
455# Packager label
456#
457#pbpackager $ENV{'PBPROJ'} = William Porte <bill\@$ENV{'PBPROJ'}.org>
458#
459
460# For delivery to a machine by SSH (potentially the FTP server)
461# Needs hostname, account and directory
462#
463#sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
464#sshlogin $ENV{'PBPROJ'} = bill
465#sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
466#sshport $ENV{'PBPROJ'} = 22
467
468#
469# For Virtual machines management
470# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
471# followed by '-' and by release number
472# followed by '-' and by architecture
473# a .vmtype extension will be added to the resulting string
474# a QEMU rhel-3-i286 here means that the VM will be named rhel-3-i386.qemu
475#
476#vmlist $ENV{'PBPROJ'} = asianux-2-i386,asianux-3-i386,centos-7-x86_64,mandrake-10.1-i386,mandrake-10.2-i386,mandriva-2006.0-i386,mandriva-2007.0-i386,mandriva-2007.1-i386,mandriva-2008.0-i386,mandriva-2008.1-i386,mandriva-2009.0-i386,mandriva-2009.1-i386,mandriva-2010.0-i386,mandriva-2010.1-i386,redhat-7.3-i386,redhat-9-i386,fedora-4-i386,fedora-5-i386,fedora-6-i386,fedora-7-i386,fedora-8-i386,fedora-9-i386,fedora-10-i386,fedora-11-i386,fedora-12-i386,fedora-13-i386,fedora-14-i386,fedora-15-i386,fedora-16-i386,fedora-17-i386,fedora-18-i386,fedora-19-i386,fedora-20-i386,fedora-21-i386,rhel-2-i386,rhel-3-i386,rhel-4-i386,rhel-5-i386,rhel-6-i386,suse-10.0-i386,suse-10.1-i386,opensuse-10.2-i386,opensuse-10.3-i386,opensuse-11.0-i386,opensuse-11.1-i386,opensuse-11.2-i386,opensuse-11.3-i386,opensuse-11.4-i386,opensuse-12.1-i386,opensuse-12.2-i386,opensuse-12.3-i386,opensuse-13.1-i386,opensuse-13.2-i386,sles-9-i386,sles-10-i386,sles-11-i386,gentoo-nover-i386,debian-3-i386,debian-4-i386,debian-5-i386,debian-6-i386,debian-7-i386,debian-8-i386,ubuntu-6.06-i386,ubuntu-7.04-i386,ubuntu-7.10-i386,ubuntu-8.04-i386,ubuntu-8.10-i386,ubuntu-9.04-i386,ubuntu-9.10-i386,ubuntu-10.04-i386,ubuntu-10.10-i386,ubuntu-11.04-i386,ubuntu-11.10-i386,ubuntu-12.04-i386,ubuntu-12.10-i386,ubuntu-13.04-i386,ubuntu-13.10-i386,ubuntu-14.04-i386,ubuntu-14.10-i386,ubuntu-15.04-i386,ubuntu-15.10-i386,ubuntu-16.04-i386,solaris-10-i386,asianux-2-x86_64,asianux-3-x86_64,mandriva-2007.0-x86_64,mandriva-2007.1-x86_64,mandriva-2008.0-x86_64,mandriva-2008.1-x86_64,mandriva-2009.0-x86_64,mandriva-2009.1-x86_64,mandriva-2010.0-x86_64,mandriva-2010.1-x86_64,mageia-1-i386,mageia-2-i386,mageia-3-i386,mageia-4-i386,mageia-5-i386,mageia-1-x86_64,mageia-2-x86_64,mageia-3-x86_64,mageia-4-x86_64,mageia-5-x86_64,fedora-6-x86_64,fedora-7-x86_64,fedora-8-x86_64,fedora-9-x86_64,fedora-10-x86_64,fedora-11-x86_64,fedora-12-x86_64,fedora-13-x86_64,fedora-14-x86_64,fedora-15-x86_64,fedora-16-x86_64,fedora-17-x86_64,fedora-18-x86_64,fedora-19-x86_64,fedora-20-x86_64,fedora-21-x86_64,fedora-22-x86_64,fedora-23-x86_64,rhel-3-x86_64,rhel-4-x86_64,rhel-5-x86_64,rhel-6-x86_64,rhel-7-x86_64,opensuse-10.2-x86_64,opensuse-10.3-x86_64,opensuse-11.0-x86_64,opensuse-11.1-x86_64,opensuse-11.2-x86_64,opensuse-11.3-x86_64,opensuse-11.4-x86_64,opensuse-12.1-x86_64,opensuse-12.2-x86_64,opensuse-12.3-x86_64,opensuse-13.1-x86_64,opensuse-13.2-x86_64,sles-10-x86_64,sles-11-x86_64,sles-12-x86_64,gentoo-nover-x86_64,debian-4-x86_64,debian-5-x86_64,debian-6-x86_64,debian-7-x86_64,debian-8-x86_64,ubuntu-7.04-x86_64,ubuntu-7.10-x86_64,ubuntu-8.04-x86_64,ubuntu-8.10-x86_64,ubuntu-9.04-x86_64,ubuntu-9.10-x86_64,ubuntu-10.04-x86_64,ubuntu-10.10-x86_64,ubuntu-11.04-x86_64,ubuntu-11.10-x86_64,ubuntu-12.04-x86_64,ubuntu-12.10-x86_64,ubuntu-13.04-x86_64,ubuntu-13.10-x86_64,ubuntu-14.04-x86_64,ubuntu-14.10-x86_64,ubuntu-15.04-x86_64,ubuntu-15.10-x86_64,ubuntu-16.04-x86_64
477
478#
479# Valid values for vmtype are
480# qemu, (vmware, xen, ... TBD)
481#vmtype $ENV{'PBPROJ'} = qemu
482
483# Hash for VM stuff on vmtype
484#vmntp default = pool.ntp.org
485
486# We suppose we can commmunicate with the VM through SSH
487#vmhost $ENV{'PBPROJ'} = localhost
488#vmlogin $ENV{'PBPROJ'} = pb
489#vmport $ENV{'PBPROJ'} = 2222
490
491# Timeout to wait when VM is launched/stopped
492#vmtmout default = 120
493
494# per VMs needed paramaters
495#vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
496#vmpath $ENV{'PBPROJ'} = /home/qemu
497#vmsize $ENV{'PBPROJ'} = 5G
498
499#
500# For Virtual environment management
501# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
502# followed by '-' and by release number
503# followed by '-' and by architecture
504# a .vetype extension will be added to the resulting string
505# a chroot rhel-3-i286 here means that the VE will be named rhel-3-i386.chroot
506#
507#velist $ENV{'PBPROJ'} = velist default = debian-7-x86_64,debian-8-x86_64,centos-5-x86_64,centos-6-x86_64,centos-7-x86_64,fedora-21-x86_64,fedora-22-x86_64,fedora-23-x86_64,fedora-24-x86_64,fedora-25-x86_64,ubuntu-12.04-x86_64,ubuntu-14.04-x86_64,ubuntu-14.10-x86_64,ubuntu-15.04-x86_64,ubuntu-15.10-x86_64,ubuntu-16.04-x86_64,ubuntu-16.10-x86_64,opensuse-42.1-x86_64,opensuse-42.2-x86_64,opensuse-13.2-x86_64,opensuse-13.1-x86_64,mageia-4-x86_64,mageia-5-x86_64
508
509# VE params
510#vetype $ENV{'PBPROJ'} = chroot
511#ventp default = pool.ntp.org
512#velogin $ENV{'PBPROJ'} = pb
513#vepath $ENV{'PBPROJ'} = /var/cache/rpmbootstrap
514#rbsconf $ENV{'PBPROJ'} = /etc/mock
515#verebuild $ENV{'PBPROJ'} = false
516
517#
518# Global version/tag for the project
519#
520#projver $ENV{'PBPROJ'} = devel
521#projtag $ENV{'PBPROJ'} = 1
522
523# Hash of valid version names
524
525# Additional repository to add at build time
526# addrepo centos-5-x86_64 = http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm,ftp://ftp.project-builder.org/centos/5/pb.repo
527# addrepo centos-5-x86_64 = http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm,ftp://ftp.project-builder.org/centos/5/pb.repo
528#version $ENV{'PBPROJ'} = devel,stable
529
530# Is it a test version or a production version
531testver $ENV{'PBPROJ'} = true
532# Which upper target dir for delivery
533delivery $ENV{'PBPROJ'} = test
534
535# Additional repository to add at build time
536# addrepo centos-5-x86_64 = http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm,ftp://ftp.project-builder.org/centos/5/pb.repo
537# addrepo centos-4-x86_64 = http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.x86_64.rpm,ftp://ftp.project-builder.org/centos/4/pb.repo
538
539# Adapt to your needs:
540# Optional if you need to overwrite the global values above
541#
542EOF
543
544 foreach my $pp (@pkgs) {
545 print CONF << "EOF";
546#pkgver $pp = stable
547#pkgtag $pp = 3
548EOF
549 }
550 foreach my $pp (@pkgs) {
551 print CONF << "EOF";
552# Hash of default package/package directory
553#defpkgdir $pp = dir-$pp
554EOF
555 }
556
557 print CONF << "EOF";
558# Hash of additional package/package directory
559#extpkgdir minor-pkg = dir-minor-pkg
560
561# List of files per pkg on which to apply filters
562# Files are mentioned relatively to pbroot/defpkgdir
563EOF
564 foreach my $pp (@pkgs) {
565 print CONF << "EOF";
566#filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
567#supfiles $pp = $pp.init
568
569# For perl modules, names are different depending on distro
570# Here perl-xxx for RPMs, libxxx-perl for debs, ...
571# So the package name is indeed virtual
572#namingtype $pp = perl
573EOF
574 }
575 close(CONF);
576 pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter");
577 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
578 print CONF << "EOF";
579#
580# \$Id\$
581#
582# Filter for all files
583#
584#
585# PBREPO is replaced by the root URL to access the repository
586filter PBREPO = \$pb->{'repo'}
587
588# PBSRC is replaced by the source package location after the repo
589filter PBSRC = src/%{srcname}-%{version}\$pb->{'extdir'}.tar.gz
590
591# PBVER is replaced by the version (\$pb->{'ver'} in code)
592filter PBVER = \$pb->{'ver'}
593
594# PBDATE is replaced by the date (\$pb->{'date'} in code)
595filter PBDATE = \$pb->{'date'}
596
597# PBEXTDIR is replaced by the testdir extension if needed (\$pb->{'extdir'} in code)
598filter PBEXTDIR = \$pb->{'extdir'}
599
600# PBPATCHSRC is replaced by the patches names if value is yes. Patches are located under the pbpatch dir of the pkg.
601#filter PBPATCHSRC = yes
602
603# PBPATCHCMD is replaced by the patches commands if value is yes
604#filter PBPATCHCMD = yes
605
606# PBMULTISRC is replaced by the sources names if value is yes. Sources are located under the pbsrc dir of the pkg.
607#filter PBMULTISRC = yes
608
609# PBTAG is replaced by the tag (\$pb->{'tag'} in code)
610filter PBTAG = \$pb->{'tag'}
611
612# PBREV is replaced by the revision (\$pb->{'rev'} in code)
613filter PBREV = \$pb->{'rev'}
614
615# PBREALPKG is replaced by the package name (\$pb->{'realpkg'} in code)
616filter PBREALPKG = \$pb->{'realpkg'}
617
618# PBPKG is replaced by the package name (\$pb->{'pkg'} in code)
619filter PBPKG = \$pb->{'pkg'}
620
621# PBPROJ is replaced by the project name (\$pb->{'proj'} in code)
622filter PBPROJ = \$pb->{'proj'}
623
624# PBPACKAGER is replaced by the packager name (\$pb->{'packager'} in code)
625filter PBPACKAGER = \$pb->{'packager'}
626
627# PBDESC contains the description of the package
628#filter PBDESC = Bla-Bla \
629# with a trailing \, the variable can be multi-line. \
630# only the trailing \'s will be removed, the leading spaces, \
631# trailing spaces, and newlines will remain except on the \
632# last line. You can use dollar slash as a way to introduce carraige \
633# return (perl syntax). \
634# You can use transform e.g. in rpm.pbf to adjust spaces
635
636# PBSUMMARY contains a short single line description of the package
637#filter PBSUMMARY = Bla
638
639# PBURL contains the URL of the Web site of the project
640#filter PBURL = http://www.$ENV{'PBPROJ'}.org
641
642# PBLOG is replaced by the changelog if value is yes
643# and should be last as when used we need the %pb hash filled
644#filter PBLOG = yes
645
646EOF
647 close(CONF);
648 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
649 print CONF << "EOF";
650#
651# \$Id\$
652#
653# Filter for rpm build
654#
655
656# PBGRP is replaced by the RPM group of apps
657#filter PBGRP = Applications/Archiving
658
659# PBLIC is replaced by the license of the application
660#filter PBLIC = GPL
661
662# PBDEP is replaced by the list of dependencies
663#filter PBDEP =
664
665# PBBDEP is replaced by the list of build dependencies
666#filter PBBDEP =
667
668# PBSUF is replaced by the package suffix (\$pb->{'suf'} in code)
669filter PBSUF = \$pb->{'suf'}
670
671# PBOBS is replaced by the Obsolete line
672#filter PBOBS =
673
674# transform a variable from the key on the right to the key on the left using the perl expression
675# after the input key name. Useful for taking multi-line documentation and removing trailing spaces
676# or leading spaces.
677#transform PBDESC = PBDESC_raw s/\\s+\\n/\\n/go;
678
679EOF
680 close(CONF);
681 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/fedora.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/fedora.pbf";
682 print CONF << "EOF";
683#
684# \$Id\$
685#
686# Filter for rpm build
687#
688
689# PBGRP is replaced by the RPM group of apps
690# Cf: http://fedoraproject.org/wiki/RPMGroups
691#filter PBGRP = Applications/Archiving
692
693# PBLIC is replaced by the license of the application
694# Cf: http://fedoraproject.org/wiki/Licensing
695#filter PBLIC = GPLv2+
696
697# PBDEP is replaced by the list of dependencies
698#filter PBDEP =
699
700# PBBDEP is replaced by the list of build dependencies
701#filter PBBDEP =
702
703# PBSUF is replaced by the package suffix (\$pb->{'suf'} in code)
704filter PBSUF = %{dist}
705
706# PBOBS is replaced by the Obsolete line
707#filter PBOBS =
708
709EOF
710 close(CONF);
711 foreach my $i (1..7) {
712 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/fedora-$i.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/fedora-$i.pbf";
713 print CONF << "EOF";
714#
715# \$Id\$
716#
717# Filter for old fedora build
718#
719
720# PBSUF is replaced by the package suffix (\$pb->{'suf'} in code)
721filter PBSUF = \$pb->{'suf'}
722
723EOF
724 close(CONF);
725 }
726 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
727 print CONF << "EOF";
728#
729# \$Id\$
730#
731# Filter for debian build
732#
733# PBGRP is replaced by the group of apps
734filter PBGRP = utils
735
736# PBLIC is replaced by the license of the application
737# Cf: http://www.debian.org/legal/licenses/
738#filter PBLIC = GPL
739
740# PBDEP is replaced by the list of dependencies
741#filter PBDEP =
742
743# PBBDEP is replaced by the list of build dependencies
744#filter PBBDEP =
745
746# PBSUG is replaced by the list of suggestions
747#filter PBSUG =
748
749# PBREC is replaced by the list of recommandations
750#filter PBREC =
751
752EOF
753 close(CONF);
754 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/debian-3.1.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/debian-3.1.pbf";
755 print CONF << "EOF";
756#
757# \$Id\$
758#
759# Filter for debian build
760#
761# PBDEBSTD is replaced by the Debian standard version
762filter PBDEBSTD = 3.6.1
763
764# PBDEBCOMP is replaced by the Debian Compatibility value
765filter PBDEBCOMP = 4
766
767EOF
768 close(CONF);
769 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/debian-4.0.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/debian-4.0.pbf";
770 print CONF << "EOF";
771#
772# \$Id\$
773#
774# Filter for debian build
775#
776# PBDEBSTD is replaced by the Debian standard version
777filter PBDEBSTD = 3.6.1
778
779# PBDEBCOMP is replaced by the Debian Compatibility value
780filter PBDEBCOMP = 5
781
782EOF
783 close(CONF);
784 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/debian-5.0.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/debian-5.0.pbf";
785 print CONF << "EOF";
786#
787# \$Id\$
788#
789# Filter for debian build
790#
791# PBDEBSTD is replaced by the Debian standard version
792filter PBDEBSTD = 3.8.0
793
794# PBDEBCOMP is replaced by the Debian Compatibility value
795filter PBDEBCOMP = 7
796
797EOF
798 close(CONF);
799 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/debian-6.0.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/debian-6.0.pbf";
800 print CONF << "EOF";
801#
802# \$Id\$
803#
804# Filter for debian build
805#
806# PBDEBSTD is replaced by the Debian standard version
807filter PBDEBSTD = 3.8.0
808
809# PBDEBCOMP is replaced by the Debian Compatibility value
810filter PBDEBCOMP = 7
811
812EOF
813 close(CONF);
814 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/debian.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/debian.pbf";
815 print CONF << "EOF";
816#
817# \$Id\$
818#
819# Filter for debian build
820#
821# PBDEBSTD is replaced by the Debian standard version
822filter PBDEBSTD = 3.9.4
823
824# PBDEBCOMP is replaced by the Debian Compatibility value
825filter PBDEBCOMP = 9
826
827EOF
828 close(CONF);
829 foreach my $ubv ("ubuntu-6.06.pbf","ubuntu-7.04.pbf","ubuntu-7.10.pbf") {
830 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/$ubv") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/$ubv";
831 print CONF << "EOF";
832#
833# \$Id\$
834#
835# Filter for ubuntu build
836#
837# PBDEBSTD is replaced by the Debian standard version
838filter PBDEBSTD = 3.6.2
839
840# PBDEBCOMP is replaced by the Debian Compatibility value
841filter PBDEBCOMP = 4
842
843EOF
844 close(CONF);
845 }
846 foreach my $ubv ("ubuntu-8.04.pbf","ubuntu-8.10.pbf") {
847 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/$ubv") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/$ubv";
848 print CONF << "EOF";
849#
850# \$Id\$
851#
852# Filter for ubuntu build
853#
854# PBDEBSTD is replaced by the Debian standard version
855filter PBDEBSTD = 3.7.3
856
857# PBDEBCOMP is replaced by the Debian Compatibility value
858filter PBDEBCOMP = 4
859
860EOF
861 close(CONF);
862 }
863 foreach my $ubv ("ubuntu-9.04.pbf") {
864 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/$ubv") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/$ubv";
865 print CONF << "EOF";
866#
867# \$Id\$
868#
869# Filter for ubuntu build
870#
871# PBDEBSTD is replaced by the Debian standard version
872filter PBDEBSTD = 3.8.0
873
874# PBDEBCOMP is replaced by the Debian Compatibility value
875filter PBDEBCOMP = 4
876
877EOF
878 close(CONF);
879 }
880 # 9.10+
881 foreach my $ubv ("ubuntu.pbf") {
882 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/$ubv") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/$ubv";
883 print CONF << "EOF";
884#
885# \$Id\$
886#
887# Filter for ubuntu build
888#
889# PBDEBSTD is replaced by the Debian standard version
890filter PBDEBSTD = 3.8.3
891
892# PBDEBCOMP is replaced by the Debian Compatibility value
893filter PBDEBCOMP = 7
894
895EOF
896 close(CONF);
897 }
898 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
899 print CONF << "EOF";
900# Specific group for Mandriva for $ENV{'PBPROJ'}
901# Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
902#filter PBGRP = Archiving/Backup
903
904# PBLIC is replaced by the license of the application
905# Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses
906#filter PBLIC = GPL
907
908EOF
909 close(CONF);
910 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
911 print CONF << "EOF";
912# Specific group for SuSE for $ENV{'PBPROJ'}
913# Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
914#filter PBGRP = Productivity/Archiving/Backup
915
916# PBLIC is replaced by the license of the application
917# Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag
918#filter PBLIC = GPL
919
920EOF
921 close(CONF);
922 foreach my $pp (@pkgs) {
923 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb");
924 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
925 print CONF << "EOF";
926Source: PBPKG
927# http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
928Section: PBGRP
929Priority: optional
930Maintainer: PBPACKAGER
931Build-Depends: debhelper (>= 4.2.20), PBBDEP
932Standards-Version: PBDEBSTD
933Vcs-Svn: svn://svn.PBPROJ.org/svn/PBVER/PBPKG
934Vcs-Browser: http://trac.PBPROJ.org/browser/PBVER/PBPKG
935Homepage: PBURL
936
937Package: PBPKG
938Architecture: amd64 i386 ia64
939# http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
940Section: PBGRP
941Priority: optional
942Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
943Recommends: PBREC
944Suggests: PBSUG
945Description: PBSUMMARY
946 PBDESC
947 .
948
949EOF
950 close(CONF);
951 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
952 print CONF << "EOF";
953This package is debianized by PBPACKAGER
954`date`
955
956The current upstream source was downloaded from
957PBREPO.
958
959Upstream Authors: Put their name here
960
961Copyright:
962
963 This package is free software; you can redistribute it and/or modify
964 it under the terms of the GNU General Public License as published by
965 the Free Software Foundation; version 2 dated June, 1991.
966
967 This package is distributed in the hope that it will be useful,
968 but WITHOUT ANY WARRANTY; without even the implied warranty of
969 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
970 GNU General Public License for more details.
971
972 You should have received a copy of the GNU General Public License
973 along with this package; if not, write to the Free Software
974 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
975 MA 02110-1301, USA.
976
977On Debian systems, the complete text of the GNU General
978Public License can be found in /usr/share/common-licenses/GPL.
979
980EOF
981 close(CONF);
982 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
983 print CONF << "EOF";
984PBLOG
985EOF
986 close(CONF);
987 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
988 print CONF << "EOF";
989PBDEBCOMP
990EOF
991 close(CONF);
992 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
993 print CONF << "EOF";
994EOF
995 close(CONF);
996 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
997 print CONF << "EOF";
998INSTALL
999COPYING
1000AUTHORS
1001NEWS
1002README
1003EOF
1004 close(CONF);
1005 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
1006 print CONF << 'EOF';
1007#!/usr/bin/make -f
1008# -*- makefile -*-
1009# Sample debian/rules that uses debhelper.
1010# GNU copyright 1997 to 1999 by Joey Hess.
1011#
1012# $Id$
1013#
1014
1015# Uncomment this to turn on verbose mode.
1016#export DH_VERBOSE=1
1017
1018# Define package name variable for a one-stop change.
1019PACKAGE_NAME = PBPKG
1020
1021# These are used for cross-compiling and for saving the configure script
1022# from having to guess our platform (since we know it already)
1023DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
1024DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
1025
1026CFLAGS = -Wall -g
1027
1028ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
1029 CFLAGS += -O0
1030else
1031 CFLAGS += -O2
1032endif
1033ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
1034 INSTALL_PROGRAM += -s
1035endif
1036
1037config.status: configure
1038 dh_testdir
1039
1040 # Configure the package.
1041 CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man
1042
1043# Build both architecture dependent and independent
1044build: build-arch build-indep
1045
1046# Build architecture dependent
1047build-arch: build-arch-stamp
1048
1049build-arch-stamp: config.status
1050 dh_testdir
1051
1052 # Compile the package.
1053 $(MAKE)
1054
1055 touch build-stamp
1056
1057# Build architecture independent
1058build-indep: build-indep-stamp
1059
1060build-indep-stamp: config.status
1061 # Nothing to do, the only indep item is the manual which is available as html in original source
1062 touch build-indep-stamp
1063
1064# Clean up
1065clean:
1066 dh_testdir
1067 dh_testroot
1068 rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
1069 # Clean temporary document directory
1070 rm -rf debian/doc-temp
1071 # Clean up.
1072 -$(MAKE) distclean
1073 rm -f config.log
1074ifneq "$(wildcard /usr/share/misc/config.sub)" ""
1075 cp -f /usr/share/misc/config.sub config.sub
1076endif
1077ifneq "$(wildcard /usr/share/misc/config.guess)" ""
1078 cp -f /usr/share/misc/config.guess config.guess
1079endif
1080
1081 dh_clean
1082
1083# Install architecture dependent and independent
1084install: install-arch install-indep
1085
1086# Install architecture dependent
1087install-arch: build-arch
1088 dh_testdir
1089 dh_testroot
1090 dh_clean -k -s
1091 dh_installdirs -s
1092
1093 # Install the package files into build directory:
1094 # - start with upstream make install
1095 $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/usr/share/man
1096 # - copy html manual to temporary location for renaming
1097 mkdir -p debian/doc-temp
1098 dh_install -s
1099
1100# Install architecture independent
1101install-indep: build-indep
1102 dh_testdir
1103 dh_testroot
1104 dh_clean -k -i
1105 dh_installdirs -i
1106 dh_install -i
1107
1108# Must not depend on anything. This is to be called by
1109# binary-arch/binary-indep
1110# in another 'make' thread.
1111binary-common:
1112 dh_testdir
1113 dh_testroot
1114 dh_installchangelogs ChangeLog
1115 dh_installdocs
1116 dh_installman
1117 dh_link
1118 dh_strip
1119 dh_compress
1120 dh_fixperms
1121 dh_installdeb
1122 dh_shlibdeps
1123 dh_gencontrol
1124 dh_md5sums
1125 dh_builddeb
1126
1127# Build architecture independant packages using the common target.
1128binary-indep: build-indep install-indep
1129 $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
1130
1131# Build architecture dependant packages using the common target.
1132binary-arch: build-arch install-arch
1133 $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
1134
1135# Build architecture depdendent and independent packages
1136binary: binary-arch binary-indep
1137.PHONY: clean binary
1138
1139EOF
1140 close(CONF);
1141 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm");
1142 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
1143 print CONF << 'EOF';
1144#
1145# $Id$
1146#
1147# Used if virtual name != real name (perl, ...) - replace PBPKG by PBREALPKG in the line below
1148%define srcname PBPKG
1149
1150Summary: PBSUMMARY
1151Summary(fr): french bla-bla
1152
1153Name: PBREALPKG
1154Version: PBVER
1155Release: PBTAGPBSUF
1156License: PBLIC
1157Group: PBGRP
1158Url: PBURL
1159Source: PBREPO/PBSRC
1160#PBPATCHSRC
1161BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
1162#Requires: PBDEP
1163#BuildRequires: PBBDEP
1164
1165%description
1166PBDESC
1167
1168%description -l fr
1169french desc
1170
1171%prep
1172%setup -q %{name}-%{version}PBEXTDIR
1173# Used if virtual name != real name (perl, ...)
1174#%setup -q -n %{srcname}-%{version}PBEXTDIR
1175#PBPATCHCMD
1176
1177%build
1178%configure
1179make %{?_smp_mflags}
1180
1181%install
1182%{__rm} -rf $RPM_BUILD_ROOT
1183make DESTDIR=$RPM_BUILD_ROOT install
1184
1185%clean
1186%{__rm} -rf $RPM_BUILD_ROOT
1187
1188%files
1189%defattr(-,root,root)
1190%doc ChangeLog
1191%doc INSTALL COPYING README AUTHORS NEWS
1192
1193%changelog
1194PBLOG
1195
1196EOF
1197 close(CONF);
1198 open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/pkg.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/pkg.pbf";
1199 print CONF << "EOF";
1200#
1201# \$Id\$
1202#
1203# Filter for pkg build
1204#
1205# Solaris package name (VENDOR : 4 letters in uppercase, SOFT : 8 letters in lowercase)
1206filter PBSOLPKG = SUNWsoftware
1207
1208EOF
1209 close(CONF);
1210 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter");
1211 pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pkg");
1212 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/pkg/pkginfo") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pkg/pkginfo";
1213 print CONF << 'EOF';
1214#
1215# $Id$
1216#
1217PKG="PBSOLPKG"
1218NAME="PBREALPKG"
1219VERSION="PBVER"
1220# all or i386
1221ARCH="all"
1222CATEGORY="application"
1223DESC="PBSUMMARY"
1224EMAIL="PBPACKAGER"
1225VENDOR="PBPACKAGER"
1226HOTLINE="PBURL"
1227EOF
1228 close(CONF);
1229 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/pkg/pbbuild") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pkg/pbbuild";
1230 print CONF << 'EOF';
1231#
1232# $Id$
1233#
1234#perl Makefile.PL INSTALLDIRS=vendor
1235./configure --prefix=/usr
1236make
1237make install DESTDIR=\$1
1238EOF
1239 close(CONF);
1240 open(CONF,"> $ENV{'PBROOTDIR'}/$pp/pkg/depend") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pkg/depend";
1241 print CONF << 'EOF';
1242#
1243# $Id$
1244#
1245#P SUNWperl584core Perl 5.8.4 (core)
1246EOF
1247 close(CONF);
1248
1249 }
1250 pb_vcs_add($pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONFDIR'});
1251 my $msg = "updated to ".basename("$ENV{'PBPROJDIR'}");
1252 $msg = "Project $ENV{'PBPROJ'} creation" if (defined $pbinit);
1253 pb_vcs_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBPROJDIR'}",$msg);
1254 } else {
1255 pb_log(0,"ERROR: no pbroot defined, used $ENV{'PBROOTDIR'}, without finding $ENV{'PBPROJ'}.pb in it\n");
1256 pb_log(0," Please use -r release in order to be able to initialize your environment correctly\n");
1257 die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
1258 }
1259 }
1260 umask 0022;
1261 return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
1262} elsif ($action =~ /^(newv|setupv)/) {
1263 # No PBDESTDIR yet so doing nothing
1264 return;
1265} else {
1266 # Setup the variables from what has been stored at the end of cms2build
1267 my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
1268 $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
1269
1270 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
1271 $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
1272
1273 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
1274 $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
1275
1276 ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
1277 $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
1278
1279 return;
1280}
1281}
1282
1283=head1 WEB SITES
1284
1285The 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/>.
1286
1287=head1 USER MAILING LIST
1288
1289None exists for the moment.
1290
1291=head1 AUTHORS
1292
1293The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
1294
1295=head1 COPYRIGHT
1296
1297Project-Builder.org is distributed under the GPL v2.0 license
1298described in the file C<COPYING> included with the distribution.
1299
1300=cut
1301
13021;
Note: See TracBrowser for help on using the repository browser.