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

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