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

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

More YAML transformations

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