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