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

Last change on this file was 2659, checked in by Bruno Cornec, 3 years ago

Fix some wrong mageia URLs

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