[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;
|
---|
[320] | 14 | use File::stat;
|
---|
[315] | 15 | use File::Copy;
|
---|
[318] | 16 | use File::Temp qw(tempdir);
|
---|
[8] | 17 | use Data::Dumper;
|
---|
[315] | 18 | use POSIX qw(strftime);
|
---|
[318] | 19 | use Time::localtime qw(localtime);
|
---|
[328] | 20 | use Date::Manip;
|
---|
| 21 | use English;
|
---|
[2] | 22 |
|
---|
[318] | 23 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 24 |
|
---|
| 25 | use Exporter;
|
---|
| 26 |
|
---|
| 27 | # Export, by default, all the functions into the namespace of
|
---|
| 28 | # any code which uses this module.
|
---|
| 29 |
|
---|
| 30 | our $debug = 0;
|
---|
| 31 | our $LOG = \*STDOUT;
|
---|
| 32 |
|
---|
| 33 | our @ISA = qw(Exporter);
|
---|
[331] | 34 | our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if 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 pb_cms_compliant pb_get_uri pb_cms_get_uri $debug $LOG);
|
---|
[318] | 35 |
|
---|
[49] | 36 | $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
|
---|
[5] | 37 |
|
---|
[74] | 38 | sub pb_env_init {
|
---|
[2] | 39 |
|
---|
[273] | 40 | my $proj=shift || undef;
|
---|
| 41 | my $pbinit=shift || undef;
|
---|
[5] | 42 | my $ver;
|
---|
| 43 | my $tag;
|
---|
[2] | 44 |
|
---|
[8] | 45 | #
|
---|
[5] | 46 | # Check project name
|
---|
[49] | 47 | # Could be with env var PBPROJ
|
---|
| 48 | # or option -p
|
---|
| 49 | # if not define take the first in conf file
|
---|
[8] | 50 | #
|
---|
[5] | 51 | if ((defined $ENV{'PBPROJ'}) &&
|
---|
| 52 | (not (defined $proj))) {
|
---|
| 53 | $proj = $ENV{'PBPROJ'};
|
---|
| 54 | }
|
---|
[69] | 55 |
|
---|
[49] | 56 | #
|
---|
[313] | 57 | # We get the pbconf file for that project
|
---|
[69] | 58 | # and use its content
|
---|
| 59 | #
|
---|
[322] | 60 | my ($pbconf) = pb_conf_read("$ENV{'PBETC'}","pbconfurl");
|
---|
| 61 | pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
|
---|
[69] | 62 |
|
---|
[313] | 63 | my %pbconf = %$pbconf;
|
---|
[69] | 64 | if (not defined $proj) {
|
---|
| 65 | # Take the first as the default project
|
---|
[313] | 66 | $proj = (keys %pbconf)[0];
|
---|
[315] | 67 | if (defined $proj) {
|
---|
[316] | 68 | pb_log(0,"WARNING: using $proj as default project as none has been specified\n");
|
---|
[322] | 69 | pb_log(0," Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
|
---|
[319] | 70 | pb_log(0," or call pb with the -p project option or use the env var PBPROJ\n");
|
---|
| 71 | pb_log(0," if you want to use another project\n");
|
---|
[313] | 72 | }
|
---|
[69] | 73 | }
|
---|
[322] | 74 | die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
|
---|
[69] | 75 |
|
---|
[313] | 76 | # That's always the environment variable that will be used
|
---|
| 77 | $ENV{'PBPROJ'} = $proj;
|
---|
[318] | 78 | pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
|
---|
[313] | 79 |
|
---|
| 80 | if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
|
---|
[322] | 81 | die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
|
---|
[313] | 82 | }
|
---|
| 83 |
|
---|
[69] | 84 | #
|
---|
[313] | 85 | # Detect the root dir for hosting all the content generated with pb
|
---|
[69] | 86 | #
|
---|
[314] | 87 | # Tree will look like this:
|
---|
| 88 | #
|
---|
[331] | 89 | # maint pbdefdir PBDEFDIR dev dir (optional)
|
---|
[315] | 90 | # | |
|
---|
| 91 | # ------------------------ --------------------
|
---|
| 92 | # | | | |
|
---|
[331] | 93 | # pbproj1 pbproj2 PBPROJ pbproj1 pbproj2
|
---|
[315] | 94 | # | |
|
---|
| 95 | # --------------------------------------------- ----------
|
---|
[322] | 96 | # * * * | | | * *
|
---|
[331] | 97 | # tag dev pbconf ... build delivery PBCONF dev tag
|
---|
[323] | 98 | # | | | PBDESTDIR |
|
---|
| 99 | # --- ------ pbrc PBBUILDDIR -------
|
---|
| 100 | # | | | | |
|
---|
[331] | 101 | # 1.1 dev tag PBROOT 1.0 1.1 PBDIR
|
---|
[314] | 102 | # |
|
---|
[319] | 103 | # -------
|
---|
| 104 | # | |
|
---|
| 105 | # 1.0 1.1
|
---|
| 106 | # |
|
---|
[314] | 107 | # ----------------------------------
|
---|
| 108 | # | | | |
|
---|
| 109 | # pkg1 pbproj1.pb pbfilter pbcl
|
---|
| 110 | # |
|
---|
| 111 | # -----------------
|
---|
| 112 | # | | |
|
---|
| 113 | # rpm deb pbfilter
|
---|
| 114 | #
|
---|
| 115 | #
|
---|
[322] | 116 | # (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
|
---|
[314] | 117 | # Names under a pbproj and the corresponding pbconf should be similar
|
---|
| 118 | #
|
---|
[313] | 119 |
|
---|
[322] | 120 | my ($pbdefdir) = pb_conf_get_if("pbdefdir");
|
---|
| 121 | my %pbdefdir = %$pbdefdir;
|
---|
[314] | 122 |
|
---|
[322] | 123 | if (not defined $ENV{'PBDEFDIR'}) {
|
---|
| 124 | if ((not defined $pbdefdir) || (not defined $pbdefdir{$ENV{'PBPROJ'}})) {
|
---|
| 125 | pb_log(0,"WARNING: no pbdefdir defined, using /var/cache\n");
|
---|
| 126 | pb_log(0," Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
[318] | 127 | pb_log(0," if you want to use another directory\n");
|
---|
[322] | 128 | $ENV{'PBDEFDIR'} = "/var/cache";
|
---|
[316] | 129 | } else {
|
---|
| 130 | # That's always the environment variable that will be used
|
---|
[322] | 131 | $ENV{'PBDEFDIR'} = $pbdefdir{$ENV{'PBPROJ'}};
|
---|
[313] | 132 | }
|
---|
[273] | 133 | }
|
---|
[108] | 134 | # Expand potential env variable in it
|
---|
[322] | 135 | eval { $ENV{'PBDEFDIR'} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
[69] | 136 |
|
---|
[322] | 137 | pb_log(2,"PBDEFDIR: $ENV{'PBDEFDIR'}\n");
|
---|
[69] | 138 | #
|
---|
[313] | 139 | # Set delivery directory
|
---|
[49] | 140 | #
|
---|
[322] | 141 | $ENV{'PBDESTDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/delivery";
|
---|
[313] | 142 |
|
---|
[318] | 143 | pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n");
|
---|
[313] | 144 | #
|
---|
| 145 | # Removes all directory existing below the delivery dir
|
---|
| 146 | # as they are temp dir only
|
---|
| 147 | # Files stay and have to be cleaned up manually if needed
|
---|
| 148 | # those files serves as communication channels between pb phases
|
---|
| 149 | # Removing them prevents a following phase to detect what has been done before
|
---|
| 150 | #
|
---|
| 151 | if (-d $ENV{'PBDESTDIR'}) {
|
---|
| 152 | opendir(DIR,$ENV{'PBDESTDIR'}) || die "Unable to open directory $ENV{'PBDESTDIR'}: $!";
|
---|
| 153 | foreach my $d (readdir(DIR)) {
|
---|
| 154 | next if ($d =~ /^\./);
|
---|
| 155 | next if (-f "$ENV{'PBDESTDIR'}/$d");
|
---|
| 156 | pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");
|
---|
[67] | 157 | }
|
---|
[313] | 158 | closedir(DIR);
|
---|
[49] | 159 | }
|
---|
[313] | 160 | if (! -d "$ENV{'PBDESTDIR'}") {
|
---|
| 161 | pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";
|
---|
| 162 | }
|
---|
[2] | 163 |
|
---|
[8] | 164 | #
|
---|
[313] | 165 | # Set build directory
|
---|
[8] | 166 | #
|
---|
[322] | 167 | $ENV{'PBBUILDDIR'}="$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/build";
|
---|
[313] | 168 | if (! -d "$ENV{'PBBUILDDIR'}") {
|
---|
| 169 | pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";
|
---|
| 170 | }
|
---|
| 171 |
|
---|
[318] | 172 | pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
|
---|
[313] | 173 | #
|
---|
| 174 | # Set temp directory
|
---|
| 175 | #
|
---|
| 176 | if (not defined $ENV{'TMPDIR'}) {
|
---|
| 177 | $ENV{'TMPDIR'}="/tmp";
|
---|
| 178 | }
|
---|
| 179 | $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 );
|
---|
[318] | 180 | pb_log(2,"PBTMP: $ENV{'PBTMP'}\n");
|
---|
[313] | 181 |
|
---|
| 182 | #
|
---|
[320] | 183 | # The following part is only useful when in cms2build
|
---|
| 184 | # In VMs/VEs we want to skip that by providing a good PBCONF env var.
|
---|
| 185 | # return values in that case are useless
|
---|
| 186 | #
|
---|
| 187 | return if (defined $ENV{'PBCONF'});
|
---|
| 188 |
|
---|
| 189 | #
|
---|
[327] | 190 | # Check pbconf cms compliance
|
---|
[313] | 191 | #
|
---|
[327] | 192 | pb_cms_compliant("pbconfdir",'PBCONF',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
|
---|
[323] | 193 |
|
---|
[314] | 194 | # Check where is our PBROOT (release tag name can't be guessed the first time)
|
---|
[323] | 195 | #
|
---|
[314] | 196 | if (not defined $ENV{'PBROOT'}) {
|
---|
| 197 | if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
|
---|
| 198 | opendir(DIR,$ENV{'PBCONF'}) || die "Unable to open directory $ENV{'PBCONF'}: $!";
|
---|
[315] | 199 | my $maxmtime = 0;
|
---|
[314] | 200 | foreach my $d (readdir(DIR)) {
|
---|
[320] | 201 | pb_log(3,"Looking at \'$d\'...");
|
---|
[314] | 202 | next if ($d =~ /^\./);
|
---|
[320] | 203 | next if (! -d "$ENV{'PBCONF'}/$d");
|
---|
| 204 | my $s = stat("$ENV{'PBCONF'}/$d");
|
---|
| 205 | next if (not defined $s);
|
---|
| 206 | pb_log(3,"KEEP\n");
|
---|
[314] | 207 | # Keep the most recent
|
---|
[320] | 208 | pb_log(2," $s->mtime\n");
|
---|
| 209 | if ($s->mtime > $maxmtime) {
|
---|
[314] | 210 | $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$d";
|
---|
[320] | 211 | $maxmtime = $s->mtime;
|
---|
[314] | 212 | }
|
---|
| 213 | }
|
---|
| 214 | closedir(DIR);
|
---|
[316] | 215 | die "No directory found under $ENV{'PBCONF'}" if (not defined $ENV{'PBROOT'});
|
---|
| 216 | pb_log(0,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n");
|
---|
[318] | 217 | pb_log(0," Please use -r release if you want to use another release\n");
|
---|
[314] | 218 | } else {
|
---|
| 219 | my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
|
---|
| 220 | # That's always the environment variable that will be used
|
---|
[316] | 221 | die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
|
---|
[315] | 222 | $ENV{'PBROOT'} = $pbroot->{$ENV{'PBPROJ'}};
|
---|
[314] | 223 | }
|
---|
| 224 | } else {
|
---|
| 225 | # transform in full path if relative
|
---|
[316] | 226 | $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ /^\//);
|
---|
| 227 | die "$ENV{'PBROOT'} is not a directory" if (not -d $ENV{'PBROOT'});
|
---|
[314] | 228 | }
|
---|
| 229 |
|
---|
[74] | 230 | my %version = ();
|
---|
[108] | 231 | my %defpkgdir = ();
|
---|
| 232 | my %extpkgdir = ();
|
---|
| 233 | my %filteredfiles = ();
|
---|
[300] | 234 | my %supfiles = ();
|
---|
[74] | 235 |
|
---|
[314] | 236 | if ((-f "$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
|
---|
[74] | 237 | # List of pkg to build by default (mandatory)
|
---|
[320] | 238 | my ($defpkgdir,$pbpackager) = pb_conf_get("defpkgdir","pbpackager");
|
---|
[74] | 239 | # List of additional pkg to build when all is called (optional)
|
---|
| 240 | # Valid version names (optional)
|
---|
| 241 | # List of files to filter (optional)
|
---|
[313] | 242 | # Project version and tag (optional)
|
---|
| 243 | my ($extpkgdir, $version, $filteredfiles, $supfiles, $pkgv, $pkgt) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles","projver","projtag");
|
---|
[315] | 244 | pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
|
---|
| 245 | pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
|
---|
| 246 | pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
|
---|
| 247 | pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
|
---|
| 248 | pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
|
---|
[74] | 249 | # Global
|
---|
| 250 | %defpkgdir = %$defpkgdir;
|
---|
[114] | 251 | %extpkgdir = %$extpkgdir if (defined $extpkgdir);
|
---|
[74] | 252 | %version = %$version if (defined $version);
|
---|
| 253 | %filteredfiles = %$filteredfiles if (defined $filteredfiles);
|
---|
[300] | 254 | %supfiles = %$supfiles if (defined $supfiles);
|
---|
[106] | 255 | #
|
---|
| 256 | # Get global Version/Tag
|
---|
| 257 | #
|
---|
| 258 | if (not defined $ENV{'PBVER'}) {
|
---|
[313] | 259 | if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
|
---|
| 260 | $ENV{'PBVER'}=$pkgv->{$ENV{'PBPROJ'}};
|
---|
[106] | 261 | } else {
|
---|
[314] | 262 | die "No projver found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
[106] | 263 | }
|
---|
[98] | 264 | }
|
---|
[314] | 265 | 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] | 266 |
|
---|
| 267 | if (not defined $ENV{'PBTAG'}) {
|
---|
[313] | 268 | if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
|
---|
| 269 | $ENV{'PBTAG'}=$pkgt->{$ENV{'PBPROJ'}};
|
---|
[106] | 270 | } else {
|
---|
[314] | 271 | die "No projtag found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
[106] | 272 | }
|
---|
[98] | 273 | }
|
---|
[314] | 274 | die "Invalid tag name $ENV{'PBTAG'} in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBTAG'} !~ /[0-9.]+/);
|
---|
[320] | 275 |
|
---|
| 276 |
|
---|
| 277 | if (not defined $ENV{'PBPACKAGER'}) {
|
---|
| 278 | if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
|
---|
| 279 | $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
|
---|
| 280 | } else {
|
---|
| 281 | die "No pbpackager found in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
[106] | 284 | } else {
|
---|
[273] | 285 | if (defined $pbinit) {
|
---|
[316] | 286 | my $ptr = pb_get_pkg();
|
---|
[317] | 287 | my @pkgs = @$ptr;
|
---|
[316] | 288 | @pkgs = ("pkg1") if (not @pkgs);
|
---|
| 289 |
|
---|
[314] | 290 | open(CONF,"> $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
|
---|
[273] | 291 | print CONF << "EOF";
|
---|
| 292 | #
|
---|
| 293 | # Project Builder configuration file
|
---|
[313] | 294 | # For project $ENV{'PBPROJ'}
|
---|
[273] | 295 | #
|
---|
| 296 | # \$Id\$
|
---|
| 297 | #
|
---|
| 298 |
|
---|
| 299 | #
|
---|
[316] | 300 | # What is the project URL
|
---|
[273] | 301 | #
|
---|
[316] | 302 | #pbproj $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 303 | #pbproj $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 304 | #pbproj $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 305 | #pbproj $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
| 306 | #pbproj $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
| 307 | #pbproj $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
[319] | 308 | #pbproj $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
|
---|
[273] | 309 |
|
---|
| 310 | #
|
---|
| 311 | # Packager label
|
---|
| 312 | #
|
---|
[320] | 313 | #pbpackager $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
|
---|
[319] | 377 | #defpkgdir $pp = dir-$pp
|
---|
[316] | 378 | EOF
|
---|
| 379 | }
|
---|
[273] | 380 |
|
---|
[316] | 381 | print CONF << "EOF";
|
---|
[273] | 382 | # Hash of additional package/package directory
|
---|
[319] | 383 | #extpkgdir minor-pkg = dir-minor-pkg
|
---|
[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 |
|
---|
[319] | 820 | pb_log(0,"$cmt... ");
|
---|
[117] | 821 | #system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
|
---|
[293] | 822 | system($cmd);
|
---|
[29] | 823 | if ($? == -1) {
|
---|
[319] | 824 | pb_log(0,"failed to execute ($cmd) : $!\n");
|
---|
[106] | 825 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[29] | 826 | } elsif ($? & 127) {
|
---|
[319] | 827 | pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n");
|
---|
[106] | 828 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
| 829 | } elsif ($? == 0) {
|
---|
[319] | 830 | pb_log(0,"OK\n");
|
---|
[29] | 831 | } else {
|
---|
[319] | 832 | pb_log(0, "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.
|
---|
[328] | 891 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if ((not defined $p1->{$ENV{'PBPROJ'}}) && (defined $p1->{'default'}));
|
---|
[242] | 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.
|
---|
[328] | 896 | $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if ((not defined $p2->{$ENV{'PBPROJ'}}) && (defined $p2->{'default'}));
|
---|
[327] | 897 | $p1 = $p2;
|
---|
[242] | 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'}}) {
|
---|
[328] | 908 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}} if (defined $p2->{$ENV{'PBPROJ'}});
|
---|
[242] | 909 | } else {
|
---|
[328] | 910 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (defined $p1->{'default'});
|
---|
[242] | 911 | }
|
---|
| 912 | }
|
---|
[327] | 913 | # Now copy back into p1 all p2 content which doesn't exist in p1
|
---|
| 914 | # p1 content (local) always has priority over p2 (project)
|
---|
| 915 | foreach my $k (keys %$p2) {
|
---|
| 916 | $p1->{$k} = $p2->{$k} if (not defined $p1->{$k});
|
---|
| 917 | }
|
---|
[242] | 918 | }
|
---|
| 919 | }
|
---|
[262] | 920 | $ptr1[$i] = $p1;
|
---|
[315] | 921 | pb_log(2,"DEBUG: param ptr1: ".Dumper(@ptr1)."\n");
|
---|
[88] | 922 | }
|
---|
[242] | 923 | return(@ptr1);
|
---|
[88] | 924 | }
|
---|
| 925 |
|
---|
| 926 | # Function which returns a pointer on a hash
|
---|
[74] | 927 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
[313] | 928 | # if that conf file doesn't exist returns undef
|
---|
| 929 | sub pb_conf_read_if {
|
---|
| 930 |
|
---|
| 931 | my $conffile = shift;
|
---|
| 932 | my @param = @_;
|
---|
| 933 |
|
---|
| 934 | open(CONF,$conffile) || return((undef));
|
---|
| 935 | close(CONF);
|
---|
| 936 | return(pb_conf_read($conffile,@param));
|
---|
| 937 | }
|
---|
| 938 |
|
---|
| 939 | # Function which returns a pointer on a hash
|
---|
| 940 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
[74] | 941 | sub pb_conf_read {
|
---|
| 942 |
|
---|
| 943 | my $conffile = shift;
|
---|
| 944 | my @param = @_;
|
---|
| 945 | my $trace;
|
---|
| 946 | my @ptr;
|
---|
[291] | 947 | my %h;
|
---|
[74] | 948 |
|
---|
[291] | 949 | open(CONF,$conffile) || die "Unable to open $conffile";
|
---|
| 950 | while(<CONF>) {
|
---|
| 951 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
[327] | 952 | pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
|
---|
[291] | 953 | $h{$1}{$2}=$3;
|
---|
| 954 | }
|
---|
[74] | 955 | }
|
---|
[291] | 956 | close(CONF);
|
---|
[74] | 957 |
|
---|
| 958 | for my $param (@param) {
|
---|
[291] | 959 | push @ptr,$h{$param};
|
---|
[74] | 960 | }
|
---|
[89] | 961 | return(@ptr);
|
---|
[74] | 962 | }
|
---|
| 963 |
|
---|
[313] | 964 | # Analyze a url passed and return protocol, account, password, server, port, path
|
---|
[314] | 965 | sub pb_get_uri {
|
---|
[313] | 966 |
|
---|
[314] | 967 | my $uri = shift || undef;
|
---|
[313] | 968 |
|
---|
[318] | 969 | pb_log(2,"DEBUG: uri:$uri\n");
|
---|
[314] | 970 | # A URL has the format protocol://[ac@]host[:port][path[?query][#fragment]].
|
---|
| 971 | # Cf man URI
|
---|
| 972 | my ($scheme, $authority, $path, $query, $fragment) =
|
---|
[318] | 973 | $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?| if (defined $uri);
|
---|
| 974 | my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?| if (defined $authority);
|
---|
| 975 |
|
---|
| 976 | $scheme = "" if (not defined $scheme);
|
---|
| 977 | $authority = "" if (not defined $authority);
|
---|
| 978 | $path = "" if (not defined $path);
|
---|
| 979 | $account = "" if (not defined $account);
|
---|
| 980 | $host = "" if (not defined $host);
|
---|
| 981 | $port = "" if (not defined $port);
|
---|
| 982 |
|
---|
[315] | 983 | pb_log(2,"DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n");
|
---|
[314] | 984 | return($scheme, $account, $host, $port, $path);
|
---|
[313] | 985 | }
|
---|
| 986 |
|
---|
| 987 |
|
---|
| 988 | # Setup environment for CMS system for URL passed
|
---|
[74] | 989 | sub pb_cms_init {
|
---|
| 990 |
|
---|
[331] | 991 | my $scheme = shift || undef;
|
---|
[74] | 992 |
|
---|
[315] | 993 | if ($scheme =~ /^svn/) {
|
---|
[331] | 994 | # svnversion more precise than svn info
|
---|
| 995 | my $tmp = `(cd "$ENV{'PBDIR'}" ; svnversion .)`;
|
---|
| 996 | chomp($tmp);
|
---|
| 997 | $ENV{'PBREVISION'}=$tmp;
|
---|
[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";
|
---|
[331] | 1002 | } elsif ($scheme =~ /^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'});
|
---|
[331] | 1006 | $ENV{'PBREVISION'}="cvs";
|
---|
[74] | 1007 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
[331] | 1008 | $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/);
|
---|
[74] | 1009 | } else {
|
---|
[315] | 1010 | die "cms $scheme unknown";
|
---|
[74] | 1011 | }
|
---|
| 1012 | }
|
---|
| 1013 |
|
---|
[315] | 1014 | sub pb_get_date {
|
---|
| 1015 |
|
---|
| 1016 | return(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 1017 | }
|
---|
| 1018 |
|
---|
[106] | 1019 | sub pb_cms_export {
|
---|
[315] | 1020 |
|
---|
[319] | 1021 | my $uri = shift;
|
---|
[108] | 1022 | my $source = shift;
|
---|
[106] | 1023 | my $destdir = shift;
|
---|
[108] | 1024 | my $tmp;
|
---|
[115] | 1025 | my $tmp1;
|
---|
[106] | 1026 |
|
---|
[315] | 1027 | my @date = pb_get_date();
|
---|
[319] | 1028 | # If it's not flat, then we have a real uri as source
|
---|
| 1029 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
[315] | 1030 |
|
---|
[321] | 1031 | if ($scheme =~ /^svn/) {
|
---|
[108] | 1032 | if (-d $source) {
|
---|
| 1033 | $tmp = $destdir;
|
---|
| 1034 | } else {
|
---|
[327] | 1035 | $tmp = "$destdir/".basename($source);
|
---|
| 1036 | pb_mkdir_p($tmp);
|
---|
[108] | 1037 | }
|
---|
[116] | 1038 | pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
|
---|
[319] | 1039 | } elsif ($scheme eq "dir") {
|
---|
[320] | 1040 | pb_system("cp -a $path $destdir","Copying $uri from DIR to $destdir");
|
---|
[319] | 1041 | } elsif (($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
| 1042 | my $f = basename($path);
|
---|
| 1043 | unlink "$ENV{'PBTMP'}/$f";
|
---|
| 1044 | if (-x "/usr/bin/wget") {
|
---|
[320] | 1045 | pb_system("/usr/bin/wget -nv -O $ENV{'PBTMP'}/$f $uri"," ");
|
---|
[319] | 1046 | } elsif (-x "/usr/bin/curl") {
|
---|
| 1047 | pb_system("/usr/bin/curl $uri -o $ENV{'PBTMP'}/$f","Downloading $uri with curl to $ENV{'PBTMP'}/$f\n");
|
---|
| 1048 | } else {
|
---|
| 1049 | die "Unable to download $uri.\nNo wget/curl available, please install one of those";
|
---|
| 1050 | }
|
---|
| 1051 | pb_cms_export("file://$ENV{'PBTMP'}/$f",$source,$destdir);
|
---|
| 1052 | } elsif ($scheme eq "file") {
|
---|
| 1053 | use File::MimeInfo;
|
---|
| 1054 | my $mm = mimetype($path);
|
---|
| 1055 | pb_log(2,"mimetype: $mm\n");
|
---|
[320] | 1056 | pb_mkdir_p($destdir);
|
---|
[319] | 1057 |
|
---|
| 1058 | if ($mm =~ /\/x-bzip-compressed-tar$/) {
|
---|
| 1059 | # tar+bzip2
|
---|
[320] | 1060 | pb_system("cd $destdir ; tar xfj $path","Extracting $path in $destdir");
|
---|
[319] | 1061 | } elsif ($mm =~ /\/x-lzma-compressed-tar$/) {
|
---|
| 1062 | # tar+lzma
|
---|
[320] | 1063 | pb_system("cd $destdir ; tar xfY $path","Extracting $path in $destdir");
|
---|
[319] | 1064 | } elsif ($mm =~ /\/x-compressed-tar$/) {
|
---|
| 1065 | # tar+gzip
|
---|
[320] | 1066 | pb_system("cd $destdir ; tar xfz $path","Extracting $path in $destdir");
|
---|
[319] | 1067 | } elsif ($mm =~ /\/x-tar$/) {
|
---|
| 1068 | # tar
|
---|
[320] | 1069 | pb_system("cd $destdir ; tar xf $path","Extracting $path in $destdir");
|
---|
[319] | 1070 | } elsif ($mm =~ /\/zip$/) {
|
---|
| 1071 | # zip
|
---|
[320] | 1072 | pb_system("cd $destdir ; unzip $path","Extracting $path in $destdir");
|
---|
[319] | 1073 | }
|
---|
[320] | 1074 | # Maybe we created an extra level of dir under destdir
|
---|
| 1075 | opendir(DIR,$destdir) || die "Unable to open $destdir";
|
---|
| 1076 | my $cnt = 0;
|
---|
| 1077 | my $d0;
|
---|
| 1078 | foreach my $d (readdir(DIR)) {
|
---|
| 1079 | pb_log(3,"Looking at \'$d\'...");
|
---|
| 1080 | next if ($d =~ /^\./);
|
---|
| 1081 | $cnt++;
|
---|
| 1082 | $d0 = $d;
|
---|
| 1083 | }
|
---|
| 1084 | closedir(DIR);
|
---|
| 1085 | # Fix that by moving everything below that extra dir under destdir
|
---|
| 1086 | # and remove the extra dir
|
---|
| 1087 | if ($cnt == 1) {
|
---|
| 1088 | pb_system("cd $destdir/$d0 ; mv * .??* .. 2>/dev/null");
|
---|
| 1089 | pb_rm_rf("$destdir/$d0");
|
---|
| 1090 | }
|
---|
[331] | 1091 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 1092 | # CVS needs a relative path !
|
---|
[106] | 1093 | my $dir=dirname($destdir);
|
---|
| 1094 | my $base=basename($destdir);
|
---|
[331] | 1095 | # CVS also needs a modules name not a dir
|
---|
[115] | 1096 | if (-d $source) {
|
---|
| 1097 | $tmp1 = $source;
|
---|
| 1098 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
[331] | 1099 | $tmp1 =~ s|$ENV{'PBDIR'}/||;
|
---|
[115] | 1100 | } else {
|
---|
| 1101 | $tmp1 = dirname($source);
|
---|
| 1102 | $tmp1 =~ s|$ENV{'PBROOT'}/||;
|
---|
[331] | 1103 | $tmp1 =~ s|$ENV{'PBDIR'}/||;
|
---|
[115] | 1104 | $tmp1 = $tmp1."/".basename($source);
|
---|
| 1105 | }
|
---|
[315] | 1106 | my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
[331] | 1107 | pb_system("cd $dir ; cvs -d $account\@$host:$path export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir");
|
---|
[106] | 1108 | } else {
|
---|
[315] | 1109 | die "cms $scheme unknown";
|
---|
[106] | 1110 | }
|
---|
| 1111 | }
|
---|
| 1112 |
|
---|
[285] | 1113 |
|
---|
| 1114 | sub pb_create_authors {
|
---|
| 1115 |
|
---|
| 1116 | my $authors=shift;
|
---|
| 1117 | my $dest=shift;
|
---|
[315] | 1118 | my $scheme=shift;
|
---|
[285] | 1119 |
|
---|
[286] | 1120 | return if ($authors eq "/dev/null");
|
---|
| 1121 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
[320] | 1122 | # Save a potentially existing AUTHORS file and write instead toi AUTHORS.pb
|
---|
| 1123 | my $ext = "";
|
---|
| 1124 | if (-f "$dest/AUTHORS") {
|
---|
| 1125 | $ext = ".pb";
|
---|
| 1126 | }
|
---|
| 1127 | open(DAUTH,"> $dest/AUTHORS$ext") || die "Unable to create $dest/AUTHORS$ext";
|
---|
[285] | 1128 | print DAUTH "Authors of the project are:\n";
|
---|
| 1129 | print DAUTH "===========================\n";
|
---|
[286] | 1130 | while (<SAUTH>) {
|
---|
[285] | 1131 | my ($nick,$gcos) = split(/:/);
|
---|
[286] | 1132 | chomp($gcos);
|
---|
[285] | 1133 | print DAUTH "$gcos";
|
---|
[315] | 1134 | if (defined $scheme) {
|
---|
[320] | 1135 | # Do not give a scheme for flat types
|
---|
| 1136 | my $endstr="";
|
---|
| 1137 | if ("$ENV{'PBREVISION'}" ne "flat") {
|
---|
| 1138 | $endstr = " under $scheme";
|
---|
| 1139 | }
|
---|
| 1140 | print DAUTH " ($nick$endstr)\n";
|
---|
[286] | 1141 | } else {
|
---|
| 1142 | print DAUTH "\n";
|
---|
| 1143 | }
|
---|
[285] | 1144 | }
|
---|
| 1145 | close(DAUTH);
|
---|
[286] | 1146 | close(SAUTH);
|
---|
[285] | 1147 | }
|
---|
| 1148 |
|
---|
[106] | 1149 | sub pb_cms_log {
|
---|
[320] | 1150 |
|
---|
[315] | 1151 | my $scheme = shift;
|
---|
[106] | 1152 | my $pkgdir = shift;
|
---|
[285] | 1153 | my $dest = shift;
|
---|
[286] | 1154 | my $chglog = shift;
|
---|
[285] | 1155 | my $authors = shift;
|
---|
[106] | 1156 |
|
---|
[315] | 1157 | pb_create_authors($authors,$dest,$scheme);
|
---|
[285] | 1158 |
|
---|
[320] | 1159 | if ($scheme =~ /^svn/) {
|
---|
[286] | 1160 | if (! -f "$dest/ChangeLog") {
|
---|
| 1161 | if (-x "/usr/bin/svn2cl") {
|
---|
[331] | 1162 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 1163 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 1164 | close(CL);
|
---|
[315] | 1165 | pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
|
---|
[286] | 1166 | } else {
|
---|
| 1167 | # To be written from pbcl
|
---|
| 1168 | pb_system("svn log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
| 1169 | }
|
---|
[285] | 1170 | }
|
---|
[320] | 1171 | } elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
[288] | 1172 | if (! -f "$dest/ChangeLog") {
|
---|
| 1173 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
| 1174 | }
|
---|
[331] | 1175 | } elsif ($scheme =~ /^cvs/) {
|
---|
[106] | 1176 | my $tmp=basename($pkgdir);
|
---|
| 1177 | # CVS needs a relative path !
|
---|
[286] | 1178 | if (! -f "$dest/ChangeLog") {
|
---|
| 1179 | if (-x "/usr/bin/cvs2cl") {
|
---|
[331] | 1180 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 1181 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 1182 | close(CL);
|
---|
[315] | 1183 | pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
|
---|
[286] | 1184 | } else {
|
---|
| 1185 | # To be written from pbcl
|
---|
| 1186 | pb_system("cvs log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
| 1187 | }
|
---|
[285] | 1188 | }
|
---|
[106] | 1189 | } else {
|
---|
[315] | 1190 | die "cms $scheme unknown";
|
---|
[106] | 1191 | }
|
---|
| 1192 | }
|
---|
| 1193 |
|
---|
[333] | 1194 | # This function is only called with a real CMS system
|
---|
[331] | 1195 | sub pb_cms_get_uri {
|
---|
[318] | 1196 |
|
---|
[315] | 1197 | my $scheme = shift;
|
---|
[314] | 1198 | my $dir = shift;
|
---|
[315] | 1199 |
|
---|
| 1200 | my $res = "";
|
---|
[204] | 1201 | my $void = "";
|
---|
[106] | 1202 |
|
---|
[315] | 1203 | if ($scheme =~ /^svn/) {
|
---|
[314] | 1204 | open(PIPE,"LANGUAGE=C svn info $dir |") || return("");
|
---|
[204] | 1205 | while (<PIPE>) {
|
---|
[331] | 1206 | ($void,$res) = split(/^URL:/) if (/^URL:/);
|
---|
[204] | 1207 | }
|
---|
[318] | 1208 | $res =~ s/^\s*//;
|
---|
[204] | 1209 | close(PIPE);
|
---|
[315] | 1210 | chomp($res);
|
---|
[331] | 1211 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 1212 | # This path is always the root path of CVS, but we may be below
|
---|
| 1213 | open(FILE,"$dir/CVS/Root") || die "$dir isn't CVS controlled";
|
---|
| 1214 | $res = <FILE>;
|
---|
| 1215 | chomp($res);
|
---|
| 1216 | close(FILE);
|
---|
| 1217 | # Find where we are in the tree
|
---|
| 1218 | my $rdir = $dir;
|
---|
| 1219 | while ((! -d "$rdir/CVSROOT") && ($rdir ne "/")) {
|
---|
| 1220 | $rdir = dirname($rdir);
|
---|
| 1221 | }
|
---|
| 1222 | die "Unable to find a CVSROOT dir in the parents of $dir" if (! -d "$rdir/CVSROOT");
|
---|
| 1223 | #compute our place under that root dir - should be a relative path
|
---|
| 1224 | $dir =~ s|^$rdir||;
|
---|
| 1225 | my $suffix = "";
|
---|
| 1226 | $suffix = "$dir" if ($dir ne "");
|
---|
| 1227 |
|
---|
| 1228 | my $prefix = "";
|
---|
| 1229 | if ($scheme =~ /ssh/) {
|
---|
| 1230 | $prefix = "cvs+ssh://";
|
---|
| 1231 | } else {
|
---|
| 1232 | $prefix = "cvs://";
|
---|
| 1233 | }
|
---|
| 1234 | $res = $prefix.$res.$suffix;
|
---|
[204] | 1235 | } else {
|
---|
[315] | 1236 | die "cms $scheme unknown";
|
---|
[204] | 1237 | }
|
---|
[318] | 1238 | pb_log(2,"Found CMS info: $res\n");
|
---|
[315] | 1239 | return($res);
|
---|
[204] | 1240 | }
|
---|
| 1241 |
|
---|
| 1242 | sub pb_cms_copy {
|
---|
[315] | 1243 | my $scheme = shift;
|
---|
[204] | 1244 | my $oldurl = shift;
|
---|
| 1245 | my $newurl = shift;
|
---|
| 1246 |
|
---|
[331] | 1247 | if ($scheme =~ /^svn/) {
|
---|
[212] | 1248 | pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");
|
---|
[315] | 1249 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1250 | } elsif ($scheme =~ /^cvs/) {
|
---|
[204] | 1251 | } else {
|
---|
[315] | 1252 | die "cms $scheme unknown";
|
---|
[204] | 1253 | }
|
---|
| 1254 | }
|
---|
| 1255 |
|
---|
| 1256 | sub pb_cms_checkout {
|
---|
[315] | 1257 | my $scheme = shift;
|
---|
[204] | 1258 | my $url = shift;
|
---|
| 1259 | my $destination = shift;
|
---|
| 1260 |
|
---|
[315] | 1261 | if ($scheme =~ /^svn/) {
|
---|
[320] | 1262 | pb_system("svn co $url $destination","Checking out $url to $destination ");
|
---|
[315] | 1263 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1264 | } elsif ($scheme =~ /^cvs/) {
|
---|
[204] | 1265 | } else {
|
---|
[315] | 1266 | die "cms $scheme unknown";
|
---|
[204] | 1267 | }
|
---|
| 1268 | }
|
---|
| 1269 |
|
---|
[208] | 1270 | sub pb_cms_checkin {
|
---|
[315] | 1271 | my $scheme = shift;
|
---|
[208] | 1272 | my $dir = shift;
|
---|
| 1273 |
|
---|
[212] | 1274 | my $ver = basename($dir);
|
---|
[331] | 1275 | if ($scheme =~ /^svn/) {
|
---|
[212] | 1276 | pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir");
|
---|
[208] | 1277 | pb_system("svn up $dir","Updating $dir");
|
---|
[315] | 1278 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1279 | } elsif ($scheme =~ /^cvs/) {
|
---|
[208] | 1280 | } else {
|
---|
[315] | 1281 | die "cms $scheme unknown";
|
---|
[208] | 1282 | }
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
[204] | 1285 | sub pb_cms_isdiff {
|
---|
[315] | 1286 | my $scheme = shift;
|
---|
[204] | 1287 |
|
---|
[331] | 1288 | if ($scheme =~ /^svn/) {
|
---|
[204] | 1289 | open(PIPE,"svn diff $ENV{'PBROOT'} |") || die "Unable to get svn diff from $ENV{'PBROOT'}";
|
---|
| 1290 | my $l = 0;
|
---|
| 1291 | while (<PIPE>) {
|
---|
| 1292 | $l++;
|
---|
| 1293 | }
|
---|
| 1294 | return($l);
|
---|
[315] | 1295 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1296 | } elsif ($scheme =~ /^cvs/) {
|
---|
[204] | 1297 | } else {
|
---|
[315] | 1298 | die "cms $scheme unknown";
|
---|
[204] | 1299 | }
|
---|
| 1300 | }
|
---|
| 1301 |
|
---|
[77] | 1302 | # Get all filters to apply
|
---|
| 1303 | # They're cumulative from less specific to most specific
|
---|
| 1304 | # suffix is .pbf
|
---|
| 1305 |
|
---|
| 1306 | sub pb_get_filters {
|
---|
| 1307 |
|
---|
| 1308 | my @ffiles;
|
---|
[235] | 1309 | my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3);
|
---|
| 1310 | my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3);
|
---|
[77] | 1311 | my $pbpkg = shift || die "No package specified";
|
---|
[236] | 1312 | my $dtype = shift || "";
|
---|
| 1313 | my $dfam = shift || "";
|
---|
| 1314 | my $ddir = shift || "";
|
---|
| 1315 | my $dver = shift || "";
|
---|
[77] | 1316 | my $ptr; # returned value pointer on the hash of filters
|
---|
[79] | 1317 | my %ptr;
|
---|
[291] | 1318 | my %h;
|
---|
[77] | 1319 |
|
---|
[169] | 1320 | # Global filter files first, then package specificities
|
---|
[314] | 1321 | if (-d "$ENV{'PBROOT'}/pbfilter") {
|
---|
| 1322 | $mfile00 = "$ENV{'PBROOT'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/all.pbf");
|
---|
| 1323 | $mfile0 = "$ENV{'PBROOT'}/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$dtype.pbf");
|
---|
| 1324 | $mfile1 = "$ENV{'PBROOT'}/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$dfam.pbf");
|
---|
| 1325 | $mfile2 = "$ENV{'PBROOT'}/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$ddir.pbf");
|
---|
| 1326 | $mfile3 = "$ENV{'PBROOT'}/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOT'}/pbfilter/$ddir-$dver.pbf");
|
---|
[169] | 1327 |
|
---|
[231] | 1328 | push @ffiles,$mfile00 if (defined $mfile00);
|
---|
[169] | 1329 | push @ffiles,$mfile0 if (defined $mfile0);
|
---|
| 1330 | push @ffiles,$mfile1 if (defined $mfile1);
|
---|
| 1331 | push @ffiles,$mfile2 if (defined $mfile2);
|
---|
| 1332 | push @ffiles,$mfile3 if (defined $mfile3);
|
---|
| 1333 | }
|
---|
| 1334 |
|
---|
[314] | 1335 | if (-d "$ENV{'PBROOT'}/$pbpkg/pbfilter") {
|
---|
| 1336 | $ffile00 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/all.pbf");
|
---|
| 1337 | $ffile0 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dtype.pbf");
|
---|
| 1338 | $ffile1 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$dfam.pbf");
|
---|
| 1339 | $ffile2 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir.pbf");
|
---|
| 1340 | $ffile3 = "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOT'}/$pbpkg/pbfilter/$ddir-$dver.pbf");
|
---|
[77] | 1341 |
|
---|
[231] | 1342 | push @ffiles,$ffile00 if (defined $ffile00);
|
---|
[77] | 1343 | push @ffiles,$ffile0 if (defined $ffile0);
|
---|
| 1344 | push @ffiles,$ffile1 if (defined $ffile1);
|
---|
| 1345 | push @ffiles,$ffile2 if (defined $ffile2);
|
---|
| 1346 | push @ffiles,$ffile3 if (defined $ffile3);
|
---|
| 1347 | }
|
---|
| 1348 | if (@ffiles) {
|
---|
[315] | 1349 | pb_log(2,"DEBUG ffiles: ".Dumper(\@ffiles)."\n");
|
---|
[79] | 1350 |
|
---|
[291] | 1351 | foreach my $f (@ffiles) {
|
---|
| 1352 | open(CONF,$f) || next;
|
---|
| 1353 | while(<CONF>) {
|
---|
| 1354 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
| 1355 | $h{$1}{$2}=$3;
|
---|
| 1356 | }
|
---|
[79] | 1357 | }
|
---|
[291] | 1358 | close(CONF);
|
---|
[79] | 1359 |
|
---|
[291] | 1360 | $ptr = $h{"filter"};
|
---|
[315] | 1361 | pb_log(2,"DEBUG f:".Dumper($ptr)."\n");
|
---|
[291] | 1362 | }
|
---|
[77] | 1363 | } else {
|
---|
| 1364 | $ptr = { };
|
---|
| 1365 | }
|
---|
[79] | 1366 | %ptr = %$ptr;
|
---|
| 1367 | return(\%ptr);
|
---|
[77] | 1368 | }
|
---|
| 1369 |
|
---|
[236] | 1370 | # Function which applies filter on pb build files
|
---|
[77] | 1371 | sub pb_filter_file_pb {
|
---|
| 1372 |
|
---|
| 1373 | my $f=shift;
|
---|
| 1374 | my $ptr=shift;
|
---|
| 1375 | my %filter=%$ptr;
|
---|
| 1376 | my $destfile=shift;
|
---|
| 1377 | my $dtype=shift;
|
---|
[99] | 1378 | my $pbsuf=shift;
|
---|
[297] | 1379 | my $pbproj=shift;
|
---|
[80] | 1380 | my $pbpkg=shift;
|
---|
| 1381 | my $pbver=shift;
|
---|
| 1382 | my $pbtag=shift;
|
---|
| 1383 | my $pbrev=shift;
|
---|
| 1384 | my $pbdate=shift;
|
---|
[108] | 1385 | my $defpkgdir = shift;
|
---|
| 1386 | my $extpkgdir = shift;
|
---|
[174] | 1387 | my $pbpackager = shift;
|
---|
[285] | 1388 | my $chglog = shift || undef;
|
---|
[77] | 1389 |
|
---|
[315] | 1390 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
[77] | 1391 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1392 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1393 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1394 | while (<FILE>) {
|
---|
| 1395 | my $line = $_;
|
---|
| 1396 | foreach my $s (keys %filter) {
|
---|
| 1397 | # Process single variables
|
---|
[315] | 1398 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
[77] | 1399 | my $tmp = $filter{$s};
|
---|
| 1400 | next if (not defined $tmp);
|
---|
| 1401 | # Expand variables if any single one found
|
---|
[315] | 1402 | pb_log(2,"DEBUG tmp: $tmp\n");
|
---|
[77] | 1403 | if ($tmp =~ /\$/) {
|
---|
| 1404 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1405 | # special case for ChangeLog only for pb
|
---|
[259] | 1406 | } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
|
---|
[108] | 1407 | my $p = $defpkgdir->{$pbpkg};
|
---|
| 1408 | $p = $extpkgdir->{$pbpkg} if (not defined $p);
|
---|
[285] | 1409 | pb_changelog($dtype, $pbpkg, $pbver, $pbtag, $pbsuf, $p, \*DEST, $tmp, $chglog);
|
---|
[254] | 1410 | $tmp = "";
|
---|
[77] | 1411 | }
|
---|
| 1412 | $line =~ s|$s|$tmp|;
|
---|
| 1413 | }
|
---|
| 1414 | print DEST $line;
|
---|
| 1415 | }
|
---|
| 1416 | close(FILE);
|
---|
| 1417 | close(DEST);
|
---|
| 1418 | }
|
---|
| 1419 |
|
---|
| 1420 | # Function which applies filter on files (external call)
|
---|
[315] | 1421 | sub pb_filter_file_inplace {
|
---|
| 1422 |
|
---|
| 1423 | my $ptr=shift;
|
---|
| 1424 | my %filter=%$ptr;
|
---|
| 1425 | my $destfile=shift;
|
---|
| 1426 | my $pbproj=shift;
|
---|
| 1427 | my $pbpkg=shift;
|
---|
| 1428 | my $pbver=shift;
|
---|
| 1429 | my $pbtag=shift;
|
---|
| 1430 | my $pbrev=shift;
|
---|
| 1431 | my $pbdate=shift;
|
---|
| 1432 | my $pbpackager=shift;
|
---|
| 1433 |
|
---|
| 1434 | my $cp = "$ENV{'PBTMP'}/".basename($destfile);
|
---|
| 1435 | copy($destfile,$cp) || die "Unable to create $cp";
|
---|
| 1436 |
|
---|
| 1437 | pb_filter_file($cp,$ptr,$destfile,$pbproj,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
|
---|
| 1438 | unlink $cp;
|
---|
| 1439 | }
|
---|
| 1440 |
|
---|
| 1441 | # Function which applies filter on files (external call)
|
---|
[77] | 1442 | sub pb_filter_file {
|
---|
| 1443 |
|
---|
| 1444 | my $f=shift;
|
---|
| 1445 | my $ptr=shift;
|
---|
| 1446 | my %filter=%$ptr;
|
---|
| 1447 | my $destfile=shift;
|
---|
[298] | 1448 | my $pbproj=shift;
|
---|
[80] | 1449 | my $pbpkg=shift;
|
---|
| 1450 | my $pbver=shift;
|
---|
| 1451 | my $pbtag=shift;
|
---|
| 1452 | my $pbrev=shift;
|
---|
| 1453 | my $pbdate=shift;
|
---|
[174] | 1454 | my $pbpackager=shift;
|
---|
[77] | 1455 |
|
---|
[315] | 1456 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
[77] | 1457 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1458 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1459 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1460 | while (<FILE>) {
|
---|
| 1461 | my $line = $_;
|
---|
| 1462 | foreach my $s (keys %filter) {
|
---|
| 1463 | # Process single variables
|
---|
[315] | 1464 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
[77] | 1465 | my $tmp = $filter{$s};
|
---|
| 1466 | next if (not defined $tmp);
|
---|
| 1467 | # Expand variables if any single one found
|
---|
| 1468 | if ($tmp =~ /\$/) {
|
---|
| 1469 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1470 | }
|
---|
| 1471 | $line =~ s|$s|$tmp|;
|
---|
| 1472 | }
|
---|
| 1473 | print DEST $line;
|
---|
| 1474 | }
|
---|
| 1475 | close(FILE);
|
---|
| 1476 | close(DEST);
|
---|
| 1477 | }
|
---|
| 1478 |
|
---|
[315] | 1479 | sub pb_log_init {
|
---|
[77] | 1480 |
|
---|
[315] | 1481 | $debug = shift || 0;
|
---|
| 1482 | $LOG = shift || \*STDOUT;
|
---|
| 1483 |
|
---|
| 1484 | }
|
---|
| 1485 |
|
---|
| 1486 | sub pb_log {
|
---|
| 1487 |
|
---|
| 1488 | my $dlevel = shift;
|
---|
| 1489 | my $msg = shift;
|
---|
| 1490 |
|
---|
[318] | 1491 | print $LOG "$msg" if ($dlevel <= $debug);
|
---|
[315] | 1492 | }
|
---|
| 1493 |
|
---|
[316] | 1494 | #
|
---|
| 1495 | # Return the list of packages we are working on
|
---|
| 1496 | #
|
---|
| 1497 | sub pb_get_pkg {
|
---|
| 1498 |
|
---|
| 1499 | my @pkgs = ();
|
---|
| 1500 | my $defpkgdir = shift || undef;
|
---|
| 1501 | my $extpkgdir = shift || undef;
|
---|
| 1502 |
|
---|
| 1503 | # Get packages list
|
---|
| 1504 | if (not defined $ARGV[0]) {
|
---|
| 1505 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 1506 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
[317] | 1507 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
[316] | 1508 | push(@pkgs, keys %$extpkgdir) if (defined $extpkgdir);
|
---|
| 1509 | } else {
|
---|
| 1510 | @pkgs = @ARGV;
|
---|
| 1511 | }
|
---|
| 1512 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 1513 | return(\@pkgs);
|
---|
| 1514 | }
|
---|
| 1515 |
|
---|
[327] | 1516 | sub pb_cms_compliant {
|
---|
| 1517 |
|
---|
| 1518 | my $param = shift;
|
---|
| 1519 | my $envar = shift;
|
---|
| 1520 | my $defdir = shift;
|
---|
| 1521 | my $uri = shift;
|
---|
| 1522 | my $pbinit = shift;
|
---|
| 1523 | #
|
---|
| 1524 | # Check pbconf/project cms compliance
|
---|
| 1525 | #
|
---|
| 1526 |
|
---|
| 1527 | my ($pdir) = pb_conf_get_if($param);
|
---|
| 1528 | my %pdir = %$pdir;
|
---|
| 1529 |
|
---|
| 1530 | if ((defined $pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {
|
---|
| 1531 | # That's always the environment variable that will be used
|
---|
| 1532 | $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};
|
---|
| 1533 | } else {
|
---|
| 1534 | pb_log(0,"WARNING: no $param defined, using $defdir\n");
|
---|
| 1535 | pb_log(0," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
| 1536 | pb_log(0," if you want to use another directory\n");
|
---|
| 1537 | $ENV{$envar} = "$defdir";
|
---|
| 1538 | }
|
---|
| 1539 |
|
---|
| 1540 | # Expand potential env variable in it
|
---|
| 1541 | eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
| 1542 | pb_log(2,"$envar: $ENV{$envar}\n");
|
---|
| 1543 |
|
---|
| 1544 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
| 1545 |
|
---|
| 1546 | if ((! -d "$ENV{$envar}") || (defined $pbinit)) {
|
---|
| 1547 | pb_log(1,"Checking out $uri\n");
|
---|
| 1548 | pb_cms_checkout($scheme,$uri,$ENV{$envar});
|
---|
[333] | 1549 | } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/)) {
|
---|
| 1550 | # Do not compare if it's not a real cms
|
---|
| 1551 | return;
|
---|
[327] | 1552 | } else {
|
---|
| 1553 | pb_log(1,"$uri found locally, checking content\n");
|
---|
[331] | 1554 | my $cmsurl = pb_cms_get_uri($scheme,$ENV{$envar});
|
---|
[327] | 1555 | my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
|
---|
| 1556 | if ($cmsurl ne $uri) {
|
---|
| 1557 | # The local content doesn't correpond to the repository
|
---|
| 1558 | pb_log(0,"ERROR: Inconsistency detected:\n");
|
---|
| 1559 | pb_log(0," * $ENV{$envar} refers to $cmsurl but\n");
|
---|
| 1560 | pb_log(0," * $ENV{'PBETC'} refers to $uri\n");
|
---|
| 1561 | die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
|
---|
| 1562 | } else {
|
---|
| 1563 | pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
|
---|
| 1564 | # they match - do nothing - there may be local changes
|
---|
| 1565 | }
|
---|
| 1566 | }
|
---|
| 1567 | }
|
---|
| 1568 |
|
---|
[328] | 1569 | sub pb_changelog {
|
---|
| 1570 |
|
---|
| 1571 | my $dtype = shift;
|
---|
| 1572 | my $pkg = shift;
|
---|
| 1573 | my $pbver = shift;
|
---|
| 1574 | my $pbtag = shift;
|
---|
| 1575 | my $dsuf = shift;
|
---|
| 1576 | my $path = shift;
|
---|
| 1577 | my $OUTPUT = shift;
|
---|
| 1578 | my $doit = shift;
|
---|
| 1579 | my $chglog = shift || undef;
|
---|
| 1580 |
|
---|
| 1581 | my $log = "";
|
---|
| 1582 |
|
---|
| 1583 | # For date handling
|
---|
| 1584 | $ENV{LANG}="C";
|
---|
| 1585 |
|
---|
| 1586 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
| 1587 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
| 1588 | (not (defined $pbver)) || ($pbver eq "") ||
|
---|
| 1589 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
| 1590 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
| 1591 | (not (defined $path)) || ($path eq "") ||
|
---|
| 1592 | (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
|
---|
| 1593 | (not (defined $doit)) || ($doit eq "")) {
|
---|
| 1594 | print $OUTPUT "\n";
|
---|
| 1595 | return;
|
---|
| 1596 | }
|
---|
| 1597 |
|
---|
| 1598 | if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
|
---|
| 1599 | #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
|
---|
| 1600 | print $OUTPUT "\n";
|
---|
| 1601 | return;
|
---|
| 1602 | }
|
---|
| 1603 |
|
---|
| 1604 | my $date;
|
---|
| 1605 | my $ndate;
|
---|
| 1606 | my $n2date;
|
---|
| 1607 | my $ver;
|
---|
| 1608 | my $ver2;
|
---|
| 1609 | my ($packager) = pb_conf_get("pbpackager");
|
---|
| 1610 |
|
---|
| 1611 | # If we don't need to do it, or don't have it fake something
|
---|
| 1612 | if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
|
---|
| 1613 | my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 1614 | $date = strftime("%Y-%m-%d", @date);
|
---|
| 1615 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 1616 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 1617 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 1618 | $ver2 = "$pbver-$pbtag$dsuf";
|
---|
| 1619 | print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
| 1620 | print $OUTPUT "- Updated to $pbver\n";
|
---|
| 1621 | }
|
---|
| 1622 | if ($dtype eq "deb") {
|
---|
| 1623 | print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
|
---|
| 1624 | print $OUTPUT "\n";
|
---|
| 1625 | print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
| 1626 | }
|
---|
| 1627 | return;
|
---|
| 1628 | }
|
---|
| 1629 |
|
---|
| 1630 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
| 1631 |
|
---|
| 1632 | # Skip first 4 lines
|
---|
| 1633 | my $tmp = <INPUT>;
|
---|
| 1634 | $tmp = <INPUT>;
|
---|
| 1635 | $tmp = <INPUT>;
|
---|
| 1636 | if ($dtype eq "announce") {
|
---|
| 1637 | print $OUTPUT $tmp;
|
---|
| 1638 | }
|
---|
| 1639 | $tmp = <INPUT>;
|
---|
| 1640 | if ($dtype eq "announce") {
|
---|
| 1641 | print $OUTPUT $tmp;
|
---|
| 1642 | }
|
---|
| 1643 |
|
---|
| 1644 | my $first=1;
|
---|
| 1645 |
|
---|
| 1646 | # Handle each block separated by newline
|
---|
| 1647 | while (<INPUT>) {
|
---|
| 1648 | ($ver, $date) = split(/ /);
|
---|
| 1649 | $ver =~ s/^v//;
|
---|
| 1650 | chomp($date);
|
---|
| 1651 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
| 1652 | #pb_log(2,"**$date**\n";
|
---|
| 1653 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 1654 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 1655 | #pb_log(2,"**$ndate**\n";
|
---|
| 1656 |
|
---|
| 1657 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 1658 | if ($ver !~ /-/) {
|
---|
| 1659 | if ($first eq 1) {
|
---|
| 1660 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
| 1661 | $first=0;
|
---|
| 1662 | } else {
|
---|
| 1663 | $ver2 = "$ver-1$dsuf";
|
---|
| 1664 | }
|
---|
| 1665 | } else {
|
---|
| 1666 | $ver2 = "$ver$dsuf";
|
---|
| 1667 | }
|
---|
| 1668 | print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
| 1669 | print $OUTPUT "- Updated to $ver\n";
|
---|
| 1670 | }
|
---|
| 1671 | if ($dtype eq "deb") {
|
---|
| 1672 | print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
| 1673 | print $OUTPUT "\n";
|
---|
| 1674 | }
|
---|
| 1675 |
|
---|
| 1676 | $tmp = <INPUT>;
|
---|
| 1677 | while ($tmp !~ /^$/) {
|
---|
| 1678 | if ($dtype eq "deb") {
|
---|
| 1679 | $tmp =~ s/^- //;
|
---|
| 1680 | print $OUTPUT " * $tmp";
|
---|
| 1681 | } elsif ($dtype eq "rpm") {
|
---|
| 1682 | print $OUTPUT "$tmp";
|
---|
| 1683 | } else {
|
---|
| 1684 | print $OUTPUT "$tmp";
|
---|
| 1685 | }
|
---|
| 1686 | last if (eof(INPUT));
|
---|
| 1687 | $tmp = <INPUT>;
|
---|
| 1688 | }
|
---|
| 1689 | print $OUTPUT "\n";
|
---|
| 1690 |
|
---|
| 1691 | if ($dtype eq "deb") {
|
---|
| 1692 | # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
|
---|
| 1693 | print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
| 1694 | }
|
---|
| 1695 |
|
---|
| 1696 | last if (eof(INPUT));
|
---|
| 1697 | last if ($dtype eq "announce");
|
---|
| 1698 | }
|
---|
| 1699 | close(INPUT);
|
---|
| 1700 | }
|
---|
[2] | 1701 | 1;
|
---|