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

Last change on this file since 2435 was 2435, checked in by Bruno Cornec, 5 years ago

docker also requires some initializations

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