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