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