source: devel/pb/lib/ProjectBuilder/Env.pm @ 452

Revision 452, 27.3 KB checked in by bruno, 5 years ago (diff)
  • Make newproj action work again
  • Add pb_cms_add function
  • Change interface of pb_cms_checkin (third param)
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# $Id$
8#
9# Copyright B. Cornec 2007
10# Provided under the GPL v2
11
12package ProjectBuilder::Env;
13
14use strict 'vars';
15use Data::Dumper;
16use English;
17use File::Basename;
18use File::stat;
19use POSIX qw(strftime);
20use lib qw (lib);
21use ProjectBuilder::Base;
22use ProjectBuilder::Conf;
23use ProjectBuilder::CMS;
24
25# Inherit from the "Exporter" module which handles exporting functions.
26 
27use Exporter;
28 
29# Export, by default, all the functions into the namespace of
30# any code which uses this module.
31 
32our @ISA = qw(Exporter);
33our @EXPORT = qw(pb_env_init);
34
35=pod
36
37=head1 NAME
38
39ProjectBuilder::Env, part of the project-builder.org
40
41=head1 DESCRIPTION
42
43This modules provides environment functions suitable for pbinit calls.
44
45=head1 USAGE
46
47=over 4
48
49=item B<pb_env_init>
50
51This function setup the environment for project-builder.
52The first parameter is the project if givent on the command line.
53The second parameter is a flag indicating whether we should setup up the pbconf environment or not.
54The third parameter is the action passed to bp.
55It sets up environement variables (PBETC, PBPROJ, PBDEFDIR, PBBUILDDIR, PBROOTDIR, PBDESTDIR, PBCONFDIR, PBPROJVER)
56
57=cut
58
59sub pb_env_init {
60
61my $proj=shift || undef;
62my $pbinit=shift || undef;
63my $action=shift;
64my $ver;
65my $tag;
66
67$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
68
69# We only have one configuration file for now.
70pb_conf_add("$ENV{'PBETC'}");
71
72#
73# Check project name
74# Could be with env var PBPROJ
75# or option -p
76# if not define take the first in conf file
77#
78if ((defined $ENV{'PBPROJ'}) &&
79        (not (defined $proj))) {
80        $proj = $ENV{'PBPROJ'};
81}
82
83#
84# We get the pbconf file for that project
85# and use its content
86#
87my ($pbconf) = pb_conf_get("pbconfurl");
88pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
89
90my %pbconf = %$pbconf;
91if (not defined $proj) {
92        # Take the first as the default project
93        $proj = (keys %pbconf)[0];
94        if (defined $proj) {
95                pb_log(1,"WARNING: using $proj as default project as none has been specified\n");
96                pb_log(1,"         Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
97                pb_log(1,"         or call pb with the -p project option or use the env var PBPROJ\n");
98                pb_log(1,"         if you want to use another project\n");
99        }
100}
101die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
102
103# That's always the environment variable that will be used
104$ENV{'PBPROJ'} = $proj;
105pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
106
107if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
108        die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
109}
110
111# Adds a potential conf file now as it's more
112# important than the project conf file
113my ($vmpath,$vepath) = pb_conf_get("vmpath","vepath");
114pb_conf_add("$vmpath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vmpath->{$ENV{'PBPROJ'}}/.pbrc");
115pb_conf_add("$vepath->{$ENV{'PBPROJ'}}/.pbrc") if (-f "$vepath->{$ENV{'PBPROJ'}}/.pbrc");
116
117#
118# Detect the root dir for hosting all the content generated with pb
119#
120# Tree will look like this:
121#
122#             maint pbdefdir                         PBDEFDIR            dev dir (optional)
123#                  |                                                        |
124#            ------------------------                                --------------------
125#            |                      |                                |                  |
126#         pbproj1                pbproj2             PBPROJ       pbproj1           pbproj2   PBPROJDIR
127#            |                                                       |
128#  ---------------------------------------------                ----------
129#  *      *        *       |        |          |                *        *
130# tag    dev    pbconf    ...     build     delivery PBCONFDIR dev      tag                 
131#  |               |                           |     PBDESTDIR           |
132#  ---          ------                        pbrc   PBBUILDDIR       -------
133#    |          |    |                                                |     |
134#   1.1        dev  tag                                              1.0   1.1                PBDIR
135#                    |
136#                 -------
137#                 |     |
138#                1.0   1.1                           PBROOTDIR
139#                       |
140#               ----------------------------------
141#               |          |           |         |
142#             pkg1      pbproj1.pb   pbfilter   pbcl
143#               |
144#        -----------------
145#        |      |        |
146#       rpm    deb    pbfilter
147#
148#
149# (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
150# Names under a pbproj and the corresponding pbconf should be similar
151#
152
153my ($pbdefdir) = pb_conf_get_if("pbdefdir");
154
155if (not defined $ENV{'PBDEFDIR'}) {
156        if ((not defined $pbdefdir) || (not defined $pbdefdir->{$ENV{'PBPROJ'}})) {
157                pb_log(1,"WARNING: no pbdefdir defined, using /var/cache\n");
158                pb_log(1,"         Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
159                pb_log(1,"         if you want to use another directory\n");
160                $ENV{'PBDEFDIR'} = "/var/cache";
161        } else {
162                # That's always the environment variable that will be used
163                $ENV{'PBDEFDIR'} = $pbdefdir->{$ENV{'PBPROJ'}};
164        }
165}
166# Expand potential env variable in it
167eval { $ENV{'PBDEFDIR'} =~ s/(\$ENV.+\})/$1/eeg };
168
169pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n");
170
171# Put under CMS the PBPROJ dir
172if (defined $pbinit) {
173        if (! -d "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}") {
174                pb_mkdir_p("$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}") || die "Unable to recursively create $ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";
175        }
176        pb_cms_add($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}");
177}
178
179#
180# Set delivery directory
181#
182$ENV{'PBDESTDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/delivery";
183
184pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n");
185#
186# Removes all directory existing below the delivery dir
187# as they are temp dir only except when called from pbinit
188# Files stay and have to be cleaned up manually if needed
189# those files serves as communication channels between pb phases
190# Removing them prevents a following phase to detect what has been done before
191#
192if ((-d $ENV{'PBDESTDIR'}) && ($action !~ /pbinit/)) {
193        opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
194        foreach my $d (readdir(DIR)) {
195                next if ($d =~ /^\./);
196                next if (-f "$ENV{'PBDESTDIR'}/$d");
197                pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
198        }
199        closedir(DIR);
200}
201if (! -d "$ENV{'PBDESTDIR'}") {
202        pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
203}
204
205#
206# Set build directory
207#
208$ENV{'PBBUILDDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/build";
209if (! -d "$ENV{'PBBUILDDIR'}") {
210        pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
211}
212
213pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
214
215pb_temp_init();
216pb_log(2,"PBTMP: $ENV{'PBTMP'}\n");
217
218#
219# The following part is only useful when in cms2something of newver
220# In VMs/VEs we want to skip that by providing good env vars.
221# return values in that case are useless
222#
223if (($action =~ /^cms2/) || ($action =~ /^newver$/) || ($action =~ /pbinit/) || ($action =~ /^newproj$/)) {
224
225        #
226        # Check pbconf cms compliance
227        #
228        pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
229
230        # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
231        #
232        if (not defined $ENV{'PBROOTDIR'}) {
233                if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
234                        opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
235                        my $maxmtime = 0;
236                        foreach my $d (readdir(DIR)) {
237                                pb_log(3,"Looking at \'$d\'...");
238                                next if ($d =~ /^\./);
239                                next if (! -d "$ENV{'PBCONFDIR'}/$d");
240                                my $s = stat("$ENV{'PBCONFDIR'}/$d");
241                                next if (not defined $s);
242                                pb_log(3,"KEEP\n");
243                                # Keep the most recent
244                                pb_log(2," $s->mtime\n");
245                                if ($s->mtime > $maxmtime) {
246                                        $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
247                                        $maxmtime = $s->mtime;
248                                }
249                        }
250                        closedir(DIR);
251                        pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
252                        pb_log(1,"         Please use -r release if you want to use another release\n");
253                        die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
254                } else {
255                        my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
256                        # That's always the environment variable that will be used
257                        die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
258                        $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
259                }
260        } else {
261                # transform in full path if relative
262                $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
263                pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
264                die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
265        }
266
267        # Adds that conf file to the list to consider
268        pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb");
269
270        return if ($action =~ /^newver$/);
271
272        my %version = ();
273        my %defpkgdir = ();
274        my %extpkgdir = ();
275        my %filteredfiles = ();
276        my %supfiles = ();
277       
278        if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
279
280                # List of pkg to build by default (mandatory)
281                my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
282                # List of additional pkg to build when all is called (optional)
283                # Valid version names (optional)
284                # List of files to filter (optional)
285                # Project version and tag (optional)
286                my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
287                pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
288                pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
289                pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
290                pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
291                pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
292                # Global
293                %defpkgdir = %$defpkgdir;
294                %extpkgdir = %$extpkgdir if (defined $extpkgdir);
295                %version = %$version if (defined $version);
296                %filteredfiles = %$filteredfiles if (defined $filteredfiles);
297                %supfiles = %$supfiles if (defined $supfiles);
298                #
299                # Get global Version/Tag
300                #
301                if (not defined $ENV{'PBPROJVER'}) {
302                        if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
303                                $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
304                        } else {
305                                die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
306                        }
307                }
308                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'}}/));
309               
310                if (not defined $ENV{'PBPROJTAG'}) {
311                        if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
312                                $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
313                        } else {
314                                die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
315                        }
316                }
317                die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
318       
319       
320                if (not defined $ENV{'PBPACKAGER'}) {
321                        if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
322                                $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
323                        } else {
324                                die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
325                        }
326                }
327        } else {
328                if (defined $pbinit) {
329                        my @pkgs = @ARGV;
330                        @pkgs = ("pkg1") if (not @pkgs);
331       
332                        open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
333                        print CONF << "EOF";
334#
335# Project Builder configuration file
336# For project $ENV{'PBPROJ'}
337#
338# \$Id\$
339#
340
341#
342# What is the project URL
343#
344#pburl $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
345#pburl $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
346#pburl $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
347#pburl $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
348#pburl $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
349#pburl $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
350#pburl $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
351
352# Check whether project is well formed
353# (containing already a directory with the project-version name)
354#pbwf $ENV{'PBPROJ'} = 1
355
356#
357# Packager label
358#
359#pbpackager $ENV{'PBPROJ'} = William Porte <bill\@$ENV{'PBPROJ'}.org>
360#
361
362# For delivery to a machine by SSH (potentially the FTP server)
363# Needs hostname, account and directory
364#
365#sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
366#sshlogin $ENV{'PBPROJ'} = bill
367#sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
368#sshport $ENV{'PBPROJ'} = 22
369
370#
371# For Virtual machines management
372# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
373# followed by '-' and by release number
374# followed by '-' and by architecture
375# a .vmtype extension will be added to the resulting string
376# a QEMU rhel-3-i286 here means that the VM will be named rhel-3-i386.qemu
377#
378#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
379
380#
381# Valid values for vmtype are
382# qemu, (vmware, xen, ... TBD)
383#vmtype $ENV{'PBPROJ'} = qemu
384
385# Hash for VM stuff on vmtype
386#vmntp default = pool.ntp.org
387
388# We suppose we can commmunicate with the VM through SSH
389#vmhost $ENV{'PBPROJ'} = localhost
390#vmlogin $ENV{'PBPROJ'} = pb
391#vmport $ENV{'PBPROJ'} = 2222
392
393# Timeout to wait when VM is launched/stopped
394#vmtmout default = 120
395
396# per VMs needed paramaters
397#vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
398#vmpath $ENV{'PBPROJ'} = /home/qemu
399#vmsize $ENV{'PBPROJ'} = 5G
400
401#
402# For Virtual environment management
403# Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
404# followed by '-' and by release number
405# followed by '-' and by architecture
406# a .vetype extension will be added to the resulting string
407# a chroot rhel-3-i286 here means that the VE will be named rhel-3-i386.chroot
408#
409#velist $ENV{'PBPROJ'} = fedora-7-i386
410
411# VE params
412#vetype $ENV{'PBPROJ'} = chroot
413#ventp default = pool.ntp.org
414#velogin $ENV{'PBPROJ'} = pb
415#vepath $ENV{'PBPROJ'} = /var/lib/mock
416#veconf $ENV{'PBPROJ'} = /etc/mock
417#verebuild $ENV{'PBPROJ'} = false
418
419#
420# Global version/tag for the project
421#
422#projver $ENV{'PBPROJ'} = devel
423#projtag $ENV{'PBPROJ'} = 1
424
425# Hash of valid version names
426#version $ENV{'PBPROJ'} = devel,stable
427
428# Adapt to your needs:
429# Optional if you need to overwrite the global values above
430#
431EOF
432               
433                        foreach my $pp (@pkgs) {
434                                print CONF << "EOF";
435#pkgver $pp = stable
436#pkgtag $pp = 3
437EOF
438                        }
439                        foreach my $pp (@pkgs) {
440                                print CONF << "EOF";
441# Hash of default package/package directory
442#defpkgdir $pp = dir-$pp
443EOF
444                        }
445       
446                        print CONF << "EOF";
447# Hash of additional package/package directory
448#extpkgdir minor-pkg = dir-minor-pkg
449
450# List of files per pkg on which to apply filters
451# Files are mentioned relatively to pbroot/defpkgdir
452EOF
453                        foreach my $pp (@pkgs) {
454                                print CONF << "EOF";
455#filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
456#supfiles $pp = $pp.init
457EOF
458                        }
459                        close(CONF);
460                        pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
461                        open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
462                        print CONF << "EOF";
463#
464# \$Id\$
465#
466# Filter for all files
467#
468#
469# PBREPO is replaced by the root URL to access the repository
470filter PBREPO = \$pbrepo
471
472# PBSRC is replaced by the source package location after the repo
473#filter PBSRC = src/%{name}-%{version}.tar.gz
474
475# PBVER is replaced by the version (\$pbver in code)
476filter PBVER = \$pbver
477
478# PBDATE is replaced by the date (\$pbdate in code)
479filter PBDATE = \$pbdate
480
481# PBLOG is replaced by the changelog if value is yes
482#filter PBLOG = yes
483
484# PBTAG is replaced by the tag (\$pbtag in code)
485filter PBTAG = \$pbtag
486
487# PBREV is replaced by the revision (\$pbrev in code)
488filter PBREV = \$pbrev
489
490# PBPKG is replaced by the package name (\$pbpkg in code)
491filter PBPKG = \$pbpkg
492
493# PBPACKAGER is replaced by the packager name (\$pbpackager in code)
494filter PBPACKAGER = \$pbpackager
495
496# PBDESC contains the description of the package
497#filter PBDESC = "Bla-Bla"
498
499# PBURL contains the URL of the Web site of the project
500#filter PBURL = http://www.$ENV{'PBPROJ'}.org
501EOF
502                        close(CONF);
503                        open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
504                        print CONF << "EOF";
505#
506# \$Id\$
507#
508# Filter for rpm build
509#
510
511# PBGRP is replaced by the RPM group of apps
512# Cf: http://fedoraproject.org/wiki/RPMGroups
513#filter PBGRP = Applications/Archiving
514
515# PBLIC is replaced by the license of the application
516# Cf: http://fedoraproject.org/wiki/Licensing
517#filter PBLIC = GPL
518
519# PBDEP is replaced by the list of dependencies
520#filter PBDEP =
521
522# PBSUF is replaced by the package suffix (\$pbsuf in code)
523filter PBSUF = \$pbsuf
524
525# PBOBS is replaced by the Obsolete line
526#filter PBOBS =
527
528EOF
529                        close(CONF);
530                        open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
531                        print CONF << "EOF";
532#
533# \$Id\$
534#
535# Filter for debian build
536#
537# PBGRP is replaced by the group of apps
538filter PBGRP = utils
539
540# PBLIC is replaced by the license of the application
541# Cf:
542#filter PBLIC = GPL
543
544# PBDEP is replaced by the list of dependencies
545#filter PBDEP =
546
547# PBSUG is replaced by the list of suggestions
548#filter PBSUG =
549
550# PBREC is replaced by the list of recommandations
551#filter PBREC =
552
553EOF
554                        close(CONF);
555                        open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
556                        print CONF << "EOF";
557# Specific group for Mandriva for $ENV{'PBPROJ'}
558# Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
559#filter PBGRP = Archiving/Backup
560
561# PBLIC is replaced by the license of the application
562# Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses
563#filter PBLIC = GPL
564
565EOF
566                        close(CONF);
567                        open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
568                        print CONF << "EOF";
569# Specific group for SuSE for $ENV{'PBPROJ'}
570# Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
571#filter PBGRP = Productivity/Archiving/Backup
572
573# PBLIC is replaced by the license of the application
574# Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag
575#filter PBLIC = GPL
576
577EOF
578                        close(CONF);
579                        foreach my $pp (@pkgs) {
580                                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
581                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
582                                print CONF << "EOF";
583Source: PBPKG
584Section: PBGRP
585Priority: optional
586Maintainer: PBPACKAGER
587Build-Depends: debhelper (>= 4.2.20), PBDEP
588Standards-Version: 3.6.1
589
590Package: PBPKG
591Architecture: amd64 i386 ia64
592Section: PBGRP
593Priority: optional
594Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
595Recommends: PBREC
596Suggests: PBSUG
597Description:
598 PBDESC
599 .
600 Homepage: PBURL
601
602EOF
603                                close(CONF);
604                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
605                                print CONF << "EOF";
606This package is debianized by PBPACKAGER
607`date`
608
609The current upstream source was downloaded from
610PBREPO.
611
612Upstream Authors: Put their name here
613
614Copyright:
615
616   This package is free software; you can redistribute it and/or modify
617   it under the terms of the GNU General Public License as published by
618   the Free Software Foundation; version 2 dated June, 1991.
619
620   This package is distributed in the hope that it will be useful,
621   but WITHOUT ANY WARRANTY; without even the implied warranty of
622   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
623   GNU General Public License for more details.
624
625   You should have received a copy of the GNU General Public License
626   along with this package; if not, write to the Free Software
627   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
628   MA 02110-1301, USA.
629
630On Debian systems, the complete text of the GNU General
631Public License can be found in /usr/share/common-licenses/GPL.
632
633EOF
634                                close(CONF);
635                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
636                                print CONF << "EOF";
637PBLOG
638EOF
639                                close(CONF);
640                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
641                                print CONF << "EOF";
6424
643EOF
644                                close(CONF);
645                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
646                                print CONF << "EOF";
647EOF
648                                close(CONF);
649                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
650                                print CONF << "EOF";
651INSTALL
652COPYING
653AUTHORS
654NEWS
655README
656EOF
657                                close(CONF);
658                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
659                                print CONF << 'EOF';
660#!/usr/bin/make -f
661# -*- makefile -*-
662# Sample debian/rules that uses debhelper.
663# GNU copyright 1997 to 1999 by Joey Hess.
664#
665# $Id$
666#
667
668# Uncomment this to turn on verbose mode.
669#export DH_VERBOSE=1
670
671# Define package name variable for a one-stop change.
672PACKAGE_NAME = PBPKG
673
674# These are used for cross-compiling and for saving the configure script
675# from having to guess our platform (since we know it already)
676DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
677DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
678
679CFLAGS = -Wall -g
680
681ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
682        CFLAGS += -O0
683else
684        CFLAGS += -O2
685endif
686ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
687        INSTALL_PROGRAM += -s
688endif
689config.status: configure
690        dh_testdir
691
692        # Configure the package.
693        CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
694 --mandir=\$${prefix}/share/man
695
696# Build both architecture dependent and independent
697build: build-arch build-indep
698
699# Build architecture dependent
700build-arch: build-arch-stamp
701
702build-arch-stamp:  config.status
703        dh_testdir
704
705        # Compile the package.
706        $(MAKE)
707
708        touch build-stamp
709
710# Build architecture independent
711build-indep: build-indep-stamp
712
713build-indep-stamp:  config.status
714        # Nothing to do, the only indep item is the manual which is available as html in original source
715        touch build-indep-stamp
716
717# Clean up
718clean:
719        dh_testdir
720        dh_testroot
721        rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
722        # Clean temporary document directory
723        rm -rf debian/doc-temp
724        # Clean up.
725        -$(MAKE) distclean
726        rm -f config.log
727ifneq "$(wildcard /usr/share/misc/config.sub)" ""
728        cp -f /usr/share/misc/config.sub config.sub
729endif
730ifneq "$(wildcard /usr/share/misc/config.guess)" ""
731        cp -f /usr/share/misc/config.guess config.guess
732endif
733
734        dh_clean
735
736# Install architecture dependent and independent
737install: install-arch install-indep
738
739# Install architecture dependent
740install-arch: build-arch
741        dh_testdir
742        dh_testroot
743        dh_clean -k -s
744        dh_installdirs -s
745
746        # Install the package files into build directory:
747        # - start with upstream make install
748        $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
749r/share/man
750        # - copy html manual to temporary location for renaming
751        mkdir -p debian/doc-temp
752        dh_install -s
753
754# Install architecture independent
755install-indep: build-indep
756        dh_testdir
757        dh_testroot
758        dh_clean -k -i
759        dh_installdirs -i
760        dh_install -i
761
762# Must not depend on anything. This is to be called by
763# binary-arch/binary-indep
764# in another 'make' thread.
765binary-common:
766        dh_testdir
767        dh_testroot
768        dh_installchangelogs ChangeLog
769        dh_installdocs
770        dh_installman
771        dh_link
772        dh_strip
773        dh_compress
774        dh_fixperms
775        dh_installdeb
776        dh_shlibdeps
777        dh_gencontrol
778        dh_md5sums
779        dh_builddeb
780
781# Build architecture independant packages using the common target.
782binary-indep: build-indep install-indep
783        $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
784
785# Build architecture dependant packages using the common target.
786binary-arch: build-arch install-arch
787        $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
788
789# Build architecture depdendent and independent packages
790binary: binary-arch binary-indep
791.PHONY: clean binary
792
793EOF
794                                close(CONF);
795                                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
796                                open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
797                                print CONF << 'EOF';
798#
799# $Id$
800#
801
802Summary:        bla-bla
803Summary(fr):    french bla-bla
804
805Name:           PBPKG
806Version:        PBVER
807Release:        PBTAGPBSUF
808License:        PBLIC
809Group:          PBGRP
810Url:            PBURL
811Source:         PBREPO/PBSRC
812BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
813#Requires:       PBDEP
814
815%description
816PBDESC
817
818%description -l fr
819french desc
820
821%prep
822%setup -q
823
824%build
825%configure
826make %{?_smp_mflags}
827
828%install
829%{__rm} -rf $RPM_BUILD_ROOT
830make DESTDIR=$RPM_BUILD_ROOT install
831
832%clean
833%{__rm} -rf $RPM_BUILD_ROOT
834
835%files
836%defattr(-,root,root)
837%doc ChangeLog
838%doc INSTALL COPYING README AUTHORS NEWS
839
840%changelog
841PBLOG
842
843EOF
844                                close(CONF);
845                                pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
846       
847                        }
848                        pb_cms_add($pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONFDIR'});
849                        pb_cms_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}",$pbinit);
850                } else {
851                        die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
852                }
853        }
854        umask 0022;
855        return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
856} else {
857        # Setup the variables from what has been stored at the end of cms2build
858        my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
859        $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
860
861        ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
862        $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
863
864        ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
865        $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
866
867        ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
868        $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
869
870        return;
871}
872}
873
874=back
875
876=head1 WEB SITES
877
878The 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/>.
879
880=head1 USER MAILING LIST
881
882None exists for the moment.
883
884=head1 AUTHORS
885
886The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
887
888=head1 COPYRIGHT
889
890Project-Builder.org is distributed under the GPL v2.0 license
891described in the file C<COPYING> included with the distribution.
892
893=cut
894
8951;
Note: See TracBrowser for help on using the repository browser.