[2] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
[74] | 3 | # Base subroutines for the Project-Builder project
|
---|
[2] | 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 |
|
---|
[18] | 8 | use strict;
|
---|
[5] | 9 | use lib qw (lib);
|
---|
[2] | 10 | use File::Basename;
|
---|
[9] | 11 | use File::Path;
|
---|
[2] | 12 | use File::Temp qw /tempdir/;
|
---|
[74] | 13 | use AppConfig qw(ARGCOUNT_HASH);
|
---|
[8] | 14 | use Data::Dumper;
|
---|
[2] | 15 |
|
---|
[199] | 16 | use ProjectBuilder::Changelog qw (pb_changelog);
|
---|
| 17 |
|
---|
[49] | 18 | $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
|
---|
[5] | 19 |
|
---|
[74] | 20 | sub pb_env_init {
|
---|
[2] | 21 |
|
---|
[273] | 22 | my $proj=shift || undef;
|
---|
| 23 | my $pbinit=shift || undef;
|
---|
[5] | 24 | my $ver;
|
---|
| 25 | my $tag;
|
---|
[2] | 26 |
|
---|
[107] | 27 | # For the moment not dynamic
|
---|
| 28 | my $debug = 0; # Debug level
|
---|
| 29 | my $LOG = *STDOUT; # Where to log
|
---|
| 30 |
|
---|
[8] | 31 | #
|
---|
[5] | 32 | # Check project name
|
---|
[49] | 33 | # Could be with env var PBPROJ
|
---|
| 34 | # or option -p
|
---|
| 35 | # if not define take the first in conf file
|
---|
[8] | 36 | #
|
---|
[5] | 37 | if ((defined $ENV{'PBPROJ'}) &&
|
---|
| 38 | (not (defined $proj))) {
|
---|
| 39 | $proj = $ENV{'PBPROJ'};
|
---|
| 40 | }
|
---|
[69] | 41 |
|
---|
[49] | 42 | #
|
---|
[69] | 43 | # We get the pbrc file for that project
|
---|
| 44 | # and use its content
|
---|
| 45 | #
|
---|
[89] | 46 | my ($pbrc) = pb_conf_read("$ENV{'PBETC'}","pbrc");
|
---|
[74] | 47 | print "DEBUG pbrc: ".Dumper($pbrc)."\n" if ($debug >= 1);
|
---|
[69] | 48 |
|
---|
[108] | 49 | my %pbrc = %$pbrc;
|
---|
[69] | 50 | if (not defined $proj) {
|
---|
| 51 | # Take the first as the default project
|
---|
| 52 | $proj = (keys %pbrc)[0];
|
---|
| 53 | print $LOG "Using $proj as default project as none has been specified\n" if (($debug >= 0) and (defined $proj));
|
---|
| 54 | }
|
---|
| 55 | die "No project defined - use env var PBPROJ or -p proj" if (not (defined $proj));
|
---|
| 56 |
|
---|
| 57 | #
|
---|
| 58 | # Set delivery directory
|
---|
| 59 | #
|
---|
[273] | 60 | if (not defined ($pbrc{$proj})) {
|
---|
| 61 | die "Please create a pbrc reference for project $proj in $ENV{'PBETC'}\n";
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[71] | 64 | my $topdir=dirname($pbrc{$proj});
|
---|
[108] | 65 | # Expand potential env variable in it
|
---|
| 66 | eval { $topdir =~ s/(\$ENV.+\})/$1/eeg };
|
---|
[69] | 67 | chdir $topdir || die "Unable to change directory to $topdir";
|
---|
[108] | 68 | $pbrc{$proj} = $topdir."/pbrc";
|
---|
[69] | 69 | $ENV{'PBDESTDIR'}=$topdir."/delivery";
|
---|
| 70 |
|
---|
| 71 | #
|
---|
[67] | 72 | # Use project configuration file if needed
|
---|
[49] | 73 | #
|
---|
[67] | 74 | if (not defined $ENV{'PBROOT'}) {
|
---|
[69] | 75 | if (-f $pbrc{$proj}) {
|
---|
[89] | 76 | my ($pbroot) = pb_conf_read($pbrc{$proj},"pbroot");
|
---|
[71] | 77 | my %pbroot = %$pbroot;
|
---|
[77] | 78 | # All lines should point to the same pbroot so take the first
|
---|
[69] | 79 | $ENV{'PBROOT'} = (values %$pbroot)[0] if (defined $pbroot);
|
---|
| 80 | print $LOG "Using $ENV{'PBROOT'} as default pbroot from $pbrc{$proj}\n" if (($debug >= 0) and (defined $ENV{'PBROOT'}));
|
---|
[67] | 81 | }
|
---|
[69] | 82 | die "No pbroot defined - use env var PBROOT or -r pbroot " if (not defined $ENV{'PBROOT'});
|
---|
[49] | 83 | }
|
---|
[2] | 84 |
|
---|
[8] | 85 | #
|
---|
[49] | 86 | # Check pb conf compliance
|
---|
[8] | 87 | #
|
---|
[49] | 88 | $ENV{'PBCONF'} = "$ENV{'PBROOT'}/pbconf";
|
---|
[273] | 89 | if (defined $pbinit) {
|
---|
| 90 | print $LOG "Creating $ENV{'PBCONF'} directory\n";
|
---|
| 91 | pb_mkdir_p("$ENV{'PBCONF'}");
|
---|
| 92 | }
|
---|
[49] | 93 | die "Project $proj not Project-Builder compliant. Please populate $ENV{'PBCONF'}" if ( not -d "$ENV{'PBCONF'}");
|
---|
[2] | 94 |
|
---|
[74] | 95 | my %version = ();
|
---|
[108] | 96 | my %defpkgdir = ();
|
---|
| 97 | my %extpkgdir = ();
|
---|
| 98 | my %filteredfiles = ();
|
---|
[74] | 99 |
|
---|
[273] | 100 | if ((-f "$ENV{'PBCONF'}/$proj.pb") and (not defined $pbinit)) {
|
---|
[74] | 101 | # List of pkg to build by default (mandatory)
|
---|
| 102 | # List of additional pkg to build when all is called (optional)
|
---|
| 103 | # Valid version names (optional)
|
---|
| 104 | # List of files to filter (optional)
|
---|
[105] | 105 | my ($defpkgdir, $extpkgdir, $version, $filteredfiles, $pkgv, $pkgt) = pb_conf_read("$ENV{'PBCONF'}/$proj.pb","defpkgdir","extpkgdir","version","filteredfiles","projver","projtag");
|
---|
[74] | 106 | print "DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n" if ($debug >= 1);
|
---|
| 107 | print "DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n" if ($debug >= 1);
|
---|
| 108 | print "DEBUG: version: ".Dumper($version)."\n" if ($debug >= 1);
|
---|
| 109 | print "DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n" if ($debug >= 1);
|
---|
| 110 | die "Unable to find defpkgdir in $ENV{'PBCONF'}/$proj.pb" if (not defined $defpkgdir);
|
---|
| 111 | # Global
|
---|
| 112 | %defpkgdir = %$defpkgdir;
|
---|
| 113 | # Global
|
---|
[114] | 114 | %extpkgdir = %$extpkgdir if (defined $extpkgdir);
|
---|
[74] | 115 | %version = %$version if (defined $version);
|
---|
| 116 | # Global
|
---|
| 117 | %filteredfiles = %$filteredfiles if (defined $filteredfiles);
|
---|
[106] | 118 | #
|
---|
| 119 | # Get global Version/Tag
|
---|
| 120 | #
|
---|
[38] | 121 |
|
---|
[106] | 122 | if (not defined $ENV{'PBVER'}) {
|
---|
| 123 | if ((defined $pkgv) && (defined $pkgv->{$proj})) {
|
---|
| 124 | $ENV{'PBVER'}=$pkgv->{$proj};
|
---|
| 125 | } else {
|
---|
| 126 | die "No projver found in $ENV{'PBCONF'}/$proj.pb";
|
---|
| 127 | }
|
---|
[98] | 128 | }
|
---|
[106] | 129 | die "Invalid version name $ENV{'PBVER'} in $ENV{'PBCONF'}/$proj.pb" if (($ENV{'PBVER'} !~ /[0-9.]+/) && (not exists $version{$ENV{'PBVER'}}));
|
---|
| 130 |
|
---|
| 131 | if (not defined $ENV{'PBTAG'}) {
|
---|
| 132 | if ((defined $pkgt) && (defined $pkgt->{$proj})) {
|
---|
| 133 | $ENV{'PBTAG'}=$pkgt->{$proj};
|
---|
| 134 | } else {
|
---|
| 135 | die "No projtag found in $ENV{'PBCONF'}/$proj.pb";
|
---|
| 136 | }
|
---|
[98] | 137 | }
|
---|
[106] | 138 | die "Invalid tag name $ENV{'PBTAG'} in $ENV{'PBCONF'}/$proj.pb" if ($ENV{'PBTAG'} !~ /[0-9.]+/);
|
---|
| 139 | } else {
|
---|
[273] | 140 | if (defined $pbinit) {
|
---|
| 141 | open(CONF,"> $ENV{'PBCONF'}/$proj.pb") || die "Unable to create $ENV{'PBCONF'}/$proj.pb";
|
---|
| 142 | print CONF << "EOF";
|
---|
| 143 | #
|
---|
| 144 | # Project Builder configuration file
|
---|
| 145 | # For project $proj
|
---|
| 146 | #
|
---|
| 147 | # \$Id\$
|
---|
| 148 | #
|
---|
| 149 |
|
---|
| 150 | #
|
---|
| 151 | # Which CMS system is used (Subversion, CVS or tar file content extracted)
|
---|
| 152 | #
|
---|
| 153 | #cms $proj = svn
|
---|
| 154 | #cms $proj = cvs
|
---|
| 155 | #cms $proj = flat
|
---|
| 156 |
|
---|
| 157 | #
|
---|
| 158 | # Packager label
|
---|
| 159 | #
|
---|
| 160 | #packager $proj = "William Porte <bill\@$proj.org>"
|
---|
| 161 | #
|
---|
| 162 |
|
---|
| 163 | # For delivery to a machine by SSH (potentially the FTP server)
|
---|
| 164 | # Needs hostname, account and directory
|
---|
| 165 | #
|
---|
| 166 | #sshhost $proj = www.$proj.org
|
---|
| 167 | #sshlogin $proj = bill
|
---|
| 168 | #sshdir $proj = /$proj/ftp
|
---|
| 169 | #sshport $proj = 22
|
---|
| 170 |
|
---|
| 171 | #
|
---|
| 172 | # For Virtual machines management
|
---|
| 173 | # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
|
---|
| 174 | # followed by '_' and by release number
|
---|
| 175 | # a .vmtype extension will be added to the resulting string
|
---|
| 176 | # a QEMU rhel_3 here means that the VM will be named rhel_3.qemu
|
---|
| 177 | #
|
---|
[287] | 178 | #vmlist $proj = mandrake_10.1,mandrake_10.2,mandriva_2006.0,mandriva_2007.0,mandriva_2007.1,mandriva_2008.0,redhat_7.3,redhat_9,fedora_4,fedora_5,fedora_6,fedora_7,rhel_3,rhel_4,rhel_5,suse_10.0,suse_10.1,suse_10.2,suse_10.3,sles_9,sles_10,gentoo_nover,debian_3.1,debian_4.0,ubuntu_6.06,ubuntu_7.04,ubuntu_7.10
|
---|
[273] | 179 |
|
---|
| 180 | #
|
---|
| 181 | # Valid values for vmtype are
|
---|
| 182 | # qemu, (vmware, xen, ... TBD)
|
---|
| 183 | #vmtype $proj = qemu
|
---|
| 184 |
|
---|
| 185 | # Hash for VM stuff on vmtype
|
---|
| 186 | #vmntp default = pool.ntp.org
|
---|
| 187 |
|
---|
| 188 | # We suppose we can commmunicate with the VM through SSH
|
---|
[287] | 189 | #vmhost $proj = localhost
|
---|
| 190 | #vmlogin $proj = pb
|
---|
| 191 | #vmport $proj = 2222
|
---|
[273] | 192 |
|
---|
| 193 | # Timeout to wait when VM is launched/stopped
|
---|
| 194 | #vmtmout default = 120
|
---|
| 195 |
|
---|
| 196 | # per VMs needed paramaters
|
---|
[287] | 197 | #vmopt $proj = -m 384 -daemonize
|
---|
| 198 | #vmpath $proj = /home/qemu
|
---|
| 199 | #vmsize $proj = 5G
|
---|
[273] | 200 |
|
---|
| 201 | #
|
---|
| 202 | # Global version/tag for the project
|
---|
| 203 | #
|
---|
| 204 | #projver $proj = devel
|
---|
| 205 | #projtag $proj = 1
|
---|
| 206 |
|
---|
| 207 | # Adapt to your needs:
|
---|
| 208 | # Optional if you need to overwrite the global values above
|
---|
| 209 | #
|
---|
| 210 | #pkgver pkg1 = stable
|
---|
| 211 | #pkgtag pkg1 = 3
|
---|
| 212 | #pkgver nil
|
---|
| 213 | #pkgtag nil
|
---|
| 214 |
|
---|
| 215 | # Hash of default package/package directory
|
---|
| 216 | #defpkgdir pkg1 = pkg1dir
|
---|
| 217 |
|
---|
| 218 | # Hash of additional package/package directory
|
---|
| 219 | #extpkgdir pkg1-doc = pkg1-docdir
|
---|
| 220 |
|
---|
| 221 | # Hash of valid version names
|
---|
| 222 | #version devel
|
---|
| 223 | #version stable
|
---|
| 224 |
|
---|
| 225 | # List of files per pkg on which to apply filters
|
---|
| 226 | # Files are mentioned relatively to pbroot/defpkgdir
|
---|
| 227 | #filteredfiles pkg1 = Makefile.PL
|
---|
| 228 | #filteredfiles pkg1-doc = configure.in
|
---|
| 229 | EOF
|
---|
| 230 | close(CONF);
|
---|
| 231 | pb_mkdir_p("$ENV{'PBCONF'}/pbfilter") || die "Unable to create $ENV{'PBCONF'}/pbfilter";
|
---|
| 232 | open(CONF,"> $ENV{'PBCONF'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBCONF'}/pbfilter/all.pbf";
|
---|
| 233 | print CONF << "EOF";
|
---|
| 234 | #
|
---|
| 235 | # \$Id\$
|
---|
| 236 | #
|
---|
| 237 | # Filter for all files
|
---|
| 238 | #
|
---|
| 239 | # PBSRC is replaced by the source package format
|
---|
| 240 | #filter PBSRC = ftp://ftp.$proj.org/src/%{name}-%{version}.tar.gz
|
---|
| 241 |
|
---|
| 242 | # PBVER is replaced by the version (\$pbver in code)
|
---|
| 243 | #filter PBVER = \$pbver
|
---|
| 244 |
|
---|
| 245 | # PBDATE is replaced by the date (\$pbdate in code)
|
---|
| 246 | #filter PBDATE = \$pbdate
|
---|
| 247 |
|
---|
| 248 | # PBLOG is replaced by the changelog if value is yes
|
---|
| 249 | #filter PBLOG = yes
|
---|
| 250 |
|
---|
| 251 | # PBTAG is replaced by the tag (\$pbtag in code)
|
---|
| 252 | #filter PBTAG = \$pbtag
|
---|
| 253 |
|
---|
| 254 | # PBREV is replaced by the revision (\$pbrev in code)
|
---|
| 255 | #filter PBREV = \$pbrev
|
---|
| 256 |
|
---|
| 257 | # PBPKG is replaced by the package name (\$pbpkg in code)
|
---|
| 258 | #filter PBPKG = \$pbpkg
|
---|
| 259 |
|
---|
| 260 | # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
|
---|
| 261 | #filter PBPACKAGER = \$pbpackager
|
---|
| 262 |
|
---|
| 263 | # PBDESC contains the description of the package
|
---|
| 264 | #filter PBDESC = "Bla-Bla"
|
---|
| 265 |
|
---|
| 266 | # PBURL contains the URL of the Web site of the project
|
---|
| 267 | #filter PBURL = http://www.$proj.org
|
---|
| 268 | EOF
|
---|
| 269 | close(CONF);
|
---|
| 270 | open(CONF,"> $ENV{'PBCONF'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBCONF'}/pbfilter/rpm.pbf";
|
---|
| 271 | print CONF << "EOF";
|
---|
| 272 | #
|
---|
| 273 | # \$Id\$
|
---|
| 274 | #
|
---|
| 275 | # Filter for rpm build
|
---|
| 276 | #
|
---|
| 277 |
|
---|
| 278 | # PBGRP is replaced by the RPM group of apps
|
---|
[288] | 279 | # Cf: http://fedoraproject.org/wiki/RPMGroups
|
---|
[273] | 280 | #filter PBGRP = Applications/Archiving
|
---|
| 281 |
|
---|
| 282 | # PBDEP is replaced by the list of dependencies
|
---|
| 283 | #filter PBDEP =
|
---|
| 284 |
|
---|
| 285 | # PBSUF is replaced by the package name (\$pbpkg in code)
|
---|
| 286 | #filter PBSUF = \$pbsuf
|
---|
| 287 |
|
---|
| 288 | # PBOBS is replaced by the Obsolete line
|
---|
| 289 | #filter PBOBS =
|
---|
| 290 |
|
---|
| 291 | EOF
|
---|
| 292 | close(CONF);
|
---|
| 293 | open(CONF,"> $ENV{'PBCONF'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBCONF'}/pbfilter/deb.pbf";
|
---|
| 294 | print CONF << "EOF";
|
---|
| 295 | #
|
---|
| 296 | # \$Id\$
|
---|
| 297 | #
|
---|
| 298 | # Filter for debian build
|
---|
| 299 | #
|
---|
| 300 | # PBGRP is replaced by the group of apps
|
---|
| 301 | #filter PBGRP = utils
|
---|
| 302 |
|
---|
| 303 | # PBVER is replaced by the version (\$pbver in code)
|
---|
| 304 | #filter PBVER = \$pbver
|
---|
| 305 |
|
---|
| 306 | # PBDEP is replaced by the list of dependencies
|
---|
| 307 | #filter PBDEP =
|
---|
| 308 |
|
---|
| 309 | # PBSUG is replaced by the list of suggestions
|
---|
| 310 | #filter PBSUG =
|
---|
| 311 |
|
---|
| 312 | # PBREC is replaced by the list of recommandations
|
---|
| 313 | #filter PBREC =
|
---|
| 314 |
|
---|
| 315 | # PBLOG is replaced by the changelog if value is yes
|
---|
| 316 | #filter PBLOG = yes
|
---|
| 317 |
|
---|
| 318 | # PBPKG is replaced by the package name (\$pbpkg in code)
|
---|
| 319 | #filter PBPKG = \$pbpkg
|
---|
| 320 |
|
---|
| 321 | # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
|
---|
| 322 | #filter PBPACKAGER = \$pbpackager
|
---|
| 323 |
|
---|
| 324 | EOF
|
---|
| 325 | close(CONF);
|
---|
| 326 | open(CONF,"> $ENV{'PBCONF'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBCONF'}/pbfilter/md.pbf";
|
---|
| 327 | print CONF << "EOF";
|
---|
| 328 | # Specific group for Mandriva for $proj
|
---|
| 329 | filter PBGRP = Archiving/Backup
|
---|
| 330 | EOF
|
---|
| 331 | close(CONF);
|
---|
| 332 | open(CONF,"> $ENV{'PBCONF'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBCONF'}/pbfilter/novell.pbf";
|
---|
| 333 | print CONF << "EOF";
|
---|
| 334 | # Specific group for SuSE for $proj
|
---|
| 335 | filter PBGRP = Productivity/Archiving/Backup
|
---|
| 336 | EOF
|
---|
| 337 | close(CONF);
|
---|
| 338 | pb_mkdir_p("$ENV{'PBCONF'}/pkg1/deb") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb";
|
---|
| 339 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/control") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/control";
|
---|
| 340 | print CONF << "EOF";
|
---|
| 341 | Source: PBPKG
|
---|
| 342 | Section: PBGRP
|
---|
| 343 | Priority: optional
|
---|
| 344 | Maintainer: PBPACKAGER
|
---|
| 345 | Build-Depends: debhelper (>= 4.2.20), PBDEP
|
---|
| 346 | Standards-Version: 3.6.1
|
---|
| 347 |
|
---|
| 348 | Package: PBPKG
|
---|
| 349 | Architecture: amd64 i386 ia64
|
---|
| 350 | Section: PBGRP
|
---|
| 351 | Priority: optional
|
---|
| 352 | Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
|
---|
| 353 | Recommends: PBREC
|
---|
| 354 | Suggests: PBSUG
|
---|
| 355 | Description:
|
---|
| 356 | PBDESC
|
---|
| 357 | .
|
---|
| 358 | Homepage: PBURL
|
---|
| 359 |
|
---|
| 360 | EOF
|
---|
| 361 | close(CONF);
|
---|
| 362 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/copyright") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/copyright";
|
---|
| 363 | print CONF << "EOF";
|
---|
| 364 | This package is debianized by PBPACKAGER
|
---|
| 365 | `date`
|
---|
| 366 |
|
---|
| 367 | The current upstream source was downloaded from
|
---|
| 368 | ftp://ftp.$proj.org/src/.
|
---|
| 369 |
|
---|
| 370 | Upstream Authors: Put their name here
|
---|
| 371 |
|
---|
| 372 | Copyright:
|
---|
| 373 |
|
---|
| 374 | This package is free software; you can redistribute it and/or modify
|
---|
| 375 | it under the terms of the GNU General Public License as published by
|
---|
| 376 | the Free Software Foundation; version 2 dated June, 1991.
|
---|
| 377 |
|
---|
| 378 | This package is distributed in the hope that it will be useful,
|
---|
| 379 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 380 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 381 | GNU General Public License for more details.
|
---|
| 382 |
|
---|
| 383 | You should have received a copy of the GNU General Public License
|
---|
| 384 | along with this package; if not, write to the Free Software
|
---|
| 385 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
---|
| 386 | MA 02110-1301, USA.
|
---|
| 387 |
|
---|
| 388 | On Debian systems, the complete text of the GNU General
|
---|
| 389 | Public License can be found in /usr/share/common-licenses/GPL.
|
---|
| 390 |
|
---|
| 391 | EOF
|
---|
| 392 | close(CONF);
|
---|
| 393 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/changelog") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/changelog";
|
---|
| 394 | print CONF << "EOF";
|
---|
| 395 | PBLOG
|
---|
| 396 | EOF
|
---|
| 397 | close(CONF);
|
---|
| 398 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/compat") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/compat";
|
---|
| 399 | print CONF << "EOF";
|
---|
| 400 | 4
|
---|
| 401 | EOF
|
---|
| 402 | close(CONF);
|
---|
| 403 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/pkg1.dirs") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/pkg1.dirs";
|
---|
| 404 | print CONF << "EOF";
|
---|
| 405 | EOF
|
---|
| 406 | close(CONF);
|
---|
| 407 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/pkg1.docs") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/pkg1.docs";
|
---|
| 408 | print CONF << "EOF";
|
---|
| 409 | INSTALL
|
---|
| 410 | COPYING
|
---|
| 411 | AUTHORS
|
---|
| 412 | NEWS
|
---|
| 413 | README
|
---|
| 414 | EOF
|
---|
| 415 | close(CONF);
|
---|
| 416 | open(CONF,"> $ENV{'PBCONF'}/pkg1/deb/rules") || die "Unable to create $ENV{'PBCONF'}/pkg1/deb/rules";
|
---|
| 417 | print CONF << 'EOF';
|
---|
| 418 | #!/usr/bin/make -f
|
---|
| 419 | # -*- makefile -*-
|
---|
| 420 | # Sample debian/rules that uses debhelper.
|
---|
| 421 | # GNU copyright 1997 to 1999 by Joey Hess.
|
---|
| 422 | #
|
---|
| 423 | # $Id$
|
---|
| 424 | #
|
---|
| 425 |
|
---|
| 426 | # Uncomment this to turn on verbose mode.
|
---|
| 427 | #export DH_VERBOSE=1
|
---|
| 428 |
|
---|
| 429 | # Define package name variable for a one-stop change.
|
---|
| 430 | PACKAGE_NAME = PBPKG
|
---|
| 431 |
|
---|
| 432 | # These are used for cross-compiling and for saving the configure script
|
---|
| 433 | # from having to guess our platform (since we know it already)
|
---|
| 434 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
---|
| 435 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
---|
| 436 |
|
---|
| 437 | CFLAGS = -Wall -g
|
---|
| 438 |
|
---|
| 439 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
---|
| 440 | CFLAGS += -O0
|
---|
| 441 | else
|
---|
| 442 | CFLAGS += -O2
|
---|
| 443 | endif
|
---|
| 444 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
|
---|
| 445 | INSTALL_PROGRAM += -s
|
---|
| 446 | endif
|
---|
| 447 | config.status: configure
|
---|
| 448 | dh_testdir
|
---|
| 449 |
|
---|
| 450 | # Configure the package.
|
---|
| 451 | CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
|
---|
| 452 | --mandir=\$${prefix}/share/man
|
---|
| 453 |
|
---|
| 454 | # Build both architecture dependent and independent
|
---|
| 455 | build: build-arch build-indep
|
---|
| 456 |
|
---|
| 457 | # Build architecture dependent
|
---|
| 458 | build-arch: build-arch-stamp
|
---|
| 459 |
|
---|
| 460 | build-arch-stamp: config.status
|
---|
| 461 | dh_testdir
|
---|
| 462 |
|
---|
| 463 | # Compile the package.
|
---|
| 464 | $(MAKE)
|
---|
| 465 |
|
---|
| 466 | touch build-stamp
|
---|
| 467 |
|
---|
| 468 | # Build architecture independent
|
---|
| 469 | build-indep: build-indep-stamp
|
---|
| 470 |
|
---|
| 471 | build-indep-stamp: config.status
|
---|
| 472 | # Nothing to do, the only indep item is the manual which is available as html in original source
|
---|
| 473 | touch build-indep-stamp
|
---|
| 474 |
|
---|
| 475 | # Clean up
|
---|
| 476 | clean:
|
---|
| 477 | dh_testdir
|
---|
| 478 | dh_testroot
|
---|
| 479 | rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
|
---|
| 480 | # Clean temporary document directory
|
---|
| 481 | rm -rf debian/doc-temp
|
---|
| 482 | # Clean up.
|
---|
| 483 | -$(MAKE) distclean
|
---|
| 484 | rm -f config.log
|
---|
| 485 | ifneq "$(wildcard /usr/share/misc/config.sub)" ""
|
---|
| 486 | cp -f /usr/share/misc/config.sub config.sub
|
---|
| 487 | endif
|
---|
| 488 | ifneq "$(wildcard /usr/share/misc/config.guess)" ""
|
---|
| 489 | cp -f /usr/share/misc/config.guess config.guess
|
---|
| 490 | endif
|
---|
| 491 |
|
---|
| 492 | dh_clean
|
---|
| 493 |
|
---|
| 494 | # Install architecture dependent and independent
|
---|
| 495 | install: install-arch install-indep
|
---|
| 496 |
|
---|
| 497 | # Install architecture dependent
|
---|
| 498 | install-arch: build-arch
|
---|
| 499 | dh_testdir
|
---|
| 500 | dh_testroot
|
---|
| 501 | dh_clean -k -s
|
---|
| 502 | dh_installdirs -s
|
---|
| 503 |
|
---|
| 504 | # Install the package files into build directory:
|
---|
| 505 | # - start with upstream make install
|
---|
| 506 | $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
|
---|
| 507 | r/share/man
|
---|
| 508 | # - copy html manual to temporary location for renaming
|
---|
| 509 | mkdir -p debian/doc-temp
|
---|
| 510 | dh_install -s
|
---|
| 511 |
|
---|
| 512 | # Install architecture independent
|
---|
| 513 | install-indep: build-indep
|
---|
| 514 | dh_testdir
|
---|
| 515 | dh_testroot
|
---|
| 516 | dh_clean -k -i
|
---|
| 517 | dh_installdirs -i
|
---|
| 518 | dh_install -i
|
---|
| 519 |
|
---|
| 520 | # Must not depend on anything. This is to be called by
|
---|
| 521 | # binary-arch/binary-indep
|
---|
| 522 | # in another 'make' thread.
|
---|
| 523 | binary-common:
|
---|
| 524 | dh_testdir
|
---|
| 525 | dh_testroot
|
---|
| 526 | dh_installchangelogs ChangeLog
|
---|
| 527 | dh_installdocs
|
---|
| 528 | dh_installman
|
---|
| 529 | dh_link
|
---|
| 530 | dh_strip
|
---|
| 531 | dh_compress
|
---|
| 532 | dh_fixperms
|
---|
| 533 | dh_installdeb
|
---|
| 534 | dh_shlibdeps
|
---|
| 535 | dh_gencontrol
|
---|
| 536 | dh_md5sums
|
---|
| 537 | dh_builddeb
|
---|
| 538 |
|
---|
| 539 | # Build architecture independant packages using the common target.
|
---|
| 540 | binary-indep: build-indep install-indep
|
---|
| 541 | $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
|
---|
| 542 |
|
---|
| 543 | # Build architecture dependant packages using the common target.
|
---|
| 544 | binary-arch: build-arch install-arch
|
---|
| 545 | $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
|
---|
| 546 |
|
---|
| 547 | # Build architecture depdendent and independent packages
|
---|
| 548 | binary: binary-arch binary-indep
|
---|
| 549 | .PHONY: clean binary
|
---|
| 550 |
|
---|
| 551 | EOF
|
---|
| 552 | close(CONF);
|
---|
| 553 | pb_mkdir_p("$ENV{'PBCONF'}/pkg1/rpm") || die "Unable to create $ENV{'PBCONF'}/pkg1/rpm";
|
---|
| 554 | open(CONF,"> $ENV{'PBCONF'}/pkg1/rpm/pkg1.spec") || die "Unable to create $ENV{'PBCONF'}/pkg1/rpm/pkg1.spec";
|
---|
| 555 | print CONF << 'EOF';
|
---|
| 556 | #
|
---|
| 557 | # $Id$
|
---|
| 558 | #
|
---|
| 559 |
|
---|
| 560 | Summary: bla-bla
|
---|
| 561 | Summary(fr): french bla-bla
|
---|
| 562 |
|
---|
| 563 | Name: PBPKG
|
---|
| 564 | Version: PBVER
|
---|
| 565 | Release: PBTAGPBSUF
|
---|
| 566 | License: GPL
|
---|
| 567 | Group: PBGRP
|
---|
| 568 | Url: PBURL
|
---|
| 569 | Source: PBSRC
|
---|
| 570 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
|
---|
| 571 | Requires: PBDEP
|
---|
| 572 |
|
---|
| 573 | %description
|
---|
| 574 | PBDESC
|
---|
| 575 |
|
---|
| 576 | %description -l fr
|
---|
| 577 | french desc
|
---|
| 578 |
|
---|
| 579 | %prep
|
---|
| 580 | %setup -q
|
---|
| 581 |
|
---|
| 582 | %build
|
---|
| 583 | %configure
|
---|
[288] | 584 | make %{?_smp_mflags}
|
---|
[273] | 585 |
|
---|
| 586 | %install
|
---|
| 587 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
| 588 | make DESTDIR=$RPM_BUILD_ROOT install
|
---|
| 589 |
|
---|
| 590 | %clean
|
---|
| 591 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
| 592 |
|
---|
| 593 | %files
|
---|
| 594 | %defattr(-,root,root)
|
---|
| 595 | %doc ChangeLog
|
---|
| 596 | %doc INSTALL COPYING README AUTHORS NEWS
|
---|
| 597 |
|
---|
| 598 | %changelog
|
---|
| 599 | PBLOG
|
---|
| 600 |
|
---|
| 601 | EOF
|
---|
| 602 | close(CONF);
|
---|
| 603 | pb_mkdir_p("$ENV{'PBCONF'}/pkg1/pbfilter") || die "Unable to create $ENV{'PBCONF'}/pkg1/pbfilter";
|
---|
| 604 |
|
---|
| 605 | print "\nDo not to forget to commit the pbconf directory in your CMS if needed\n";
|
---|
| 606 | print "After having renamed the pkg1 directory to your package's name \n\n";
|
---|
| 607 | } else {
|
---|
| 608 | die "Unable to open $ENV{'PBCONF'}/$proj.pb";
|
---|
| 609 | }
|
---|
[98] | 610 | }
|
---|
| 611 |
|
---|
[8] | 612 | #
|
---|
[105] | 613 | # Set temp directory
|
---|
| 614 | #
|
---|
| 615 | if (not defined $ENV{'TMPDIR'}) {
|
---|
| 616 | $ENV{'TMPDIR'}="/tmp";
|
---|
| 617 | }
|
---|
| 618 | $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 );
|
---|
| 619 |
|
---|
| 620 | #
|
---|
[69] | 621 | # Removes all directory existing below the delivery dir
|
---|
| 622 | # as they are temp dir only
|
---|
[68] | 623 | # Files stay and have to be cleaned up manually
|
---|
[8] | 624 | #
|
---|
[25] | 625 | if (-d $ENV{'PBDESTDIR'}) {
|
---|
| 626 | opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
|
---|
| 627 | foreach my $d (readdir(DIR)) {
|
---|
| 628 | next if ($d =~ /^\./);
|
---|
[68] | 629 | next if (-f "$ENV{'PBDESTDIR'}/$d");
|
---|
[74] | 630 | pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
|
---|
[25] | 631 | }
|
---|
| 632 | closedir(DIR);
|
---|
| 633 | }
|
---|
| 634 | if (! -d "$ENV{'PBDESTDIR'}") {
|
---|
[74] | 635 | pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
|
---|
[25] | 636 | }
|
---|
[5] | 637 |
|
---|
[25] | 638 | #
|
---|
| 639 | # Set build directory
|
---|
| 640 | #
|
---|
[71] | 641 | $ENV{'PBBUILDDIR'}=$topdir."/build";
|
---|
[101] | 642 | if (! -d "$ENV{'PBBUILDDIR'}") {
|
---|
| 643 | pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
|
---|
| 644 | }
|
---|
[25] | 645 |
|
---|
[8] | 646 | umask 0022;
|
---|
[107] | 647 | return($proj,$debug,$LOG,\%pbrc, \%filteredfiles, \%defpkgdir, \%extpkgdir);
|
---|
[2] | 648 | }
|
---|
[9] | 649 |
|
---|
[74] | 650 | # Internal mkdir -p function
|
---|
| 651 | sub pb_mkdir_p {
|
---|
[29] | 652 | my @dir = @_;
|
---|
| 653 | my $ret = mkpath(@dir, 0, 0755);
|
---|
| 654 | return($ret);
|
---|
[9] | 655 | }
|
---|
| 656 |
|
---|
[74] | 657 | # Internal rm -rf function
|
---|
| 658 | sub pb_rm_rf {
|
---|
[29] | 659 | my @dir = @_;
|
---|
| 660 | my $ret = rmtree(@dir, 0, 0);
|
---|
| 661 | return($ret);
|
---|
[9] | 662 | }
|
---|
| 663 |
|
---|
[74] | 664 | # Internal system function
|
---|
| 665 | sub pb_system {
|
---|
[29] | 666 |
|
---|
| 667 | my $cmd=shift;
|
---|
[30] | 668 | my $cmt=shift || $cmd;
|
---|
[29] | 669 |
|
---|
[108] | 670 | print "$cmt... ";
|
---|
[117] | 671 | #system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
|
---|
| 672 | system("$cmd");
|
---|
[29] | 673 | if ($? == -1) {
|
---|
[108] | 674 | print "failed to execute ($cmd) : $!\n";
|
---|
[106] | 675 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[29] | 676 | } elsif ($? & 127) {
|
---|
[108] | 677 | printf "child ($cmd) died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without';
|
---|
[106] | 678 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
| 679 | } elsif ($? == 0) {
|
---|
[108] | 680 | print "OK\n";
|
---|
[29] | 681 | } else {
|
---|
[106] | 682 | printf "child ($cmd) exited with value %d\n", $? >> 8;
|
---|
| 683 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[29] | 684 | }
|
---|
[30] | 685 | }
|
---|
[74] | 686 |
|
---|
[106] | 687 | sub pb_display_file {
|
---|
| 688 |
|
---|
| 689 | my $file=shift;
|
---|
| 690 |
|
---|
[117] | 691 | return if (not -f $file);
|
---|
| 692 | open(FILE,"$file");
|
---|
[106] | 693 | while (<FILE>) {
|
---|
[108] | 694 | print $_;
|
---|
[106] | 695 | }
|
---|
| 696 | close(FILE);
|
---|
| 697 | }
|
---|
| 698 |
|
---|
[242] | 699 | # Function which returns a pointer on a table
|
---|
| 700 | # corresponding to a set of values queried in the conf file
|
---|
[88] | 701 | # and test the returned vaue as they need to exist in that case
|
---|
| 702 | sub pb_conf_get {
|
---|
| 703 |
|
---|
| 704 | my @param = @_;
|
---|
| 705 |
|
---|
[242] | 706 | # Everything is returned via ptr1
|
---|
| 707 | my @ptr1 = pb_conf_read("$ENV{'PBETC'}", @param);
|
---|
| 708 | my @ptr2 = pb_conf_read("$ENV{'PBCONF'}/$ENV{'PBPROJ'}.pb", @param);
|
---|
[89] | 709 |
|
---|
[242] | 710 | my $p1;
|
---|
| 711 | my $p2;
|
---|
| 712 |
|
---|
[262] | 713 | #print "DEBUG: param1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
|
---|
| 714 | #print "DEBUG: param2: ".Dumper(@ptr2)."\n"; # if ($debug >= 1);
|
---|
| 715 |
|
---|
[88] | 716 | foreach my $i (0..$#param) {
|
---|
[262] | 717 | $p1 = $ptr1[$i];
|
---|
| 718 | $p2 = $ptr2[$i];
|
---|
[265] | 719 | die "No $param[$i] defined for $ENV{'PBPROJ'}" if ((not @ptr1) && (not @ptr2));
|
---|
[262] | 720 | die "No $param[$i] defined for $ENV{'PBPROJ'}" if ((not defined $p1) && (not defined $p2));
|
---|
[242] | 721 | # Always try to take the param from the home dir conf file in priority
|
---|
| 722 | # in order to mask what could be defined under the CMS to allow for overloading
|
---|
| 723 | if (not defined $p2) {
|
---|
| 724 | # No ref in CMS project conf file so use the home dir one.
|
---|
| 725 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (not defined $p1->{$ENV{'PBPROJ'}});
|
---|
| 726 | } else {
|
---|
| 727 | # Ref found in CMS project conf file
|
---|
| 728 | if (not defined $p1) {
|
---|
| 729 | # No ref in home dir project conf file so use the CMS one.
|
---|
| 730 | $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if (not defined $p2->{$ENV{'PBPROJ'}});
|
---|
| 731 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
|
---|
| 732 | } else {
|
---|
| 733 | # Both are defined - handling the overloading
|
---|
| 734 | if (not defined $p1->{'default'}) {
|
---|
| 735 | if (defined $p2->{'default'}) {
|
---|
| 736 | $p1->{'default'} = $p2->{'default'};
|
---|
| 737 | }
|
---|
| 738 | }
|
---|
| 739 |
|
---|
| 740 | if (not defined $p1->{$ENV{'PBPROJ'}}) {
|
---|
| 741 | if (defined $p2->{$ENV{'PBPROJ'}}) {
|
---|
| 742 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
|
---|
| 743 | } else {
|
---|
| 744 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'};
|
---|
| 745 | }
|
---|
| 746 | }
|
---|
| 747 | }
|
---|
| 748 | }
|
---|
| 749 | die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $p1->{$ENV{'PBPROJ'}});
|
---|
[262] | 750 | $ptr1[$i] = $p1;
|
---|
| 751 | #print "DEBUG: param ptr1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
|
---|
[88] | 752 | }
|
---|
[242] | 753 | return(@ptr1);
|
---|
[88] | 754 | }
|
---|
| 755 |
|
---|
[242] | 756 | sub pb_no_err {
|
---|
| 757 | }
|
---|
| 758 |
|
---|
[88] | 759 | # Function which returns a pointer on a hash
|
---|
[74] | 760 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
| 761 | sub pb_conf_read {
|
---|
| 762 |
|
---|
| 763 | my $conffile = shift;
|
---|
| 764 | my @param = @_;
|
---|
| 765 | my $trace;
|
---|
| 766 | my @ptr;
|
---|
| 767 |
|
---|
[108] | 768 | my $debug = 0;
|
---|
| 769 |
|
---|
[74] | 770 | if ($debug > 0) {
|
---|
| 771 | $trace = 1;
|
---|
| 772 | } else {
|
---|
| 773 | $trace = 0;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 |
|
---|
| 777 | my $config = AppConfig->new({
|
---|
| 778 | # Auto Create variables mentioned in Conf file
|
---|
| 779 | CREATE => 1,
|
---|
| 780 | DEBUG => $trace,
|
---|
[242] | 781 | ERROR => \&pb_no_err,
|
---|
[74] | 782 | GLOBAL => {
|
---|
| 783 | # Each conf item is a hash
|
---|
| 784 | ARGCOUNT => ARGCOUNT_HASH,
|
---|
| 785 | },
|
---|
| 786 | });
|
---|
| 787 | $config->file($conffile);
|
---|
| 788 | for my $param (@param) {
|
---|
| 789 | push @ptr,$config->get($param);
|
---|
| 790 | }
|
---|
[89] | 791 | print "DEBUG: params: ".Dumper(@param)." ".Dumper(@ptr)."\n" if ($debug >= 1);
|
---|
| 792 | return(@ptr);
|
---|
[74] | 793 | }
|
---|
| 794 |
|
---|
| 795 | # Setup environment for CMS system
|
---|
| 796 | sub pb_cms_init {
|
---|
| 797 |
|
---|
| 798 | my $proj = shift || undef;
|
---|
| 799 | my $ret;
|
---|
| 800 |
|
---|
[89] | 801 | my ($cms) = pb_conf_get("cms");
|
---|
[74] | 802 |
|
---|
[88] | 803 | if ($cms->{$proj} eq "svn") {
|
---|
[74] | 804 | $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; svnversion .)`;
|
---|
| 805 | chomp($ENV{'PBREVISION'});
|
---|
| 806 | $ENV{'PBCMSLOGFILE'}="svn.log";
|
---|
[226] | 807 | } elsif ($cms->{$proj} eq "flat") {
|
---|
| 808 | $ENV{'PBREVISION'}="flat";
|
---|
[227] | 809 | $ENV{'PBCMSLOGFILE'}="flat.log";
|
---|
[88] | 810 | } elsif ($cms->{$proj} eq "cvs") {
|
---|
[106] | 811 | # Way too slow
|
---|
| 812 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
|
---|
| 813 | #chomp($ENV{'PBREVISION'});
|
---|
| 814 | $ENV{'PBREVISION'}="CVS";
|
---|
[74] | 815 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
[87] | 816 | #
|
---|
| 817 | # Export content if needed
|
---|
| 818 | #
|
---|
[242] | 819 | my ($cvsroot,$cvsrsh) = pb_conf_get("cvsroot","cvsrsh");
|
---|
[88] | 820 | $ENV{'CVSROOT'} = $cvsroot->{$proj} if (defined $cvsroot->{$proj});
|
---|
[112] | 821 | $ENV{'CVSRSH'} = $cvsrsh->{$proj} if (defined $cvsrsh->{$proj});
|
---|
[74] | 822 | } else {
|
---|
[88] | 823 | die "cms $cms->{$proj} unknown";
|
---|
[74] | 824 | }
|
---|
[106] | 825 | return($cms);
|
---|
[74] | 826 | }
|
---|
| 827 |
|
---|
[106] | 828 | sub pb_cms_export {
|
---|
| 829 | my $cms = shift;
|
---|
| 830 | my $pbdate = shift || undef;
|
---|
[108] | 831 | my $source = shift;
|
---|
[106] | 832 | my $destdir = shift;
|
---|
[108] | 833 | my $tmp;
|
---|
[115] | 834 | my $tmp1;
|
---|
[106] | 835 |
|
---|
| 836 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
[108] | 837 | if (-d $source) {
|
---|
| 838 | $tmp = $destdir;
|
---|
| 839 | } else {
|
---|
| 840 | $tmp = $destdir."/".basename($source);
|
---|
| 841 | }
|
---|
[116] | 842 | pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
|
---|
[226] | 843 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
| 844 | if (-d $source) {
|
---|
| 845 | $tmp = $destdir;
|
---|
| 846 | } else {
|
---|
| 847 | $tmp = $destdir."/".basename($source);
|
---|
| 848 | }
|
---|
| 849 | pb_system("cp -a $source $tmp","Exporting $source from DIR to $tmp");
|
---|
[106] | 850 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 851 | my $dir=dirname($destdir);
|
---|
| 852 | my $base=basename($destdir);
|
---|
[115] | 853 | if (-d $source) {
|
---|
| 854 | $tmp1 = $source;
|
---|
| 855 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
| 856 | } else {
|
---|
| 857 | $tmp1 = dirname($source);
|
---|
| 858 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
| 859 | $tmp1 = $tmp1."/".basename($source);
|
---|
| 860 | }
|
---|
[106] | 861 | # CVS needs a relative path !
|
---|
[115] | 862 | pb_system("cd $dir ; cvs export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir");
|
---|
[106] | 863 | } else {
|
---|
| 864 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 865 | }
|
---|
| 866 | }
|
---|
| 867 |
|
---|
[285] | 868 |
|
---|
| 869 | sub pb_create_authors {
|
---|
| 870 |
|
---|
| 871 | my $authors=shift;
|
---|
| 872 | my $dest=shift;
|
---|
| 873 | my $cms=shift;
|
---|
| 874 |
|
---|
[286] | 875 | return if ($authors eq "/dev/null");
|
---|
| 876 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
[285] | 877 | open(DAUTH,"> $dest/AUTHORS") || die "Unable to create $dest/AUTHORS";
|
---|
| 878 | print DAUTH "Authors of the project are:\n";
|
---|
| 879 | print DAUTH "===========================\n";
|
---|
[286] | 880 | while (<SAUTH>) {
|
---|
[285] | 881 | my ($nick,$gcos) = split(/:/);
|
---|
[286] | 882 | chomp($gcos);
|
---|
[285] | 883 | print DAUTH "$gcos";
|
---|
[286] | 884 | if (defined $cms) {
|
---|
| 885 | print DAUTH " ($nick under $cms)\n";
|
---|
| 886 | } else {
|
---|
| 887 | print DAUTH "\n";
|
---|
| 888 | }
|
---|
[285] | 889 | }
|
---|
| 890 | close(DAUTH);
|
---|
[286] | 891 | close(SAUTH);
|
---|
[285] | 892 | }
|
---|
| 893 |
|
---|
[106] | 894 | sub pb_cms_log {
|
---|
| 895 | my $cms = shift;
|
---|
| 896 | my $pkgdir = shift;
|
---|
[285] | 897 | my $dest = shift;
|
---|
[286] | 898 | my $chglog = shift;
|
---|
[285] | 899 | my $authors = shift;
|
---|
[106] | 900 |
|
---|
[285] | 901 | pb_create_authors($authors,$dest,$cms->{$ENV{'PBPROJ'}});
|
---|
| 902 |
|
---|
[106] | 903 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
[286] | 904 | if (! -f "$dest/ChangeLog") {
|
---|
| 905 | if (-x "/usr/bin/svn2cl") {
|
---|
| 906 | pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN");
|
---|
| 907 | } else {
|
---|
| 908 | # To be written from pbcl
|
---|
| 909 | pb_system("svn log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
| 910 | }
|
---|
[285] | 911 | }
|
---|
[226] | 912 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[288] | 913 | if (! -f "$dest/ChangeLog") {
|
---|
| 914 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
| 915 | }
|
---|
[106] | 916 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 917 | my $tmp=basename($pkgdir);
|
---|
| 918 | # CVS needs a relative path !
|
---|
[286] | 919 | if (! -f "$dest/ChangeLog") {
|
---|
| 920 | if (-x "/usr/bin/cvs2cl") {
|
---|
[288] | 921 | pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS");
|
---|
[286] | 922 | } else {
|
---|
| 923 | # To be written from pbcl
|
---|
| 924 | pb_system("cvs log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
| 925 | }
|
---|
[285] | 926 | }
|
---|
[106] | 927 | } else {
|
---|
| 928 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 929 | }
|
---|
| 930 | }
|
---|
| 931 |
|
---|
[204] | 932 | sub pb_cms_getinfo {
|
---|
| 933 | my $cms = shift;
|
---|
| 934 | my $url = "";
|
---|
| 935 | my $void = "";
|
---|
[106] | 936 |
|
---|
[204] | 937 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
| 938 | open(PIPE,"LANGUAGE=C svn info $ENV{'PBROOT'} |") || die "Unable to get svn info from $ENV{'PBROOT'}";
|
---|
| 939 | while (<PIPE>) {
|
---|
[206] | 940 | ($void,$url) = split(/^URL:/) if (/^URL:/);
|
---|
[204] | 941 | }
|
---|
| 942 | close(PIPE);
|
---|
[205] | 943 | chomp($url);
|
---|
[226] | 944 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[204] | 945 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 946 | } else {
|
---|
| 947 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 948 | }
|
---|
| 949 | return($url);
|
---|
| 950 | }
|
---|
| 951 |
|
---|
| 952 | sub pb_cms_copy {
|
---|
| 953 | my $cms = shift;
|
---|
| 954 | my $oldurl = shift;
|
---|
| 955 | my $newurl = shift;
|
---|
| 956 |
|
---|
| 957 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
[212] | 958 | pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");
|
---|
[226] | 959 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[204] | 960 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 961 | } else {
|
---|
| 962 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 963 | }
|
---|
| 964 | }
|
---|
| 965 |
|
---|
| 966 | sub pb_cms_checkout {
|
---|
| 967 | my $cms = shift;
|
---|
| 968 | my $url = shift;
|
---|
| 969 | my $destination = shift;
|
---|
| 970 |
|
---|
| 971 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
| 972 | pb_system("svn co $url $destination","Checking $url to $destination ");
|
---|
[226] | 973 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[204] | 974 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 975 | } else {
|
---|
| 976 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 977 | }
|
---|
| 978 | }
|
---|
| 979 |
|
---|
[208] | 980 | sub pb_cms_checkin {
|
---|
| 981 | my $cms = shift;
|
---|
| 982 | my $dir = shift;
|
---|
| 983 |
|
---|
[212] | 984 | my $ver = basename($dir);
|
---|
[208] | 985 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
[212] | 986 | pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir");
|
---|
[208] | 987 | pb_system("svn up $dir","Updating $dir");
|
---|
[226] | 988 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[208] | 989 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 990 | } else {
|
---|
| 991 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 992 | }
|
---|
| 993 | }
|
---|
| 994 |
|
---|
[204] | 995 | sub pb_cms_isdiff {
|
---|
| 996 | my $cms = shift;
|
---|
| 997 |
|
---|
| 998 | if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
|
---|
| 999 | open(PIPE,"svn diff $ENV{'PBROOT'} |") || die "Unable to get svn diff from $ENV{'PBROOT'}";
|
---|
| 1000 | my $l = 0;
|
---|
| 1001 | while (<PIPE>) {
|
---|
| 1002 | $l++;
|
---|
| 1003 | }
|
---|
| 1004 | return($l);
|
---|
[226] | 1005 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
|
---|
[204] | 1006 | } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
|
---|
| 1007 | } else {
|
---|
| 1008 | die "cms $cms->{$ENV{'PBPROJ'}} unknown";
|
---|
| 1009 | }
|
---|
| 1010 | }
|
---|
| 1011 |
|
---|
[77] | 1012 | # Get all filters to apply
|
---|
| 1013 | # They're cumulative from less specific to most specific
|
---|
| 1014 | # suffix is .pbf
|
---|
| 1015 |
|
---|
| 1016 | sub pb_get_filters {
|
---|
| 1017 |
|
---|
[108] | 1018 | # For the moment not dynamic
|
---|
| 1019 | my $debug = 0; # Debug level
|
---|
| 1020 | my $LOG = *STDOUT; # Where to log
|
---|
| 1021 |
|
---|
[77] | 1022 | my @ffiles;
|
---|
[235] | 1023 | my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3);
|
---|
| 1024 | my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3);
|
---|
[77] | 1025 | my $pbpkg = shift || die "No package specified";
|
---|
[236] | 1026 | my $dtype = shift || "";
|
---|
| 1027 | my $dfam = shift || "";
|
---|
| 1028 | my $ddir = shift || "";
|
---|
| 1029 | my $dver = shift || "";
|
---|
[77] | 1030 | my $ptr; # returned value pointer on the hash of filters
|
---|
[79] | 1031 | my %ptr;
|
---|
[77] | 1032 |
|
---|
[169] | 1033 | # Global filter files first, then package specificities
|
---|
| 1034 | if (-d "$ENV{'PBCONF'}/pbfilter") {
|
---|
[231] | 1035 | $mfile00 = "$ENV{'PBCONF'}/pbfilter/all.pbf" if (-f "$ENV{'PBCONF'}/pbfilter/all.pbf");
|
---|
[169] | 1036 | $mfile0 = "$ENV{'PBCONF'}/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/pbfilter/$dtype.pbf");
|
---|
| 1037 | $mfile1 = "$ENV{'PBCONF'}/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/pbfilter/$dfam.pbf");
|
---|
| 1038 | $mfile2 = "$ENV{'PBCONF'}/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/pbfilter/$ddir.pbf");
|
---|
| 1039 | $mfile3 = "$ENV{'PBCONF'}/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/pbfilter/$ddir-$dver.pbf");
|
---|
| 1040 |
|
---|
[231] | 1041 | push @ffiles,$mfile00 if (defined $mfile00);
|
---|
[169] | 1042 | push @ffiles,$mfile0 if (defined $mfile0);
|
---|
| 1043 | push @ffiles,$mfile1 if (defined $mfile1);
|
---|
| 1044 | push @ffiles,$mfile2 if (defined $mfile2);
|
---|
| 1045 | push @ffiles,$mfile3 if (defined $mfile3);
|
---|
| 1046 | }
|
---|
| 1047 |
|
---|
[77] | 1048 | if (-d "$ENV{'PBCONF'}/$pbpkg/pbfilter") {
|
---|
[231] | 1049 | $ffile00 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/all.pbf");
|
---|
[77] | 1050 | $ffile0 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dtype.pbf");
|
---|
| 1051 | $ffile1 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$dfam.pbf");
|
---|
| 1052 | $ffile2 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir.pbf");
|
---|
| 1053 | $ffile3 = "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBCONF'}/$pbpkg/pbfilter/$ddir-$dver.pbf");
|
---|
| 1054 |
|
---|
[231] | 1055 | push @ffiles,$ffile00 if (defined $ffile00);
|
---|
[77] | 1056 | push @ffiles,$ffile0 if (defined $ffile0);
|
---|
| 1057 | push @ffiles,$ffile1 if (defined $ffile1);
|
---|
| 1058 | push @ffiles,$ffile2 if (defined $ffile2);
|
---|
| 1059 | push @ffiles,$ffile3 if (defined $ffile3);
|
---|
| 1060 | }
|
---|
| 1061 | if (@ffiles) {
|
---|
| 1062 | print $LOG "DEBUG ffiles: ".Dumper(\@ffiles)."\n" if ($debug >= 1);
|
---|
[79] | 1063 |
|
---|
| 1064 | my $config = AppConfig->new({
|
---|
| 1065 | # Auto Create variables mentioned in Conf file
|
---|
| 1066 | CREATE => 1,
|
---|
| 1067 | DEBUG => 0,
|
---|
| 1068 | GLOBAL => {
|
---|
| 1069 | # Each conf item is a hash
|
---|
| 1070 | ARGCOUNT => AppConfig::ARGCOUNT_HASH
|
---|
| 1071 | }
|
---|
| 1072 | });
|
---|
| 1073 |
|
---|
[77] | 1074 | $config->file(@ffiles);
|
---|
| 1075 | $ptr = $config->get("filter");
|
---|
| 1076 | print $LOG "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1);
|
---|
| 1077 | } else {
|
---|
| 1078 | $ptr = { };
|
---|
| 1079 | }
|
---|
[79] | 1080 | %ptr = %$ptr;
|
---|
| 1081 | return(\%ptr);
|
---|
[77] | 1082 | }
|
---|
| 1083 |
|
---|
[236] | 1084 | # Function which applies filter on pb build files
|
---|
[77] | 1085 | sub pb_filter_file_pb {
|
---|
| 1086 |
|
---|
| 1087 | my $f=shift;
|
---|
| 1088 | my $ptr=shift;
|
---|
| 1089 | my %filter=%$ptr;
|
---|
| 1090 | my $destfile=shift;
|
---|
| 1091 | my $dtype=shift;
|
---|
[99] | 1092 | my $pbsuf=shift;
|
---|
[80] | 1093 | my $pbpkg=shift;
|
---|
| 1094 | my $pbver=shift;
|
---|
| 1095 | my $pbtag=shift;
|
---|
| 1096 | my $pbrev=shift;
|
---|
| 1097 | my $pbdate=shift;
|
---|
[108] | 1098 | my $defpkgdir = shift;
|
---|
| 1099 | my $extpkgdir = shift;
|
---|
[174] | 1100 | my $pbpackager = shift;
|
---|
[285] | 1101 | my $chglog = shift || undef;
|
---|
[77] | 1102 |
|
---|
[108] | 1103 | # For the moment not dynamic
|
---|
| 1104 | my $debug = 0; # Debug level
|
---|
| 1105 | my $LOG = *STDOUT; # Where to log
|
---|
| 1106 |
|
---|
[77] | 1107 | print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
|
---|
| 1108 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1109 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1110 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1111 | while (<FILE>) {
|
---|
| 1112 | my $line = $_;
|
---|
| 1113 | foreach my $s (keys %filter) {
|
---|
| 1114 | # Process single variables
|
---|
[79] | 1115 | print $LOG "DEBUG filter{$s}: $filter{$s}\n" if ($debug >= 1);
|
---|
[77] | 1116 | my $tmp = $filter{$s};
|
---|
| 1117 | next if (not defined $tmp);
|
---|
| 1118 | # Expand variables if any single one found
|
---|
[79] | 1119 | print $LOG "DEBUG tmp: $tmp\n" if ($debug >= 1);
|
---|
[77] | 1120 | if ($tmp =~ /\$/) {
|
---|
| 1121 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1122 | # special case for ChangeLog only for pb
|
---|
[259] | 1123 | } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
|
---|
[108] | 1124 | my $p = $defpkgdir->{$pbpkg};
|
---|
| 1125 | $p = $extpkgdir->{$pbpkg} if (not defined $p);
|
---|
[285] | 1126 | pb_changelog($dtype, $pbpkg, $pbver, $pbtag, $pbsuf, $p, \*DEST, $tmp, $chglog);
|
---|
[254] | 1127 | $tmp = "";
|
---|
[77] | 1128 | }
|
---|
| 1129 | $line =~ s|$s|$tmp|;
|
---|
| 1130 | }
|
---|
| 1131 | print DEST $line;
|
---|
| 1132 | }
|
---|
| 1133 | close(FILE);
|
---|
| 1134 | close(DEST);
|
---|
| 1135 | }
|
---|
| 1136 |
|
---|
| 1137 | # Function which applies filter on files (external call)
|
---|
| 1138 | sub pb_filter_file {
|
---|
| 1139 |
|
---|
| 1140 | my $f=shift;
|
---|
| 1141 | my $ptr=shift;
|
---|
| 1142 | my %filter=%$ptr;
|
---|
| 1143 | my $destfile=shift;
|
---|
[80] | 1144 | my $pbpkg=shift;
|
---|
| 1145 | my $pbver=shift;
|
---|
| 1146 | my $pbtag=shift;
|
---|
| 1147 | my $pbrev=shift;
|
---|
| 1148 | my $pbdate=shift;
|
---|
[174] | 1149 | my $pbpackager=shift;
|
---|
[77] | 1150 |
|
---|
[108] | 1151 | # For the moment not dynamic
|
---|
| 1152 | my $debug = 0; # Debug level
|
---|
| 1153 | my $LOG = *STDOUT; # Where to log
|
---|
| 1154 |
|
---|
[77] | 1155 | print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
|
---|
| 1156 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1157 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1158 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1159 | while (<FILE>) {
|
---|
| 1160 | my $line = $_;
|
---|
| 1161 | foreach my $s (keys %filter) {
|
---|
| 1162 | # Process single variables
|
---|
| 1163 | print $LOG "DEBUG filter{$s}: $filter{$s}\n" if ($debug > 1);
|
---|
| 1164 | my $tmp = $filter{$s};
|
---|
| 1165 | next if (not defined $tmp);
|
---|
| 1166 | # Expand variables if any single one found
|
---|
| 1167 | if ($tmp =~ /\$/) {
|
---|
| 1168 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1169 | }
|
---|
| 1170 | $line =~ s|$s|$tmp|;
|
---|
| 1171 | }
|
---|
| 1172 | print DEST $line;
|
---|
| 1173 | }
|
---|
| 1174 | close(FILE);
|
---|
| 1175 | close(DEST);
|
---|
| 1176 | }
|
---|
| 1177 |
|
---|
| 1178 |
|
---|
[2] | 1179 | 1;
|
---|