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

Last change on this file since 2309 was 2309, checked in by bruno, 2 years ago

Remove useless code

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