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