[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);
|
---|
[376] | 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_cms_checkin pb_get_date pb_log pb_log_init pb_get_pkg pb_cms_get_pkg pb_get_uri pb_cms_get_uri $debug $LOG);
|
---|
[318] | 35 |
|
---|
[74] | 36 | sub pb_env_init {
|
---|
[2] | 37 |
|
---|
[273] | 38 | my $proj=shift || undef;
|
---|
| 39 | my $pbinit=shift || undef;
|
---|
[353] | 40 | my $action=shift;
|
---|
[5] | 41 | my $ver;
|
---|
| 42 | my $tag;
|
---|
[2] | 43 |
|
---|
[355] | 44 | $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
|
---|
| 45 |
|
---|
[8] | 46 | #
|
---|
[5] | 47 | # Check project name
|
---|
[49] | 48 | # Could be with env var PBPROJ
|
---|
| 49 | # or option -p
|
---|
| 50 | # if not define take the first in conf file
|
---|
[8] | 51 | #
|
---|
[5] | 52 | if ((defined $ENV{'PBPROJ'}) &&
|
---|
| 53 | (not (defined $proj))) {
|
---|
| 54 | $proj = $ENV{'PBPROJ'};
|
---|
| 55 | }
|
---|
[69] | 56 |
|
---|
[49] | 57 | #
|
---|
[313] | 58 | # We get the pbconf file for that project
|
---|
[69] | 59 | # and use its content
|
---|
| 60 | #
|
---|
[322] | 61 | my ($pbconf) = pb_conf_read("$ENV{'PBETC'}","pbconfurl");
|
---|
| 62 | pb_log(2,"DEBUG pbconfurl: ".Dumper($pbconf)."\n");
|
---|
[69] | 63 |
|
---|
[313] | 64 | my %pbconf = %$pbconf;
|
---|
[69] | 65 | if (not defined $proj) {
|
---|
| 66 | # Take the first as the default project
|
---|
[313] | 67 | $proj = (keys %pbconf)[0];
|
---|
[315] | 68 | if (defined $proj) {
|
---|
[339] | 69 | pb_log(1,"WARNING: using $proj as default project as none has been specified\n");
|
---|
| 70 | pb_log(1," Please either create a pbconfurl reference for project $proj in $ENV{'PBETC'}\n");
|
---|
| 71 | pb_log(1," or call pb with the -p project option or use the env var PBPROJ\n");
|
---|
| 72 | pb_log(1," if you want to use another project\n");
|
---|
[313] | 73 | }
|
---|
[69] | 74 | }
|
---|
[322] | 75 | die "No project defined - use env var PBPROJ or -p proj or a pbconfurl entry in $ENV{'PBETC'}" if (not (defined $proj));
|
---|
[69] | 76 |
|
---|
[313] | 77 | # That's always the environment variable that will be used
|
---|
| 78 | $ENV{'PBPROJ'} = $proj;
|
---|
[318] | 79 | pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n");
|
---|
[313] | 80 |
|
---|
| 81 | if (not defined ($pbconf{$ENV{'PBPROJ'}})) {
|
---|
[322] | 82 | die "Please create a pbconfurl reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n";
|
---|
[313] | 83 | }
|
---|
| 84 |
|
---|
[69] | 85 | #
|
---|
[313] | 86 | # Detect the root dir for hosting all the content generated with pb
|
---|
[69] | 87 | #
|
---|
[314] | 88 | # Tree will look like this:
|
---|
| 89 | #
|
---|
[331] | 90 | # maint pbdefdir PBDEFDIR dev dir (optional)
|
---|
[315] | 91 | # | |
|
---|
| 92 | # ------------------------ --------------------
|
---|
| 93 | # | | | |
|
---|
[339] | 94 | # pbproj1 pbproj2 PBPROJ pbproj1 pbproj2 PBPROJDIR
|
---|
[315] | 95 | # | |
|
---|
| 96 | # --------------------------------------------- ----------
|
---|
[322] | 97 | # * * * | | | * *
|
---|
[339] | 98 | # tag dev pbconf ... build delivery PBCONFDIR dev tag
|
---|
[323] | 99 | # | | | PBDESTDIR |
|
---|
| 100 | # --- ------ pbrc PBBUILDDIR -------
|
---|
| 101 | # | | | | |
|
---|
[339] | 102 | # 1.1 dev tag 1.0 1.1 PBDIR
|
---|
[314] | 103 | # |
|
---|
[319] | 104 | # -------
|
---|
| 105 | # | |
|
---|
[339] | 106 | # 1.0 1.1 PBROOTDIR
|
---|
[319] | 107 | # |
|
---|
[314] | 108 | # ----------------------------------
|
---|
| 109 | # | | | |
|
---|
| 110 | # pkg1 pbproj1.pb pbfilter pbcl
|
---|
| 111 | # |
|
---|
| 112 | # -----------------
|
---|
| 113 | # | | |
|
---|
| 114 | # rpm deb pbfilter
|
---|
| 115 | #
|
---|
| 116 | #
|
---|
[322] | 117 | # (*) By default, if no relocation in .pbrc, dev dir is taken in the maint pbdefdir (when appropriate)
|
---|
[314] | 118 | # Names under a pbproj and the corresponding pbconf should be similar
|
---|
| 119 | #
|
---|
[313] | 120 |
|
---|
[322] | 121 | my ($pbdefdir) = pb_conf_get_if("pbdefdir");
|
---|
[314] | 122 |
|
---|
[322] | 123 | if (not defined $ENV{'PBDEFDIR'}) {
|
---|
[344] | 124 | if ((not defined $pbdefdir) || (not defined $pbdefdir->{$ENV{'PBPROJ'}})) {
|
---|
[339] | 125 | pb_log(1,"WARNING: no pbdefdir defined, using /var/cache\n");
|
---|
| 126 | pb_log(1," Please create a pbdefdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
| 127 | pb_log(1," 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
|
---|
[344] | 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 | #
|
---|
[358] | 183 | # The following part is only useful when in cms2something of newver
|
---|
[353] | 184 | # In VMs/VEs we want to skip that by providing good env vars.
|
---|
[320] | 185 | # return values in that case are useless
|
---|
| 186 | #
|
---|
[358] | 187 | if (($action =~ /^cms2/) || ($action =~ /^newver$/)) {
|
---|
[320] | 188 |
|
---|
[353] | 189 | #
|
---|
| 190 | # Check pbconf cms compliance
|
---|
| 191 | #
|
---|
| 192 | pb_cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
|
---|
[323] | 193 |
|
---|
[353] | 194 | # Check where is our PBROOTDIR (release tag name can't be guessed the first time)
|
---|
| 195 | #
|
---|
| 196 | if (not defined $ENV{'PBROOTDIR'}) {
|
---|
| 197 | if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
|
---|
| 198 | opendir(DIR,$ENV{'PBCONFDIR'}) || die "Unable to open directory $ENV{'PBCONFDIR'}: $!";
|
---|
| 199 | my $maxmtime = 0;
|
---|
| 200 | foreach my $d (readdir(DIR)) {
|
---|
| 201 | pb_log(3,"Looking at \'$d\'...");
|
---|
| 202 | next if ($d =~ /^\./);
|
---|
| 203 | next if (! -d "$ENV{'PBCONFDIR'}/$d");
|
---|
| 204 | my $s = stat("$ENV{'PBCONFDIR'}/$d");
|
---|
| 205 | next if (not defined $s);
|
---|
| 206 | pb_log(3,"KEEP\n");
|
---|
| 207 | # Keep the most recent
|
---|
| 208 | pb_log(2," $s->mtime\n");
|
---|
| 209 | if ($s->mtime > $maxmtime) {
|
---|
| 210 | $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$d";
|
---|
| 211 | $maxmtime = $s->mtime;
|
---|
| 212 | }
|
---|
[314] | 213 | }
|
---|
[353] | 214 | closedir(DIR);
|
---|
| 215 | die "No directory found under $ENV{'PBCONFDIR'}" if (not defined $ENV{'PBROOTDIR'});
|
---|
| 216 | pb_log(1,"WARNING: no pbroot defined, using $ENV{'PBROOTDIR'}\n");
|
---|
| 217 | pb_log(1," Please use -r release if you want to use another release\n");
|
---|
| 218 | } else {
|
---|
| 219 | my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
|
---|
| 220 | # That's always the environment variable that will be used
|
---|
| 221 | die "Please remove inconsistent $ENV{'PBDESTDIR'}/pbrc" if ((not defined $pbroot) || (not defined $pbroot->{$ENV{'PBPROJ'}}));
|
---|
| 222 | $ENV{'PBROOTDIR'} = $pbroot->{$ENV{'PBPROJ'}};
|
---|
[314] | 223 | }
|
---|
| 224 | } else {
|
---|
[353] | 225 | # transform in full path if relative
|
---|
| 226 | $ENV{'PBROOTDIR'} = "$ENV{'PBCONFDIR'}/$ENV{'PBROOTDIR'}" if ($ENV{'PBROOTDIR'} !~ /^\//);
|
---|
| 227 | pb_mkdir_p($ENV{'PBROOTDIR'}) if (defined $pbinit);
|
---|
| 228 | die "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'});
|
---|
[314] | 229 | }
|
---|
| 230 |
|
---|
[358] | 231 | return if ($action =~ /^newver$/);
|
---|
| 232 |
|
---|
[353] | 233 | my %version = ();
|
---|
| 234 | my %defpkgdir = ();
|
---|
| 235 | my %extpkgdir = ();
|
---|
| 236 | my %filteredfiles = ();
|
---|
| 237 | my %supfiles = ();
|
---|
| 238 |
|
---|
| 239 | if ((-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") and (not defined $pbinit)) {
|
---|
| 240 | # List of pkg to build by default (mandatory)
|
---|
| 241 | my ($defpkgdir,$pbpackager, $pkgv, $pkgt) = pb_conf_get("defpkgdir","pbpackager","projver","projtag");
|
---|
| 242 | # List of additional pkg to build when all is called (optional)
|
---|
| 243 | # Valid version names (optional)
|
---|
| 244 | # List of files to filter (optional)
|
---|
| 245 | # Project version and tag (optional)
|
---|
| 246 | my ($extpkgdir, $version, $filteredfiles, $supfiles) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles");
|
---|
| 247 | pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
|
---|
| 248 | pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
|
---|
| 249 | pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
|
---|
| 250 | pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
|
---|
| 251 | pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
|
---|
| 252 | # Global
|
---|
| 253 | %defpkgdir = %$defpkgdir;
|
---|
| 254 | %extpkgdir = %$extpkgdir if (defined $extpkgdir);
|
---|
| 255 | %version = %$version if (defined $version);
|
---|
| 256 | %filteredfiles = %$filteredfiles if (defined $filteredfiles);
|
---|
| 257 | %supfiles = %$supfiles if (defined $supfiles);
|
---|
| 258 | #
|
---|
| 259 | # Get global Version/Tag
|
---|
| 260 | #
|
---|
| 261 | if (not defined $ENV{'PBPROJVER'}) {
|
---|
| 262 | if ((defined $pkgv) && (defined $pkgv->{$ENV{'PBPROJ'}})) {
|
---|
| 263 | $ENV{'PBPROJVER'}=$pkgv->{$ENV{'PBPROJ'}};
|
---|
| 264 | } else {
|
---|
| 265 | die "No projver found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
|
---|
| 266 | }
|
---|
[106] | 267 | }
|
---|
[353] | 268 | die "Invalid version name $ENV{'PBPROJVER'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if (($ENV{'PBPROJVER'} !~ /[0-9.]+/) && (not defined $version) && ($ENV{'PBPROJVER'} =~ /$version{$ENV{'PBPROJ'}}/));
|
---|
| 269 |
|
---|
| 270 | if (not defined $ENV{'PBPROJTAG'}) {
|
---|
| 271 | if ((defined $pkgt) && (defined $pkgt->{$ENV{'PBPROJ'}})) {
|
---|
| 272 | $ENV{'PBPROJTAG'}=$pkgt->{$ENV{'PBPROJ'}};
|
---|
| 273 | } else {
|
---|
| 274 | die "No projtag found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
|
---|
| 275 | }
|
---|
| 276 | }
|
---|
| 277 | die "Invalid tag name $ENV{'PBPROJTAG'} in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb" if ($ENV{'PBPROJTAG'} !~ /[0-9.]+/);
|
---|
[106] | 278 |
|
---|
[353] | 279 |
|
---|
| 280 | if (not defined $ENV{'PBPACKAGER'}) {
|
---|
| 281 | if ((defined $pbpackager) && (defined $pbpackager->{$ENV{'PBPROJ'}})) {
|
---|
| 282 | $ENV{'PBPACKAGER'}=$pbpackager->{$ENV{'PBPROJ'}};
|
---|
| 283 | } else {
|
---|
| 284 | die "No pbpackager found in $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
|
---|
| 285 | }
|
---|
[106] | 286 | }
|
---|
[353] | 287 | } else {
|
---|
| 288 | if (defined $pbinit) {
|
---|
| 289 | my $ptr = pb_get_pkg();
|
---|
| 290 | my @pkgs = @$ptr;
|
---|
| 291 | @pkgs = ("pkg1") if (not @pkgs);
|
---|
| 292 |
|
---|
| 293 | open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") || die "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
|
---|
| 294 | print CONF << "EOF";
|
---|
[273] | 295 | #
|
---|
| 296 | # Project Builder configuration file
|
---|
[313] | 297 | # For project $ENV{'PBPROJ'}
|
---|
[273] | 298 | #
|
---|
| 299 | # \$Id\$
|
---|
| 300 | #
|
---|
| 301 |
|
---|
| 302 | #
|
---|
[316] | 303 | # What is the project URL
|
---|
[273] | 304 | #
|
---|
[343] | 305 | #pburl $ENV{'PBPROJ'} = svn://svn.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 306 | #pburl $ENV{'PBPROJ'} = svn://svn+ssh.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 307 | #pburl $ENV{'PBPROJ'} = cvs://cvs.$ENV{'PBPROJ'}.org/$ENV{'PBPROJ'}/devel
|
---|
| 308 | #pburl $ENV{'PBPROJ'} = http://www.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
| 309 | #pburl $ENV{'PBPROJ'} = ftp://ftp.$ENV{'PBPROJ'}.org/src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
| 310 | #pburl $ENV{'PBPROJ'} = file:///src/$ENV{'PBPROJ'}-devel.tar.gz
|
---|
| 311 | #pburl $ENV{'PBPROJ'} = dir:///src/$ENV{'PBPROJ'}-devel
|
---|
[273] | 312 |
|
---|
[344] | 313 | # Check whether project is well formed
|
---|
| 314 | # (containing already a directory with the project-version name)
|
---|
| 315 | #pbwf $ENV{'PBPROJ'} = 1
|
---|
| 316 |
|
---|
[273] | 317 | #
|
---|
| 318 | # Packager label
|
---|
| 319 | #
|
---|
[344] | 320 | #pbpackager $ENV{'PBPROJ'} = William Porte <bill\@$ENV{'PBPROJ'}.org>
|
---|
[273] | 321 | #
|
---|
| 322 |
|
---|
| 323 | # For delivery to a machine by SSH (potentially the FTP server)
|
---|
| 324 | # Needs hostname, account and directory
|
---|
| 325 | #
|
---|
[313] | 326 | #sshhost $ENV{'PBPROJ'} = www.$ENV{'PBPROJ'}.org
|
---|
| 327 | #sshlogin $ENV{'PBPROJ'} = bill
|
---|
| 328 | #sshdir $ENV{'PBPROJ'} = /$ENV{'PBPROJ'}/ftp
|
---|
| 329 | #sshport $ENV{'PBPROJ'} = 22
|
---|
[273] | 330 |
|
---|
| 331 | #
|
---|
| 332 | # For Virtual machines management
|
---|
| 333 | # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
|
---|
[343] | 334 | # followed by '-' and by release number
|
---|
| 335 | # followed by '-' and by architecture
|
---|
[273] | 336 | # a .vmtype extension will be added to the resulting string
|
---|
[343] | 337 | # a QEMU rhel-3-i286 here means that the VM will be named rhel-3-i386.qemu
|
---|
[273] | 338 | #
|
---|
[343] | 339 | #vmlist $ENV{'PBPROJ'} = mandrake-10.1-i386,mandrake-10.2-i386,mandriva-2006.0-i386,mandriva-2007.0-i386,mandriva-2007.1-i386,mandriva-2008.0-i386,redhat-7.3-i386,redhat-9-i386,fedora-4-i386,fedora-5-i386,fedora-6-i386,fedora-7-i386,fedora-8-i386,rhel-3-i386,rhel-4-i386,rhel-5-i386,suse-10.0-i386,suse-10.1-i386,suse-10.2-i386,suse-10.3-i386,sles-9-i386,sles-10-i386,gentoo-nover-i386,debian-3.1-i386,debian-4.0-i386,ubuntu-6.06-i386,ubuntu-7.04-i386,ubuntu-7.10-i386,mandriva-2007.0-x86_64,mandriva-2007.1-x86_64,mandriva-2008.0-x86_64,fedora-6-x86_64,fedora-7-x86_64,fedora-8-x86_64,rhel-4-x86_64,rhel-5-x86_64,suse-10.2-x86_64,suse-10.3-x86_64,sles-10-x86_64,gentoo-nover-x86_64,debian-4.0-x86_64,ubuntu-7.04-x86_64,ubuntu-7.10-x86_64
|
---|
[273] | 340 |
|
---|
| 341 | #
|
---|
| 342 | # Valid values for vmtype are
|
---|
| 343 | # qemu, (vmware, xen, ... TBD)
|
---|
[313] | 344 | #vmtype $ENV{'PBPROJ'} = qemu
|
---|
[273] | 345 |
|
---|
| 346 | # Hash for VM stuff on vmtype
|
---|
| 347 | #vmntp default = pool.ntp.org
|
---|
| 348 |
|
---|
| 349 | # We suppose we can commmunicate with the VM through SSH
|
---|
[313] | 350 | #vmhost $ENV{'PBPROJ'} = localhost
|
---|
| 351 | #vmlogin $ENV{'PBPROJ'} = pb
|
---|
| 352 | #vmport $ENV{'PBPROJ'} = 2222
|
---|
[273] | 353 |
|
---|
| 354 | # Timeout to wait when VM is launched/stopped
|
---|
| 355 | #vmtmout default = 120
|
---|
| 356 |
|
---|
| 357 | # per VMs needed paramaters
|
---|
[313] | 358 | #vmopt $ENV{'PBPROJ'} = -m 384 -daemonize
|
---|
| 359 | #vmpath $ENV{'PBPROJ'} = /home/qemu
|
---|
| 360 | #vmsize $ENV{'PBPROJ'} = 5G
|
---|
[273] | 361 |
|
---|
[343] | 362 | #
|
---|
| 363 | # For Virtual environment management
|
---|
| 364 | # Naming convention to follow: distribution name (as per ProjectBuilder::Distribution)
|
---|
| 365 | # followed by '-' and by release number
|
---|
| 366 | # followed by '-' and by architecture
|
---|
| 367 | # a .vetype extension will be added to the resulting string
|
---|
| 368 | # a chroot rhel-3-i286 here means that the VE will be named rhel-3-i386.chroot
|
---|
[273] | 369 | #
|
---|
[343] | 370 | #velist $ENV{'PBPROJ'} = fedora-7-i386
|
---|
| 371 |
|
---|
| 372 | # VE params
|
---|
| 373 | #vetype $ENV{'PBPROJ'} = chroot
|
---|
| 374 | #ventp default = pool.ntp.org
|
---|
| 375 | #velogin $ENV{'PBPROJ'} = pb
|
---|
| 376 | #vepath $ENV{'PBPROJ'} = /var/lib/mock
|
---|
| 377 | #veconf $ENV{'PBPROJ'} = /etc/mock
|
---|
| 378 | #verebuild $ENV{'PBPROJ'} = false
|
---|
| 379 |
|
---|
| 380 | #
|
---|
[273] | 381 | # Global version/tag for the project
|
---|
| 382 | #
|
---|
[313] | 383 | #projver $ENV{'PBPROJ'} = devel
|
---|
| 384 | #projtag $ENV{'PBPROJ'} = 1
|
---|
[273] | 385 |
|
---|
[316] | 386 | # Hash of valid version names
|
---|
| 387 | #version $ENV{'PBPROJ'} = devel,stable
|
---|
| 388 |
|
---|
[273] | 389 | # Adapt to your needs:
|
---|
| 390 | # Optional if you need to overwrite the global values above
|
---|
| 391 | #
|
---|
[316] | 392 | EOF
|
---|
| 393 |
|
---|
[353] | 394 | foreach my $pp (@pkgs) {
|
---|
| 395 | print CONF << "EOF";
|
---|
[316] | 396 | #pkgver $pp = stable
|
---|
| 397 | #pkgtag $pp = 3
|
---|
| 398 | EOF
|
---|
[353] | 399 | }
|
---|
| 400 | foreach my $pp (@pkgs) {
|
---|
| 401 | print CONF << "EOF";
|
---|
[273] | 402 | # Hash of default package/package directory
|
---|
[319] | 403 | #defpkgdir $pp = dir-$pp
|
---|
[316] | 404 | EOF
|
---|
[353] | 405 | }
|
---|
| 406 |
|
---|
| 407 | print CONF << "EOF";
|
---|
[273] | 408 | # Hash of additional package/package directory
|
---|
[319] | 409 | #extpkgdir minor-pkg = dir-minor-pkg
|
---|
[273] | 410 |
|
---|
| 411 | # List of files per pkg on which to apply filters
|
---|
| 412 | # Files are mentioned relatively to pbroot/defpkgdir
|
---|
| 413 | EOF
|
---|
[353] | 414 | foreach my $pp (@pkgs) {
|
---|
| 415 | print CONF << "EOF";
|
---|
[316] | 416 | #filteredfiles $pp = Makefile.PL,configure.in,install.sh,$pp.8
|
---|
| 417 | #supfiles $pp = $pp.init
|
---|
| 418 | EOF
|
---|
[353] | 419 | }
|
---|
| 420 | close(CONF);
|
---|
| 421 | pb_mkdir_p("$ENV{'PBROOTDIR'}/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter";
|
---|
| 422 | open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/all.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/all.pbf";
|
---|
| 423 | print CONF << "EOF";
|
---|
[273] | 424 | #
|
---|
| 425 | # \$Id\$
|
---|
| 426 | #
|
---|
| 427 | # Filter for all files
|
---|
| 428 | #
|
---|
| 429 | # PBSRC is replaced by the source package format
|
---|
[313] | 430 | #filter PBSRC = ftp://ftp.$ENV{'PBPROJ'}.org/src/%{name}-%{version}.tar.gz
|
---|
[273] | 431 |
|
---|
| 432 | # PBVER is replaced by the version (\$pbver in code)
|
---|
[344] | 433 | filter PBVER = \$pbver
|
---|
[273] | 434 |
|
---|
| 435 | # PBDATE is replaced by the date (\$pbdate in code)
|
---|
[344] | 436 | filter PBDATE = \$pbdate
|
---|
[273] | 437 |
|
---|
| 438 | # PBLOG is replaced by the changelog if value is yes
|
---|
| 439 | #filter PBLOG = yes
|
---|
| 440 |
|
---|
| 441 | # PBTAG is replaced by the tag (\$pbtag in code)
|
---|
[344] | 442 | filter PBTAG = \$pbtag
|
---|
[273] | 443 |
|
---|
| 444 | # PBREV is replaced by the revision (\$pbrev in code)
|
---|
[344] | 445 | filter PBREV = \$pbrev
|
---|
[273] | 446 |
|
---|
| 447 | # PBPKG is replaced by the package name (\$pbpkg in code)
|
---|
[344] | 448 | filter PBPKG = \$pbpkg
|
---|
[273] | 449 |
|
---|
| 450 | # PBPACKAGER is replaced by the packager name (\$pbpackager in code)
|
---|
[344] | 451 | filter PBPACKAGER = \$pbpackager
|
---|
[273] | 452 |
|
---|
| 453 | # PBDESC contains the description of the package
|
---|
| 454 | #filter PBDESC = "Bla-Bla"
|
---|
| 455 |
|
---|
| 456 | # PBURL contains the URL of the Web site of the project
|
---|
[313] | 457 | #filter PBURL = http://www.$ENV{'PBPROJ'}.org
|
---|
[273] | 458 | EOF
|
---|
[353] | 459 | close(CONF);
|
---|
| 460 | open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/rpm.pbf";
|
---|
| 461 | print CONF << "EOF";
|
---|
[273] | 462 | #
|
---|
| 463 | # \$Id\$
|
---|
| 464 | #
|
---|
| 465 | # Filter for rpm build
|
---|
| 466 | #
|
---|
| 467 |
|
---|
| 468 | # PBGRP is replaced by the RPM group of apps
|
---|
[288] | 469 | # Cf: http://fedoraproject.org/wiki/RPMGroups
|
---|
[273] | 470 | #filter PBGRP = Applications/Archiving
|
---|
| 471 |
|
---|
[316] | 472 | # PBLIC is replaced by the license of the application
|
---|
| 473 | # Cf: http://fedoraproject.org/wiki/Licensing
|
---|
| 474 | #filter PBLIC = GPL
|
---|
| 475 |
|
---|
[273] | 476 | # PBDEP is replaced by the list of dependencies
|
---|
| 477 | #filter PBDEP =
|
---|
| 478 |
|
---|
[344] | 479 | # PBSUF is replaced by the package suffix (\$pbsuf in code)
|
---|
| 480 | filter PBSUF = \$pbsuf
|
---|
[273] | 481 |
|
---|
| 482 | # PBOBS is replaced by the Obsolete line
|
---|
| 483 | #filter PBOBS =
|
---|
| 484 |
|
---|
| 485 | EOF
|
---|
[353] | 486 | close(CONF);
|
---|
| 487 | open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/deb.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/deb.pbf";
|
---|
| 488 | print CONF << "EOF";
|
---|
[273] | 489 | #
|
---|
| 490 | # \$Id\$
|
---|
| 491 | #
|
---|
| 492 | # Filter for debian build
|
---|
| 493 | #
|
---|
| 494 | # PBGRP is replaced by the group of apps
|
---|
[344] | 495 | filter PBGRP = utils
|
---|
[273] | 496 |
|
---|
[316] | 497 | # PBLIC is replaced by the license of the application
|
---|
| 498 | # Cf:
|
---|
| 499 | #filter PBLIC = GPL
|
---|
| 500 |
|
---|
[273] | 501 | # PBDEP is replaced by the list of dependencies
|
---|
| 502 | #filter PBDEP =
|
---|
| 503 |
|
---|
| 504 | # PBSUG is replaced by the list of suggestions
|
---|
| 505 | #filter PBSUG =
|
---|
| 506 |
|
---|
| 507 | # PBREC is replaced by the list of recommandations
|
---|
| 508 | #filter PBREC =
|
---|
| 509 |
|
---|
| 510 | EOF
|
---|
[353] | 511 | close(CONF);
|
---|
| 512 | open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/md.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/md.pbf";
|
---|
| 513 | print CONF << "EOF";
|
---|
[313] | 514 | # Specific group for Mandriva for $ENV{'PBPROJ'}
|
---|
[316] | 515 | # Cf: http://wiki.mandriva.com/en/Development/Packaging/Groups
|
---|
[344] | 516 | #filter PBGRP = Archiving/Backup
|
---|
[316] | 517 |
|
---|
| 518 | # PBLIC is replaced by the license of the application
|
---|
| 519 | # Cf: http://wiki.mandriva.com/en/Development/Packaging/Licenses
|
---|
| 520 | #filter PBLIC = GPL
|
---|
| 521 |
|
---|
[273] | 522 | EOF
|
---|
[353] | 523 | close(CONF);
|
---|
| 524 | open(CONF,"> $ENV{'PBROOTDIR'}/pbfilter/novell.pbf") || die "Unable to create $ENV{'PBROOTDIR'}/pbfilter/novell.pbf";
|
---|
| 525 | print CONF << "EOF";
|
---|
[313] | 526 | # Specific group for SuSE for $ENV{'PBPROJ'}
|
---|
[316] | 527 | # Cf: http://en.opensuse.org/SUSE_Package_Conventions/RPM_Groups
|
---|
[344] | 528 | #filter PBGRP = Productivity/Archiving/Backup
|
---|
[316] | 529 |
|
---|
| 530 | # PBLIC is replaced by the license of the application
|
---|
| 531 | # Cf: http://en.opensuse.org/Packaging/SUSE_Package_Conventions/RPM_Style#1.6._License_Tag
|
---|
| 532 | #filter PBLIC = GPL
|
---|
| 533 |
|
---|
[273] | 534 | EOF
|
---|
[353] | 535 | close(CONF);
|
---|
| 536 | foreach my $pp (@pkgs) {
|
---|
| 537 | pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/deb") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb";
|
---|
| 538 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/control") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/control";
|
---|
| 539 | print CONF << "EOF";
|
---|
[273] | 540 | Source: PBPKG
|
---|
| 541 | Section: PBGRP
|
---|
| 542 | Priority: optional
|
---|
| 543 | Maintainer: PBPACKAGER
|
---|
| 544 | Build-Depends: debhelper (>= 4.2.20), PBDEP
|
---|
| 545 | Standards-Version: 3.6.1
|
---|
| 546 |
|
---|
| 547 | Package: PBPKG
|
---|
| 548 | Architecture: amd64 i386 ia64
|
---|
| 549 | Section: PBGRP
|
---|
| 550 | Priority: optional
|
---|
| 551 | Depends: \${shlibs:Depends}, \${misc:Depends}, PBDEP
|
---|
| 552 | Recommends: PBREC
|
---|
| 553 | Suggests: PBSUG
|
---|
| 554 | Description:
|
---|
| 555 | PBDESC
|
---|
| 556 | .
|
---|
| 557 | Homepage: PBURL
|
---|
| 558 |
|
---|
| 559 | EOF
|
---|
[353] | 560 | close(CONF);
|
---|
| 561 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/copyright") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/copyright";
|
---|
| 562 | print CONF << "EOF";
|
---|
[273] | 563 | This package is debianized by PBPACKAGER
|
---|
| 564 | `date`
|
---|
| 565 |
|
---|
| 566 | The current upstream source was downloaded from
|
---|
[313] | 567 | ftp://ftp.$ENV{'PBPROJ'}.org/src/.
|
---|
[273] | 568 |
|
---|
| 569 | Upstream Authors: Put their name here
|
---|
| 570 |
|
---|
| 571 | Copyright:
|
---|
| 572 |
|
---|
| 573 | This package is free software; you can redistribute it and/or modify
|
---|
| 574 | it under the terms of the GNU General Public License as published by
|
---|
| 575 | the Free Software Foundation; version 2 dated June, 1991.
|
---|
| 576 |
|
---|
| 577 | This package is distributed in the hope that it will be useful,
|
---|
| 578 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 579 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 580 | GNU General Public License for more details.
|
---|
| 581 |
|
---|
| 582 | You should have received a copy of the GNU General Public License
|
---|
| 583 | along with this package; if not, write to the Free Software
|
---|
| 584 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
---|
| 585 | MA 02110-1301, USA.
|
---|
| 586 |
|
---|
| 587 | On Debian systems, the complete text of the GNU General
|
---|
| 588 | Public License can be found in /usr/share/common-licenses/GPL.
|
---|
| 589 |
|
---|
| 590 | EOF
|
---|
[353] | 591 | close(CONF);
|
---|
| 592 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/changelog") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/changelog";
|
---|
| 593 | print CONF << "EOF";
|
---|
[273] | 594 | PBLOG
|
---|
| 595 | EOF
|
---|
[353] | 596 | close(CONF);
|
---|
| 597 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/compat") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/compat";
|
---|
| 598 | print CONF << "EOF";
|
---|
[273] | 599 | 4
|
---|
| 600 | EOF
|
---|
[353] | 601 | close(CONF);
|
---|
| 602 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.dirs";
|
---|
| 603 | print CONF << "EOF";
|
---|
[273] | 604 | EOF
|
---|
[353] | 605 | close(CONF);
|
---|
| 606 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/$pp.docs";
|
---|
| 607 | print CONF << "EOF";
|
---|
[273] | 608 | INSTALL
|
---|
| 609 | COPYING
|
---|
| 610 | AUTHORS
|
---|
| 611 | NEWS
|
---|
| 612 | README
|
---|
| 613 | EOF
|
---|
[353] | 614 | close(CONF);
|
---|
| 615 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/deb/rules") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/deb/rules";
|
---|
| 616 | print CONF << 'EOF';
|
---|
[273] | 617 | #!/usr/bin/make -f
|
---|
| 618 | # -*- makefile -*-
|
---|
| 619 | # Sample debian/rules that uses debhelper.
|
---|
| 620 | # GNU copyright 1997 to 1999 by Joey Hess.
|
---|
| 621 | #
|
---|
| 622 | # $Id$
|
---|
| 623 | #
|
---|
| 624 |
|
---|
| 625 | # Uncomment this to turn on verbose mode.
|
---|
| 626 | #export DH_VERBOSE=1
|
---|
| 627 |
|
---|
| 628 | # Define package name variable for a one-stop change.
|
---|
| 629 | PACKAGE_NAME = PBPKG
|
---|
| 630 |
|
---|
| 631 | # These are used for cross-compiling and for saving the configure script
|
---|
| 632 | # from having to guess our platform (since we know it already)
|
---|
| 633 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
---|
| 634 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
---|
| 635 |
|
---|
| 636 | CFLAGS = -Wall -g
|
---|
| 637 |
|
---|
| 638 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
---|
| 639 | CFLAGS += -O0
|
---|
| 640 | else
|
---|
| 641 | CFLAGS += -O2
|
---|
| 642 | endif
|
---|
| 643 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
|
---|
| 644 | INSTALL_PROGRAM += -s
|
---|
| 645 | endif
|
---|
| 646 | config.status: configure
|
---|
| 647 | dh_testdir
|
---|
| 648 |
|
---|
| 649 | # Configure the package.
|
---|
| 650 | CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr
|
---|
| 651 | --mandir=\$${prefix}/share/man
|
---|
| 652 |
|
---|
| 653 | # Build both architecture dependent and independent
|
---|
| 654 | build: build-arch build-indep
|
---|
| 655 |
|
---|
| 656 | # Build architecture dependent
|
---|
| 657 | build-arch: build-arch-stamp
|
---|
| 658 |
|
---|
| 659 | build-arch-stamp: config.status
|
---|
| 660 | dh_testdir
|
---|
| 661 |
|
---|
| 662 | # Compile the package.
|
---|
| 663 | $(MAKE)
|
---|
| 664 |
|
---|
| 665 | touch build-stamp
|
---|
| 666 |
|
---|
| 667 | # Build architecture independent
|
---|
| 668 | build-indep: build-indep-stamp
|
---|
| 669 |
|
---|
| 670 | build-indep-stamp: config.status
|
---|
| 671 | # Nothing to do, the only indep item is the manual which is available as html in original source
|
---|
| 672 | touch build-indep-stamp
|
---|
| 673 |
|
---|
| 674 | # Clean up
|
---|
| 675 | clean:
|
---|
| 676 | dh_testdir
|
---|
| 677 | dh_testroot
|
---|
| 678 | rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
|
---|
| 679 | # Clean temporary document directory
|
---|
| 680 | rm -rf debian/doc-temp
|
---|
| 681 | # Clean up.
|
---|
| 682 | -$(MAKE) distclean
|
---|
| 683 | rm -f config.log
|
---|
| 684 | ifneq "$(wildcard /usr/share/misc/config.sub)" ""
|
---|
| 685 | cp -f /usr/share/misc/config.sub config.sub
|
---|
| 686 | endif
|
---|
| 687 | ifneq "$(wildcard /usr/share/misc/config.guess)" ""
|
---|
| 688 | cp -f /usr/share/misc/config.guess config.guess
|
---|
| 689 | endif
|
---|
| 690 |
|
---|
| 691 | dh_clean
|
---|
| 692 |
|
---|
| 693 | # Install architecture dependent and independent
|
---|
| 694 | install: install-arch install-indep
|
---|
| 695 |
|
---|
| 696 | # Install architecture dependent
|
---|
| 697 | install-arch: build-arch
|
---|
| 698 | dh_testdir
|
---|
| 699 | dh_testroot
|
---|
| 700 | dh_clean -k -s
|
---|
| 701 | dh_installdirs -s
|
---|
| 702 |
|
---|
| 703 | # Install the package files into build directory:
|
---|
| 704 | # - start with upstream make install
|
---|
| 705 | $(MAKE) install prefix=$(CURDIR)/debian/$(PACKAGE_NAME)/usr mandir=$(CURDIR)/debian/$(PACKAGE_NAME)/us
|
---|
| 706 | r/share/man
|
---|
| 707 | # - copy html manual to temporary location for renaming
|
---|
| 708 | mkdir -p debian/doc-temp
|
---|
| 709 | dh_install -s
|
---|
| 710 |
|
---|
| 711 | # Install architecture independent
|
---|
| 712 | install-indep: build-indep
|
---|
| 713 | dh_testdir
|
---|
| 714 | dh_testroot
|
---|
| 715 | dh_clean -k -i
|
---|
| 716 | dh_installdirs -i
|
---|
| 717 | dh_install -i
|
---|
| 718 |
|
---|
| 719 | # Must not depend on anything. This is to be called by
|
---|
| 720 | # binary-arch/binary-indep
|
---|
| 721 | # in another 'make' thread.
|
---|
| 722 | binary-common:
|
---|
| 723 | dh_testdir
|
---|
| 724 | dh_testroot
|
---|
| 725 | dh_installchangelogs ChangeLog
|
---|
| 726 | dh_installdocs
|
---|
| 727 | dh_installman
|
---|
| 728 | dh_link
|
---|
| 729 | dh_strip
|
---|
| 730 | dh_compress
|
---|
| 731 | dh_fixperms
|
---|
| 732 | dh_installdeb
|
---|
| 733 | dh_shlibdeps
|
---|
| 734 | dh_gencontrol
|
---|
| 735 | dh_md5sums
|
---|
| 736 | dh_builddeb
|
---|
| 737 |
|
---|
| 738 | # Build architecture independant packages using the common target.
|
---|
| 739 | binary-indep: build-indep install-indep
|
---|
| 740 | $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
|
---|
| 741 |
|
---|
| 742 | # Build architecture dependant packages using the common target.
|
---|
| 743 | binary-arch: build-arch install-arch
|
---|
| 744 | $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
|
---|
| 745 |
|
---|
| 746 | # Build architecture depdendent and independent packages
|
---|
| 747 | binary: binary-arch binary-indep
|
---|
| 748 | .PHONY: clean binary
|
---|
| 749 |
|
---|
| 750 | EOF
|
---|
[353] | 751 | close(CONF);
|
---|
| 752 | pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/rpm") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm";
|
---|
| 753 | open(CONF,"> $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/rpm/$pp.spec";
|
---|
| 754 | print CONF << 'EOF';
|
---|
[273] | 755 | #
|
---|
| 756 | # $Id$
|
---|
| 757 | #
|
---|
| 758 |
|
---|
| 759 | Summary: bla-bla
|
---|
| 760 | Summary(fr): french bla-bla
|
---|
| 761 |
|
---|
| 762 | Name: PBPKG
|
---|
| 763 | Version: PBVER
|
---|
| 764 | Release: PBTAGPBSUF
|
---|
[316] | 765 | License: PBLIC
|
---|
[273] | 766 | Group: PBGRP
|
---|
| 767 | Url: PBURL
|
---|
| 768 | Source: PBSRC
|
---|
| 769 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n)
|
---|
[344] | 770 | #Requires: PBDEP
|
---|
[273] | 771 |
|
---|
| 772 | %description
|
---|
| 773 | PBDESC
|
---|
| 774 |
|
---|
| 775 | %description -l fr
|
---|
| 776 | french desc
|
---|
| 777 |
|
---|
| 778 | %prep
|
---|
| 779 | %setup -q
|
---|
| 780 |
|
---|
| 781 | %build
|
---|
| 782 | %configure
|
---|
[288] | 783 | make %{?_smp_mflags}
|
---|
[273] | 784 |
|
---|
| 785 | %install
|
---|
| 786 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
| 787 | make DESTDIR=$RPM_BUILD_ROOT install
|
---|
| 788 |
|
---|
| 789 | %clean
|
---|
| 790 | %{__rm} -rf $RPM_BUILD_ROOT
|
---|
| 791 |
|
---|
| 792 | %files
|
---|
| 793 | %defattr(-,root,root)
|
---|
| 794 | %doc ChangeLog
|
---|
| 795 | %doc INSTALL COPYING README AUTHORS NEWS
|
---|
| 796 |
|
---|
| 797 | %changelog
|
---|
| 798 | PBLOG
|
---|
| 799 |
|
---|
| 800 | EOF
|
---|
[353] | 801 | close(CONF);
|
---|
| 802 | pb_mkdir_p("$ENV{'PBROOTDIR'}/$pp/pbfilter") || die "Unable to create $ENV{'PBROOTDIR'}/$pp/pbfilter";
|
---|
| 803 |
|
---|
| 804 | pb_log(0,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
|
---|
| 805 | }
|
---|
| 806 | } else {
|
---|
| 807 | die "Unable to open $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb";
|
---|
[316] | 808 | }
|
---|
[273] | 809 | }
|
---|
[353] | 810 | umask 0022;
|
---|
| 811 | return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
|
---|
| 812 | } else {
|
---|
| 813 | # Setup the variables from what has been stored at the end of cms2build
|
---|
| 814 | my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbroot");
|
---|
| 815 | $ENV{'PBROOTDIR'} = $var->{$ENV{'PBPROJ'}};
|
---|
| 816 |
|
---|
| 817 | ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projver");
|
---|
| 818 | $ENV{'PBPROJVER'} = $var->{$ENV{'PBPROJ'}};
|
---|
| 819 |
|
---|
| 820 | ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","projtag");
|
---|
| 821 | $ENV{'PBPROJTAG'} = $var->{$ENV{'PBPROJ'}};
|
---|
| 822 |
|
---|
| 823 | ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","pbpackager");
|
---|
| 824 | $ENV{'PBPACKAGER'} = $var->{$ENV{'PBPROJ'}};
|
---|
| 825 |
|
---|
| 826 | return;
|
---|
[98] | 827 | }
|
---|
[2] | 828 | }
|
---|
[9] | 829 |
|
---|
[74] | 830 | # Internal mkdir -p function
|
---|
| 831 | sub pb_mkdir_p {
|
---|
[29] | 832 | my @dir = @_;
|
---|
| 833 | my $ret = mkpath(@dir, 0, 0755);
|
---|
| 834 | return($ret);
|
---|
[9] | 835 | }
|
---|
| 836 |
|
---|
[74] | 837 | # Internal rm -rf function
|
---|
| 838 | sub pb_rm_rf {
|
---|
[29] | 839 | my @dir = @_;
|
---|
| 840 | my $ret = rmtree(@dir, 0, 0);
|
---|
| 841 | return($ret);
|
---|
[9] | 842 | }
|
---|
| 843 |
|
---|
[74] | 844 | # Internal system function
|
---|
| 845 | sub pb_system {
|
---|
[29] | 846 |
|
---|
| 847 | my $cmd=shift;
|
---|
[30] | 848 | my $cmt=shift || $cmd;
|
---|
[29] | 849 |
|
---|
[319] | 850 | pb_log(0,"$cmt... ");
|
---|
[117] | 851 | #system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
|
---|
[293] | 852 | system($cmd);
|
---|
[353] | 853 | pb_log(1,"Executing $cmd\n");
|
---|
[347] | 854 | my $res = $?;
|
---|
| 855 | if ($res == -1) {
|
---|
[319] | 856 | pb_log(0,"failed to execute ($cmd) : $!\n");
|
---|
[106] | 857 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[347] | 858 | } elsif ($res & 127) {
|
---|
[319] | 859 | pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n");
|
---|
[106] | 860 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[347] | 861 | } elsif ($res == 0) {
|
---|
[319] | 862 | pb_log(0,"OK\n");
|
---|
[29] | 863 | } else {
|
---|
[319] | 864 | pb_log(0, "child ($cmd) exited with value ".($? >> 8)."\n");
|
---|
[106] | 865 | pb_display_file("$ENV{'PBTMP'}/system.log");
|
---|
[29] | 866 | }
|
---|
[347] | 867 | return($res);
|
---|
[30] | 868 | }
|
---|
[74] | 869 |
|
---|
[106] | 870 | sub pb_display_file {
|
---|
| 871 |
|
---|
| 872 | my $file=shift;
|
---|
| 873 |
|
---|
[117] | 874 | return if (not -f $file);
|
---|
| 875 | open(FILE,"$file");
|
---|
[106] | 876 | while (<FILE>) {
|
---|
[108] | 877 | print $_;
|
---|
[106] | 878 | }
|
---|
| 879 | close(FILE);
|
---|
| 880 | }
|
---|
| 881 |
|
---|
[242] | 882 | # Function which returns a pointer on a table
|
---|
| 883 | # corresponding to a set of values queried in the conf file
|
---|
[88] | 884 | # and test the returned vaue as they need to exist in that case
|
---|
| 885 | sub pb_conf_get {
|
---|
| 886 |
|
---|
| 887 | my @param = @_;
|
---|
[313] | 888 | my @return = pb_conf_get_if(@param);
|
---|
[88] | 889 |
|
---|
[315] | 890 | die "No params found for $ENV{'PBPROJ'}" if (not @return);
|
---|
[313] | 891 |
|
---|
| 892 | foreach my $i (0..$#param) {
|
---|
| 893 | die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $return[$i]);
|
---|
| 894 | }
|
---|
| 895 | return(@return);
|
---|
| 896 | }
|
---|
| 897 |
|
---|
| 898 | # Function which returns a pointer on a table
|
---|
| 899 | # corresponding to a set of values queried in the conf file
|
---|
| 900 | # Those value may be undef if they do not exist
|
---|
| 901 | sub pb_conf_get_if {
|
---|
| 902 |
|
---|
| 903 | my @param = @_;
|
---|
| 904 |
|
---|
[242] | 905 | # Everything is returned via ptr1
|
---|
[318] | 906 | my @ptr1 = ();
|
---|
| 907 | my @ptr2 = ();
|
---|
| 908 | @ptr1 = pb_conf_read_if("$ENV{'PBETC'}", @param) if (defined $ENV{'PBETC'});
|
---|
[339] | 909 | @ptr2 = pb_conf_read_if("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb", @param) if ((defined $ENV{'PBROOTDIR'}) and (defined $ENV{'PBPROJ'}));
|
---|
[89] | 910 |
|
---|
[242] | 911 | my $p1;
|
---|
| 912 | my $p2;
|
---|
| 913 |
|
---|
[355] | 914 | pb_log(2,"DEBUG: pb_conf_get param1: ".Dumper(@ptr1)."\n");
|
---|
| 915 | pb_log(2,"DEBUG: pb_conf_get param2: ".Dumper(@ptr2)."\n");
|
---|
[262] | 916 |
|
---|
[88] | 917 | foreach my $i (0..$#param) {
|
---|
[262] | 918 | $p1 = $ptr1[$i];
|
---|
| 919 | $p2 = $ptr2[$i];
|
---|
[242] | 920 | # Always try to take the param from the home dir conf file in priority
|
---|
| 921 | # in order to mask what could be defined under the CMS to allow for overloading
|
---|
| 922 | if (not defined $p2) {
|
---|
| 923 | # No ref in CMS project conf file so use the home dir one.
|
---|
[328] | 924 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if ((not defined $p1->{$ENV{'PBPROJ'}}) && (defined $p1->{'default'}));
|
---|
[242] | 925 | } else {
|
---|
| 926 | # Ref found in CMS project conf file
|
---|
| 927 | if (not defined $p1) {
|
---|
| 928 | # No ref in home dir project conf file so use the CMS one.
|
---|
[328] | 929 | $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if ((not defined $p2->{$ENV{'PBPROJ'}}) && (defined $p2->{'default'}));
|
---|
[327] | 930 | $p1 = $p2;
|
---|
[242] | 931 | } else {
|
---|
| 932 | # Both are defined - handling the overloading
|
---|
| 933 | if (not defined $p1->{'default'}) {
|
---|
| 934 | if (defined $p2->{'default'}) {
|
---|
| 935 | $p1->{'default'} = $p2->{'default'};
|
---|
| 936 | }
|
---|
| 937 | }
|
---|
| 938 |
|
---|
| 939 | if (not defined $p1->{$ENV{'PBPROJ'}}) {
|
---|
| 940 | if (defined $p2->{$ENV{'PBPROJ'}}) {
|
---|
[328] | 941 | $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}} if (defined $p2->{$ENV{'PBPROJ'}});
|
---|
[242] | 942 | } else {
|
---|
[328] | 943 | $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (defined $p1->{'default'});
|
---|
[242] | 944 | }
|
---|
| 945 | }
|
---|
[327] | 946 | # Now copy back into p1 all p2 content which doesn't exist in p1
|
---|
| 947 | # p1 content (local) always has priority over p2 (project)
|
---|
| 948 | foreach my $k (keys %$p2) {
|
---|
| 949 | $p1->{$k} = $p2->{$k} if (not defined $p1->{$k});
|
---|
| 950 | }
|
---|
[242] | 951 | }
|
---|
| 952 | }
|
---|
[262] | 953 | $ptr1[$i] = $p1;
|
---|
[88] | 954 | }
|
---|
[355] | 955 | pb_log(2,"DEBUG: pb_conf_get param ptr1: ".Dumper(@ptr1)."\n");
|
---|
[242] | 956 | return(@ptr1);
|
---|
[88] | 957 | }
|
---|
| 958 |
|
---|
| 959 | # Function which returns a pointer on a hash
|
---|
[74] | 960 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
[313] | 961 | # if that conf file doesn't exist returns undef
|
---|
| 962 | sub pb_conf_read_if {
|
---|
| 963 |
|
---|
| 964 | my $conffile = shift;
|
---|
| 965 | my @param = @_;
|
---|
| 966 |
|
---|
| 967 | open(CONF,$conffile) || return((undef));
|
---|
| 968 | close(CONF);
|
---|
| 969 | return(pb_conf_read($conffile,@param));
|
---|
| 970 | }
|
---|
| 971 |
|
---|
| 972 | # Function which returns a pointer on a hash
|
---|
| 973 | # corresponding to a declaration (arg2) in a conf file (arg1)
|
---|
[74] | 974 | sub pb_conf_read {
|
---|
| 975 |
|
---|
| 976 | my $conffile = shift;
|
---|
| 977 | my @param = @_;
|
---|
| 978 | my $trace;
|
---|
| 979 | my @ptr;
|
---|
[291] | 980 | my %h;
|
---|
[74] | 981 |
|
---|
[291] | 982 | open(CONF,$conffile) || die "Unable to open $conffile";
|
---|
| 983 | while(<CONF>) {
|
---|
| 984 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
[327] | 985 | pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
|
---|
[291] | 986 | $h{$1}{$2}=$3;
|
---|
| 987 | }
|
---|
[74] | 988 | }
|
---|
[291] | 989 | close(CONF);
|
---|
[74] | 990 |
|
---|
| 991 | for my $param (@param) {
|
---|
[291] | 992 | push @ptr,$h{$param};
|
---|
[74] | 993 | }
|
---|
[89] | 994 | return(@ptr);
|
---|
[74] | 995 | }
|
---|
| 996 |
|
---|
[313] | 997 | # Analyze a url passed and return protocol, account, password, server, port, path
|
---|
[314] | 998 | sub pb_get_uri {
|
---|
[313] | 999 |
|
---|
[314] | 1000 | my $uri = shift || undef;
|
---|
[313] | 1001 |
|
---|
[318] | 1002 | pb_log(2,"DEBUG: uri:$uri\n");
|
---|
[314] | 1003 | # A URL has the format protocol://[ac@]host[:port][path[?query][#fragment]].
|
---|
| 1004 | # Cf man URI
|
---|
| 1005 | my ($scheme, $authority, $path, $query, $fragment) =
|
---|
[318] | 1006 | $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?| if (defined $uri);
|
---|
| 1007 | my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?| if (defined $authority);
|
---|
| 1008 |
|
---|
| 1009 | $scheme = "" if (not defined $scheme);
|
---|
| 1010 | $authority = "" if (not defined $authority);
|
---|
| 1011 | $path = "" if (not defined $path);
|
---|
| 1012 | $account = "" if (not defined $account);
|
---|
| 1013 | $host = "" if (not defined $host);
|
---|
| 1014 | $port = "" if (not defined $port);
|
---|
| 1015 |
|
---|
[315] | 1016 | pb_log(2,"DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n");
|
---|
[314] | 1017 | return($scheme, $account, $host, $port, $path);
|
---|
[313] | 1018 | }
|
---|
| 1019 |
|
---|
| 1020 |
|
---|
| 1021 | # Setup environment for CMS system for URL passed
|
---|
[74] | 1022 | sub pb_cms_init {
|
---|
| 1023 |
|
---|
[339] | 1024 | my $pbinit = shift || undef;
|
---|
[74] | 1025 |
|
---|
[339] | 1026 | my ($pburl) = pb_conf_get("pburl");
|
---|
| 1027 | pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pburl->{$ENV{'PBPROJ'}}\n");
|
---|
| 1028 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($pburl->{$ENV{'PBPROJ'}});
|
---|
| 1029 |
|
---|
| 1030 | my ($pbprojdir) = pb_conf_get_if("pbprojdir");
|
---|
| 1031 |
|
---|
| 1032 | if ((defined $pbprojdir) && (defined $pbprojdir->{$ENV{'PBPROJ'}})) {
|
---|
| 1033 | $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}};
|
---|
| 1034 | } else {
|
---|
| 1035 | $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";
|
---|
| 1036 | }
|
---|
| 1037 |
|
---|
| 1038 | # Computing the default dir for PBDIR.
|
---|
| 1039 | # what we have is PBPROJDIR so work from that.
|
---|
| 1040 | # Tree identical between PBCONFDIR and PBROOTDIR on one side and
|
---|
| 1041 | # PBPROJDIR and PBDIR on the other side.
|
---|
| 1042 |
|
---|
| 1043 | my $tmp = $ENV{'PBROOTDIR'};
|
---|
| 1044 | $tmp =~ s|^$ENV{'PBCONFDIR'}||;
|
---|
| 1045 |
|
---|
| 1046 | #
|
---|
| 1047 | # Check project cms compliance
|
---|
| 1048 | #
|
---|
| 1049 | pb_cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$pburl->{$ENV{'PBPROJ'}},$pbinit);
|
---|
| 1050 |
|
---|
[315] | 1051 | if ($scheme =~ /^svn/) {
|
---|
[331] | 1052 | # svnversion more precise than svn info
|
---|
[339] | 1053 | $tmp = `(cd "$ENV{'PBDIR'}" ; svnversion .)`;
|
---|
[331] | 1054 | chomp($tmp);
|
---|
| 1055 | $ENV{'PBREVISION'}=$tmp;
|
---|
[74] | 1056 | $ENV{'PBCMSLOGFILE'}="svn.log";
|
---|
[315] | 1057 | } elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
[226] | 1058 | $ENV{'PBREVISION'}="flat";
|
---|
[227] | 1059 | $ENV{'PBCMSLOGFILE'}="flat.log";
|
---|
[331] | 1060 | } elsif ($scheme =~ /^cvs/) {
|
---|
[106] | 1061 | # Way too slow
|
---|
[339] | 1062 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOTDIR'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
|
---|
[106] | 1063 | #chomp($ENV{'PBREVISION'});
|
---|
[331] | 1064 | $ENV{'PBREVISION'}="cvs";
|
---|
[74] | 1065 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
[331] | 1066 | $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/);
|
---|
[74] | 1067 | } else {
|
---|
[315] | 1068 | die "cms $scheme unknown";
|
---|
[74] | 1069 | }
|
---|
[339] | 1070 |
|
---|
| 1071 | return($scheme,$pburl->{$ENV{'PBPROJ'}});
|
---|
[74] | 1072 | }
|
---|
| 1073 |
|
---|
[315] | 1074 | sub pb_get_date {
|
---|
| 1075 |
|
---|
| 1076 | return(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 1077 | }
|
---|
| 1078 |
|
---|
[106] | 1079 | sub pb_cms_export {
|
---|
[315] | 1080 |
|
---|
[319] | 1081 | my $uri = shift;
|
---|
[108] | 1082 | my $source = shift;
|
---|
[106] | 1083 | my $destdir = shift;
|
---|
[108] | 1084 | my $tmp;
|
---|
[115] | 1085 | my $tmp1;
|
---|
[106] | 1086 |
|
---|
[315] | 1087 | my @date = pb_get_date();
|
---|
[319] | 1088 | # If it's not flat, then we have a real uri as source
|
---|
| 1089 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
[315] | 1090 |
|
---|
[321] | 1091 | if ($scheme =~ /^svn/) {
|
---|
[108] | 1092 | if (-d $source) {
|
---|
| 1093 | $tmp = $destdir;
|
---|
| 1094 | } else {
|
---|
[327] | 1095 | $tmp = "$destdir/".basename($source);
|
---|
[108] | 1096 | }
|
---|
[116] | 1097 | pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
|
---|
[319] | 1098 | } elsif ($scheme eq "dir") {
|
---|
[320] | 1099 | pb_system("cp -a $path $destdir","Copying $uri from DIR to $destdir");
|
---|
[319] | 1100 | } elsif (($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
| 1101 | my $f = basename($path);
|
---|
| 1102 | unlink "$ENV{'PBTMP'}/$f";
|
---|
| 1103 | if (-x "/usr/bin/wget") {
|
---|
[320] | 1104 | pb_system("/usr/bin/wget -nv -O $ENV{'PBTMP'}/$f $uri"," ");
|
---|
[319] | 1105 | } elsif (-x "/usr/bin/curl") {
|
---|
| 1106 | pb_system("/usr/bin/curl $uri -o $ENV{'PBTMP'}/$f","Downloading $uri with curl to $ENV{'PBTMP'}/$f\n");
|
---|
| 1107 | } else {
|
---|
| 1108 | die "Unable to download $uri.\nNo wget/curl available, please install one of those";
|
---|
| 1109 | }
|
---|
| 1110 | pb_cms_export("file://$ENV{'PBTMP'}/$f",$source,$destdir);
|
---|
| 1111 | } elsif ($scheme eq "file") {
|
---|
| 1112 | use File::MimeInfo;
|
---|
| 1113 | my $mm = mimetype($path);
|
---|
| 1114 | pb_log(2,"mimetype: $mm\n");
|
---|
[320] | 1115 | pb_mkdir_p($destdir);
|
---|
[319] | 1116 |
|
---|
[344] | 1117 | # Check whether the file is well formed
|
---|
| 1118 | # (containing already a directory with the project-version name)
|
---|
| 1119 | my ($pbwf) = pb_conf_get_if("pbwf");
|
---|
| 1120 | if ((defined $pbwf) && (defined $pbwf->{$ENV{'PBPROJ'}})) {
|
---|
| 1121 | $destdir = dirname($destdir);
|
---|
| 1122 | }
|
---|
| 1123 |
|
---|
[319] | 1124 | if ($mm =~ /\/x-bzip-compressed-tar$/) {
|
---|
| 1125 | # tar+bzip2
|
---|
[320] | 1126 | pb_system("cd $destdir ; tar xfj $path","Extracting $path in $destdir");
|
---|
[319] | 1127 | } elsif ($mm =~ /\/x-lzma-compressed-tar$/) {
|
---|
| 1128 | # tar+lzma
|
---|
[320] | 1129 | pb_system("cd $destdir ; tar xfY $path","Extracting $path in $destdir");
|
---|
[319] | 1130 | } elsif ($mm =~ /\/x-compressed-tar$/) {
|
---|
| 1131 | # tar+gzip
|
---|
[320] | 1132 | pb_system("cd $destdir ; tar xfz $path","Extracting $path in $destdir");
|
---|
[319] | 1133 | } elsif ($mm =~ /\/x-tar$/) {
|
---|
| 1134 | # tar
|
---|
[320] | 1135 | pb_system("cd $destdir ; tar xf $path","Extracting $path in $destdir");
|
---|
[319] | 1136 | } elsif ($mm =~ /\/zip$/) {
|
---|
| 1137 | # zip
|
---|
[320] | 1138 | pb_system("cd $destdir ; unzip $path","Extracting $path in $destdir");
|
---|
[319] | 1139 | }
|
---|
[331] | 1140 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 1141 | # CVS needs a relative path !
|
---|
[106] | 1142 | my $dir=dirname($destdir);
|
---|
| 1143 | my $base=basename($destdir);
|
---|
[331] | 1144 | # CVS also needs a modules name not a dir
|
---|
[342] | 1145 | #if (-d $source) {
|
---|
| 1146 | $tmp1 = basename($source);
|
---|
| 1147 | #} else {
|
---|
| 1148 | #$tmp1 = dirname($source);
|
---|
| 1149 | #$tmp1 = basename($tmp1);
|
---|
| 1150 | #}
|
---|
| 1151 | my $optcvs = "";
|
---|
| 1152 |
|
---|
| 1153 | # If we're working on the CVS itself
|
---|
| 1154 | my $cvstag = basename($ENV{'PBROOTDIR'});
|
---|
| 1155 | my $cvsopt = "";
|
---|
| 1156 | if ($cvstag eq "cvs") {
|
---|
| 1157 | my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
| 1158 | $cvsopt = "-D \"$pbdate\"";
|
---|
[115] | 1159 | } else {
|
---|
[342] | 1160 | # we're working on a tag which should be the last part of PBROOTDIR
|
---|
| 1161 | $cvsopt = "-r $cvstag";
|
---|
[115] | 1162 | }
|
---|
[342] | 1163 | pb_system("cd $dir ; cvs -d $account\@$host:$path export $cvsopt -d $base $tmp1","Exporting $tmp1 from $source under CVS to $destdir");
|
---|
[106] | 1164 | } else {
|
---|
[315] | 1165 | die "cms $scheme unknown";
|
---|
[106] | 1166 | }
|
---|
| 1167 | }
|
---|
| 1168 |
|
---|
[285] | 1169 |
|
---|
| 1170 | sub pb_create_authors {
|
---|
| 1171 |
|
---|
| 1172 | my $authors=shift;
|
---|
| 1173 | my $dest=shift;
|
---|
[315] | 1174 | my $scheme=shift;
|
---|
[285] | 1175 |
|
---|
[286] | 1176 | return if ($authors eq "/dev/null");
|
---|
| 1177 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
[320] | 1178 | # Save a potentially existing AUTHORS file and write instead toi AUTHORS.pb
|
---|
| 1179 | my $ext = "";
|
---|
| 1180 | if (-f "$dest/AUTHORS") {
|
---|
| 1181 | $ext = ".pb";
|
---|
| 1182 | }
|
---|
| 1183 | open(DAUTH,"> $dest/AUTHORS$ext") || die "Unable to create $dest/AUTHORS$ext";
|
---|
[285] | 1184 | print DAUTH "Authors of the project are:\n";
|
---|
| 1185 | print DAUTH "===========================\n";
|
---|
[286] | 1186 | while (<SAUTH>) {
|
---|
[285] | 1187 | my ($nick,$gcos) = split(/:/);
|
---|
[286] | 1188 | chomp($gcos);
|
---|
[285] | 1189 | print DAUTH "$gcos";
|
---|
[315] | 1190 | if (defined $scheme) {
|
---|
[320] | 1191 | # Do not give a scheme for flat types
|
---|
| 1192 | my $endstr="";
|
---|
| 1193 | if ("$ENV{'PBREVISION'}" ne "flat") {
|
---|
| 1194 | $endstr = " under $scheme";
|
---|
| 1195 | }
|
---|
| 1196 | print DAUTH " ($nick$endstr)\n";
|
---|
[286] | 1197 | } else {
|
---|
| 1198 | print DAUTH "\n";
|
---|
| 1199 | }
|
---|
[285] | 1200 | }
|
---|
| 1201 | close(DAUTH);
|
---|
[286] | 1202 | close(SAUTH);
|
---|
[285] | 1203 | }
|
---|
| 1204 |
|
---|
[106] | 1205 | sub pb_cms_log {
|
---|
[320] | 1206 |
|
---|
[315] | 1207 | my $scheme = shift;
|
---|
[106] | 1208 | my $pkgdir = shift;
|
---|
[285] | 1209 | my $dest = shift;
|
---|
[286] | 1210 | my $chglog = shift;
|
---|
[285] | 1211 | my $authors = shift;
|
---|
[106] | 1212 |
|
---|
[315] | 1213 | pb_create_authors($authors,$dest,$scheme);
|
---|
[285] | 1214 |
|
---|
[320] | 1215 | if ($scheme =~ /^svn/) {
|
---|
[286] | 1216 | if (! -f "$dest/ChangeLog") {
|
---|
| 1217 | if (-x "/usr/bin/svn2cl") {
|
---|
[331] | 1218 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 1219 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 1220 | close(CL);
|
---|
[315] | 1221 | pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
|
---|
[286] | 1222 | } else {
|
---|
| 1223 | # To be written from pbcl
|
---|
| 1224 | pb_system("svn log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
| 1225 | }
|
---|
[285] | 1226 | }
|
---|
[320] | 1227 | } elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
[288] | 1228 | if (! -f "$dest/ChangeLog") {
|
---|
| 1229 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
| 1230 | }
|
---|
[331] | 1231 | } elsif ($scheme =~ /^cvs/) {
|
---|
[106] | 1232 | my $tmp=basename($pkgdir);
|
---|
| 1233 | # CVS needs a relative path !
|
---|
[286] | 1234 | if (! -f "$dest/ChangeLog") {
|
---|
| 1235 | if (-x "/usr/bin/cvs2cl") {
|
---|
[331] | 1236 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 1237 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 1238 | close(CL);
|
---|
[315] | 1239 | pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
|
---|
[286] | 1240 | } else {
|
---|
| 1241 | # To be written from pbcl
|
---|
| 1242 | pb_system("cvs log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
| 1243 | }
|
---|
[285] | 1244 | }
|
---|
[106] | 1245 | } else {
|
---|
[315] | 1246 | die "cms $scheme unknown";
|
---|
[106] | 1247 | }
|
---|
| 1248 | }
|
---|
| 1249 |
|
---|
[333] | 1250 | # This function is only called with a real CMS system
|
---|
[331] | 1251 | sub pb_cms_get_uri {
|
---|
[318] | 1252 |
|
---|
[315] | 1253 | my $scheme = shift;
|
---|
[314] | 1254 | my $dir = shift;
|
---|
[315] | 1255 |
|
---|
| 1256 | my $res = "";
|
---|
[204] | 1257 | my $void = "";
|
---|
[106] | 1258 |
|
---|
[315] | 1259 | if ($scheme =~ /^svn/) {
|
---|
[314] | 1260 | open(PIPE,"LANGUAGE=C svn info $dir |") || return("");
|
---|
[204] | 1261 | while (<PIPE>) {
|
---|
[331] | 1262 | ($void,$res) = split(/^URL:/) if (/^URL:/);
|
---|
[204] | 1263 | }
|
---|
[318] | 1264 | $res =~ s/^\s*//;
|
---|
[204] | 1265 | close(PIPE);
|
---|
[315] | 1266 | chomp($res);
|
---|
[331] | 1267 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 1268 | # This path is always the root path of CVS, but we may be below
|
---|
| 1269 | open(FILE,"$dir/CVS/Root") || die "$dir isn't CVS controlled";
|
---|
| 1270 | $res = <FILE>;
|
---|
| 1271 | chomp($res);
|
---|
| 1272 | close(FILE);
|
---|
| 1273 | # Find where we are in the tree
|
---|
| 1274 | my $rdir = $dir;
|
---|
| 1275 | while ((! -d "$rdir/CVSROOT") && ($rdir ne "/")) {
|
---|
| 1276 | $rdir = dirname($rdir);
|
---|
| 1277 | }
|
---|
| 1278 | die "Unable to find a CVSROOT dir in the parents of $dir" if (! -d "$rdir/CVSROOT");
|
---|
| 1279 | #compute our place under that root dir - should be a relative path
|
---|
| 1280 | $dir =~ s|^$rdir||;
|
---|
| 1281 | my $suffix = "";
|
---|
| 1282 | $suffix = "$dir" if ($dir ne "");
|
---|
| 1283 |
|
---|
| 1284 | my $prefix = "";
|
---|
| 1285 | if ($scheme =~ /ssh/) {
|
---|
| 1286 | $prefix = "cvs+ssh://";
|
---|
| 1287 | } else {
|
---|
| 1288 | $prefix = "cvs://";
|
---|
| 1289 | }
|
---|
| 1290 | $res = $prefix.$res.$suffix;
|
---|
[204] | 1291 | } else {
|
---|
[315] | 1292 | die "cms $scheme unknown";
|
---|
[204] | 1293 | }
|
---|
[318] | 1294 | pb_log(2,"Found CMS info: $res\n");
|
---|
[315] | 1295 | return($res);
|
---|
[204] | 1296 | }
|
---|
| 1297 |
|
---|
| 1298 | sub pb_cms_copy {
|
---|
[315] | 1299 | my $scheme = shift;
|
---|
[204] | 1300 | my $oldurl = shift;
|
---|
| 1301 | my $newurl = shift;
|
---|
| 1302 |
|
---|
[331] | 1303 | if ($scheme =~ /^svn/) {
|
---|
[212] | 1304 | pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");
|
---|
[315] | 1305 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1306 | } elsif ($scheme =~ /^cvs/) {
|
---|
[204] | 1307 | } else {
|
---|
[315] | 1308 | die "cms $scheme unknown";
|
---|
[204] | 1309 | }
|
---|
| 1310 | }
|
---|
| 1311 |
|
---|
| 1312 | sub pb_cms_checkout {
|
---|
[315] | 1313 | my $scheme = shift;
|
---|
[204] | 1314 | my $url = shift;
|
---|
| 1315 | my $destination = shift;
|
---|
| 1316 |
|
---|
[315] | 1317 | if ($scheme =~ /^svn/) {
|
---|
[320] | 1318 | pb_system("svn co $url $destination","Checking out $url to $destination ");
|
---|
[344] | 1319 | } elsif (($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
| 1320 | return;
|
---|
[331] | 1321 | } elsif ($scheme =~ /^cvs/) {
|
---|
[344] | 1322 | pb_system("cvs co $url $destination","Checking out $url to $destination ");
|
---|
[204] | 1323 | } else {
|
---|
[315] | 1324 | die "cms $scheme unknown";
|
---|
[204] | 1325 | }
|
---|
| 1326 | }
|
---|
| 1327 |
|
---|
[208] | 1328 | sub pb_cms_checkin {
|
---|
[315] | 1329 | my $scheme = shift;
|
---|
[208] | 1330 | my $dir = shift;
|
---|
| 1331 |
|
---|
[212] | 1332 | my $ver = basename($dir);
|
---|
[331] | 1333 | if ($scheme =~ /^svn/) {
|
---|
[212] | 1334 | pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir");
|
---|
[208] | 1335 | pb_system("svn up $dir","Updating $dir");
|
---|
[315] | 1336 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1337 | } elsif ($scheme =~ /^cvs/) {
|
---|
[208] | 1338 | } else {
|
---|
[315] | 1339 | die "cms $scheme unknown";
|
---|
[208] | 1340 | }
|
---|
| 1341 | }
|
---|
| 1342 |
|
---|
[204] | 1343 | sub pb_cms_isdiff {
|
---|
[315] | 1344 | my $scheme = shift;
|
---|
[358] | 1345 | my $dir =shift;
|
---|
[204] | 1346 |
|
---|
[331] | 1347 | if ($scheme =~ /^svn/) {
|
---|
[358] | 1348 | open(PIPE,"svn diff $dir |") || die "Unable to get svn diff from $dir";
|
---|
[204] | 1349 | my $l = 0;
|
---|
| 1350 | while (<PIPE>) {
|
---|
| 1351 | $l++;
|
---|
| 1352 | }
|
---|
| 1353 | return($l);
|
---|
[315] | 1354 | } elsif ($scheme eq "flat") {
|
---|
[331] | 1355 | } elsif ($scheme =~ /^cvs/) {
|
---|
[358] | 1356 | open(PIPE,"cvs diff $dir |") || die "Unable to get svn diff from $dir";
|
---|
| 1357 | my $l = 0;
|
---|
| 1358 | while (<PIPE>) {
|
---|
| 1359 | # Skipping normal messages
|
---|
| 1360 | next if (/^cvs diff:/);
|
---|
| 1361 | $l++;
|
---|
| 1362 | }
|
---|
| 1363 | return($l);
|
---|
[204] | 1364 | } else {
|
---|
[315] | 1365 | die "cms $scheme unknown";
|
---|
[204] | 1366 | }
|
---|
| 1367 | }
|
---|
| 1368 |
|
---|
[77] | 1369 | # Get all filters to apply
|
---|
| 1370 | # They're cumulative from less specific to most specific
|
---|
| 1371 | # suffix is .pbf
|
---|
| 1372 |
|
---|
| 1373 | sub pb_get_filters {
|
---|
| 1374 |
|
---|
| 1375 | my @ffiles;
|
---|
[235] | 1376 | my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3);
|
---|
| 1377 | my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3);
|
---|
[77] | 1378 | my $pbpkg = shift || die "No package specified";
|
---|
[236] | 1379 | my $dtype = shift || "";
|
---|
| 1380 | my $dfam = shift || "";
|
---|
| 1381 | my $ddir = shift || "";
|
---|
| 1382 | my $dver = shift || "";
|
---|
[344] | 1383 | my $ptr = undef; # returned value pointer on the hash of filters
|
---|
[291] | 1384 | my %h;
|
---|
[77] | 1385 |
|
---|
[169] | 1386 | # Global filter files first, then package specificities
|
---|
[339] | 1387 | if (-d "$ENV{'PBROOTDIR'}/pbfilter") {
|
---|
| 1388 | $mfile00 = "$ENV{'PBROOTDIR'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/all.pbf");
|
---|
| 1389 | $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$dtype.pbf");
|
---|
| 1390 | $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$dfam.pbf");
|
---|
| 1391 | $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$ddir.pbf");
|
---|
| 1392 | $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/$ddir-$dver.pbf");
|
---|
[169] | 1393 |
|
---|
[231] | 1394 | push @ffiles,$mfile00 if (defined $mfile00);
|
---|
[169] | 1395 | push @ffiles,$mfile0 if (defined $mfile0);
|
---|
| 1396 | push @ffiles,$mfile1 if (defined $mfile1);
|
---|
| 1397 | push @ffiles,$mfile2 if (defined $mfile2);
|
---|
| 1398 | push @ffiles,$mfile3 if (defined $mfile3);
|
---|
| 1399 | }
|
---|
| 1400 |
|
---|
[339] | 1401 | if (-d "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter") {
|
---|
| 1402 | $ffile00 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf");
|
---|
| 1403 | $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dtype.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dtype.pbf");
|
---|
| 1404 | $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dfam.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$dfam.pbf");
|
---|
| 1405 | $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir.pbf");
|
---|
| 1406 | $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir-$dver.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$ddir-$dver.pbf");
|
---|
[77] | 1407 |
|
---|
[231] | 1408 | push @ffiles,$ffile00 if (defined $ffile00);
|
---|
[77] | 1409 | push @ffiles,$ffile0 if (defined $ffile0);
|
---|
| 1410 | push @ffiles,$ffile1 if (defined $ffile1);
|
---|
| 1411 | push @ffiles,$ffile2 if (defined $ffile2);
|
---|
| 1412 | push @ffiles,$ffile3 if (defined $ffile3);
|
---|
| 1413 | }
|
---|
| 1414 | if (@ffiles) {
|
---|
[315] | 1415 | pb_log(2,"DEBUG ffiles: ".Dumper(\@ffiles)."\n");
|
---|
[79] | 1416 |
|
---|
[291] | 1417 | foreach my $f (@ffiles) {
|
---|
| 1418 | open(CONF,$f) || next;
|
---|
| 1419 | while(<CONF>) {
|
---|
| 1420 | if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
|
---|
| 1421 | $h{$1}{$2}=$3;
|
---|
| 1422 | }
|
---|
[79] | 1423 | }
|
---|
[291] | 1424 | close(CONF);
|
---|
[79] | 1425 |
|
---|
[291] | 1426 | $ptr = $h{"filter"};
|
---|
[315] | 1427 | pb_log(2,"DEBUG f:".Dumper($ptr)."\n");
|
---|
[291] | 1428 | }
|
---|
[77] | 1429 | }
|
---|
[344] | 1430 | return($ptr);
|
---|
[77] | 1431 | }
|
---|
| 1432 |
|
---|
[236] | 1433 | # Function which applies filter on pb build files
|
---|
[77] | 1434 | sub pb_filter_file_pb {
|
---|
| 1435 |
|
---|
| 1436 | my $f=shift;
|
---|
| 1437 | my $ptr=shift;
|
---|
| 1438 | my %filter=%$ptr;
|
---|
| 1439 | my $destfile=shift;
|
---|
| 1440 | my $dtype=shift;
|
---|
[99] | 1441 | my $pbsuf=shift;
|
---|
[297] | 1442 | my $pbproj=shift;
|
---|
[80] | 1443 | my $pbpkg=shift;
|
---|
| 1444 | my $pbver=shift;
|
---|
| 1445 | my $pbtag=shift;
|
---|
| 1446 | my $pbrev=shift;
|
---|
| 1447 | my $pbdate=shift;
|
---|
[108] | 1448 | my $defpkgdir = shift;
|
---|
| 1449 | my $extpkgdir = shift;
|
---|
[174] | 1450 | my $pbpackager = shift;
|
---|
[285] | 1451 | my $chglog = shift || undef;
|
---|
[77] | 1452 |
|
---|
[315] | 1453 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
[77] | 1454 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1455 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1456 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1457 | while (<FILE>) {
|
---|
| 1458 | my $line = $_;
|
---|
| 1459 | foreach my $s (keys %filter) {
|
---|
| 1460 | # Process single variables
|
---|
[315] | 1461 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
[77] | 1462 | my $tmp = $filter{$s};
|
---|
| 1463 | next if (not defined $tmp);
|
---|
| 1464 | # Expand variables if any single one found
|
---|
[315] | 1465 | pb_log(2,"DEBUG tmp: $tmp\n");
|
---|
[77] | 1466 | if ($tmp =~ /\$/) {
|
---|
| 1467 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1468 | # special case for ChangeLog only for pb
|
---|
[259] | 1469 | } elsif (($s =~ /^PBLOG$/) && ($line =~ /^PBLOG$/)) {
|
---|
[108] | 1470 | my $p = $defpkgdir->{$pbpkg};
|
---|
| 1471 | $p = $extpkgdir->{$pbpkg} if (not defined $p);
|
---|
[285] | 1472 | pb_changelog($dtype, $pbpkg, $pbver, $pbtag, $pbsuf, $p, \*DEST, $tmp, $chglog);
|
---|
[254] | 1473 | $tmp = "";
|
---|
[77] | 1474 | }
|
---|
| 1475 | $line =~ s|$s|$tmp|;
|
---|
| 1476 | }
|
---|
| 1477 | print DEST $line;
|
---|
| 1478 | }
|
---|
| 1479 | close(FILE);
|
---|
| 1480 | close(DEST);
|
---|
| 1481 | }
|
---|
| 1482 |
|
---|
| 1483 | # Function which applies filter on files (external call)
|
---|
[315] | 1484 | sub pb_filter_file_inplace {
|
---|
| 1485 |
|
---|
| 1486 | my $ptr=shift;
|
---|
| 1487 | my %filter=%$ptr;
|
---|
| 1488 | my $destfile=shift;
|
---|
| 1489 | my $pbproj=shift;
|
---|
| 1490 | my $pbpkg=shift;
|
---|
| 1491 | my $pbver=shift;
|
---|
| 1492 | my $pbtag=shift;
|
---|
| 1493 | my $pbrev=shift;
|
---|
| 1494 | my $pbdate=shift;
|
---|
| 1495 | my $pbpackager=shift;
|
---|
| 1496 |
|
---|
| 1497 | my $cp = "$ENV{'PBTMP'}/".basename($destfile);
|
---|
| 1498 | copy($destfile,$cp) || die "Unable to create $cp";
|
---|
| 1499 |
|
---|
| 1500 | pb_filter_file($cp,$ptr,$destfile,$pbproj,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
|
---|
| 1501 | unlink $cp;
|
---|
| 1502 | }
|
---|
| 1503 |
|
---|
| 1504 | # Function which applies filter on files (external call)
|
---|
[77] | 1505 | sub pb_filter_file {
|
---|
| 1506 |
|
---|
| 1507 | my $f=shift;
|
---|
| 1508 | my $ptr=shift;
|
---|
| 1509 | my %filter=%$ptr;
|
---|
| 1510 | my $destfile=shift;
|
---|
[298] | 1511 | my $pbproj=shift;
|
---|
[80] | 1512 | my $pbpkg=shift;
|
---|
| 1513 | my $pbver=shift;
|
---|
| 1514 | my $pbtag=shift;
|
---|
| 1515 | my $pbrev=shift;
|
---|
| 1516 | my $pbdate=shift;
|
---|
[174] | 1517 | my $pbpackager=shift;
|
---|
[77] | 1518 |
|
---|
[315] | 1519 | pb_log(2,"DEBUG: From $f to $destfile\n");
|
---|
[77] | 1520 | pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
|
---|
| 1521 | open(DEST,"> $destfile") || die "Unable to create $destfile";
|
---|
| 1522 | open(FILE,"$f") || die "Unable to open $f: $!";
|
---|
| 1523 | while (<FILE>) {
|
---|
| 1524 | my $line = $_;
|
---|
| 1525 | foreach my $s (keys %filter) {
|
---|
| 1526 | # Process single variables
|
---|
[315] | 1527 | pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
|
---|
[77] | 1528 | my $tmp = $filter{$s};
|
---|
| 1529 | next if (not defined $tmp);
|
---|
| 1530 | # Expand variables if any single one found
|
---|
| 1531 | if ($tmp =~ /\$/) {
|
---|
| 1532 | eval { $tmp =~ s/(\$\w+)/$1/eeg };
|
---|
| 1533 | }
|
---|
| 1534 | $line =~ s|$s|$tmp|;
|
---|
| 1535 | }
|
---|
| 1536 | print DEST $line;
|
---|
| 1537 | }
|
---|
| 1538 | close(FILE);
|
---|
| 1539 | close(DEST);
|
---|
| 1540 | }
|
---|
| 1541 |
|
---|
[315] | 1542 | sub pb_log_init {
|
---|
[77] | 1543 |
|
---|
[315] | 1544 | $debug = shift || 0;
|
---|
| 1545 | $LOG = shift || \*STDOUT;
|
---|
| 1546 |
|
---|
| 1547 | }
|
---|
| 1548 |
|
---|
| 1549 | sub pb_log {
|
---|
| 1550 |
|
---|
| 1551 | my $dlevel = shift;
|
---|
| 1552 | my $msg = shift;
|
---|
| 1553 |
|
---|
[318] | 1554 | print $LOG "$msg" if ($dlevel <= $debug);
|
---|
[315] | 1555 | }
|
---|
| 1556 |
|
---|
[316] | 1557 | #
|
---|
[353] | 1558 | # Return the list of packages we are working on in a CMS action
|
---|
[316] | 1559 | #
|
---|
[353] | 1560 | sub pb_cms_get_pkg {
|
---|
[316] | 1561 |
|
---|
| 1562 | my @pkgs = ();
|
---|
| 1563 | my $defpkgdir = shift || undef;
|
---|
| 1564 | my $extpkgdir = shift || undef;
|
---|
| 1565 |
|
---|
| 1566 | # Get packages list
|
---|
| 1567 | if (not defined $ARGV[0]) {
|
---|
| 1568 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 1569 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
[317] | 1570 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
[316] | 1571 | push(@pkgs, keys %$extpkgdir) if (defined $extpkgdir);
|
---|
| 1572 | } else {
|
---|
| 1573 | @pkgs = @ARGV;
|
---|
| 1574 | }
|
---|
| 1575 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 1576 | return(\@pkgs);
|
---|
| 1577 | }
|
---|
| 1578 |
|
---|
[353] | 1579 | #
|
---|
| 1580 | # Return the list of packages we are working on in a non CMS action
|
---|
[339] | 1581 | #
|
---|
[353] | 1582 | sub pb_get_pkg {
|
---|
| 1583 |
|
---|
| 1584 | my @pkgs = ();
|
---|
| 1585 |
|
---|
| 1586 | my ($var) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg");
|
---|
| 1587 | @pkgs = keys %$var;
|
---|
| 1588 |
|
---|
| 1589 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 1590 | return(\@pkgs);
|
---|
| 1591 | }
|
---|
| 1592 |
|
---|
| 1593 | #
|
---|
[339] | 1594 | # Check pbconf/project cms compliance
|
---|
| 1595 | #
|
---|
[327] | 1596 | sub pb_cms_compliant {
|
---|
| 1597 |
|
---|
| 1598 | my $param = shift;
|
---|
| 1599 | my $envar = shift;
|
---|
| 1600 | my $defdir = shift;
|
---|
| 1601 | my $uri = shift;
|
---|
| 1602 | my $pbinit = shift;
|
---|
[339] | 1603 | my %pdir;
|
---|
[327] | 1604 |
|
---|
[339] | 1605 | my ($pdir) = pb_conf_get_if($param) if (defined $param);
|
---|
| 1606 | if (defined $pdir) {
|
---|
| 1607 | %pdir = %$pdir;
|
---|
| 1608 | }
|
---|
[327] | 1609 |
|
---|
[339] | 1610 |
|
---|
| 1611 | if ((defined $pdir) && (%pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {
|
---|
[327] | 1612 | # That's always the environment variable that will be used
|
---|
| 1613 | $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};
|
---|
| 1614 | } else {
|
---|
[339] | 1615 | if (defined $param) {
|
---|
| 1616 | pb_log(1,"WARNING: no $param defined, using $defdir\n");
|
---|
| 1617 | pb_log(1," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
| 1618 | pb_log(1," if you want to use another directory\n");
|
---|
| 1619 | }
|
---|
[327] | 1620 | $ENV{$envar} = "$defdir";
|
---|
| 1621 | }
|
---|
| 1622 |
|
---|
| 1623 | # Expand potential env variable in it
|
---|
| 1624 | eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
| 1625 | pb_log(2,"$envar: $ENV{$envar}\n");
|
---|
| 1626 |
|
---|
| 1627 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
| 1628 |
|
---|
| 1629 | if ((! -d "$ENV{$envar}") || (defined $pbinit)) {
|
---|
[344] | 1630 | if (defined $pbinit) {
|
---|
| 1631 | pb_mkdir_p("$ENV{$envar}");
|
---|
| 1632 | } else {
|
---|
| 1633 | pb_log(1,"Checking out $uri\n");
|
---|
| 1634 | pb_cms_checkout($scheme,$uri,$ENV{$envar});
|
---|
| 1635 | }
|
---|
[333] | 1636 | } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/)) {
|
---|
| 1637 | # Do not compare if it's not a real cms
|
---|
| 1638 | return;
|
---|
[327] | 1639 | } else {
|
---|
| 1640 | pb_log(1,"$uri found locally, checking content\n");
|
---|
[331] | 1641 | my $cmsurl = pb_cms_get_uri($scheme,$ENV{$envar});
|
---|
[327] | 1642 | my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
|
---|
| 1643 | if ($cmsurl ne $uri) {
|
---|
| 1644 | # The local content doesn't correpond to the repository
|
---|
| 1645 | pb_log(0,"ERROR: Inconsistency detected:\n");
|
---|
| 1646 | pb_log(0," * $ENV{$envar} refers to $cmsurl but\n");
|
---|
| 1647 | pb_log(0," * $ENV{'PBETC'} refers to $uri\n");
|
---|
| 1648 | die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
|
---|
| 1649 | } else {
|
---|
| 1650 | pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
|
---|
| 1651 | # they match - do nothing - there may be local changes
|
---|
| 1652 | }
|
---|
| 1653 | }
|
---|
| 1654 | }
|
---|
| 1655 |
|
---|
[328] | 1656 | sub pb_changelog {
|
---|
| 1657 |
|
---|
| 1658 | my $dtype = shift;
|
---|
| 1659 | my $pkg = shift;
|
---|
| 1660 | my $pbver = shift;
|
---|
| 1661 | my $pbtag = shift;
|
---|
| 1662 | my $dsuf = shift;
|
---|
| 1663 | my $path = shift;
|
---|
| 1664 | my $OUTPUT = shift;
|
---|
| 1665 | my $doit = shift;
|
---|
| 1666 | my $chglog = shift || undef;
|
---|
| 1667 |
|
---|
| 1668 | my $log = "";
|
---|
| 1669 |
|
---|
| 1670 | # For date handling
|
---|
| 1671 | $ENV{LANG}="C";
|
---|
| 1672 |
|
---|
| 1673 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
| 1674 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
| 1675 | (not (defined $pbver)) || ($pbver eq "") ||
|
---|
| 1676 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
| 1677 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
| 1678 | (not (defined $path)) || ($path eq "") ||
|
---|
| 1679 | (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
|
---|
| 1680 | (not (defined $doit)) || ($doit eq "")) {
|
---|
| 1681 | print $OUTPUT "\n";
|
---|
| 1682 | return;
|
---|
| 1683 | }
|
---|
| 1684 |
|
---|
| 1685 | if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
|
---|
| 1686 | #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
|
---|
| 1687 | print $OUTPUT "\n";
|
---|
| 1688 | return;
|
---|
| 1689 | }
|
---|
| 1690 |
|
---|
| 1691 | my $date;
|
---|
| 1692 | my $ndate;
|
---|
| 1693 | my $n2date;
|
---|
| 1694 | my $ver;
|
---|
| 1695 | my $ver2;
|
---|
[344] | 1696 | my ($pbpackager) = pb_conf_get("pbpackager");
|
---|
[328] | 1697 |
|
---|
[344] | 1698 | if (not defined $pbpackager->{$ENV{'PBPROJ'}}) {
|
---|
| 1699 | $pbpackager->{$ENV{'PBPROJ'}} = "undefined\@noproject.noorg";
|
---|
| 1700 | }
|
---|
| 1701 |
|
---|
[328] | 1702 | # If we don't need to do it, or don't have it fake something
|
---|
| 1703 | if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
|
---|
| 1704 | my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
| 1705 | $date = strftime("%Y-%m-%d", @date);
|
---|
| 1706 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 1707 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 1708 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 1709 | $ver2 = "$pbver-$pbtag$dsuf";
|
---|
[344] | 1710 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
[328] | 1711 | print $OUTPUT "- Updated to $pbver\n";
|
---|
| 1712 | }
|
---|
| 1713 | if ($dtype eq "deb") {
|
---|
| 1714 | print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
|
---|
| 1715 | print $OUTPUT "\n";
|
---|
[344] | 1716 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
[328] | 1717 | }
|
---|
| 1718 | return;
|
---|
| 1719 | }
|
---|
| 1720 |
|
---|
| 1721 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
| 1722 |
|
---|
| 1723 | # Skip first 4 lines
|
---|
| 1724 | my $tmp = <INPUT>;
|
---|
| 1725 | $tmp = <INPUT>;
|
---|
| 1726 | $tmp = <INPUT>;
|
---|
| 1727 | if ($dtype eq "announce") {
|
---|
| 1728 | print $OUTPUT $tmp;
|
---|
| 1729 | }
|
---|
| 1730 | $tmp = <INPUT>;
|
---|
| 1731 | if ($dtype eq "announce") {
|
---|
| 1732 | print $OUTPUT $tmp;
|
---|
| 1733 | }
|
---|
| 1734 |
|
---|
| 1735 | my $first=1;
|
---|
| 1736 |
|
---|
| 1737 | # Handle each block separated by newline
|
---|
| 1738 | while (<INPUT>) {
|
---|
| 1739 | ($ver, $date) = split(/ /);
|
---|
| 1740 | $ver =~ s/^v//;
|
---|
| 1741 | chomp($date);
|
---|
| 1742 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
| 1743 | #pb_log(2,"**$date**\n";
|
---|
| 1744 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 1745 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 1746 | #pb_log(2,"**$ndate**\n";
|
---|
| 1747 |
|
---|
| 1748 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 1749 | if ($ver !~ /-/) {
|
---|
| 1750 | if ($first eq 1) {
|
---|
| 1751 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
| 1752 | $first=0;
|
---|
| 1753 | } else {
|
---|
| 1754 | $ver2 = "$ver-1$dsuf";
|
---|
| 1755 | }
|
---|
| 1756 | } else {
|
---|
| 1757 | $ver2 = "$ver$dsuf";
|
---|
| 1758 | }
|
---|
[344] | 1759 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
[328] | 1760 | print $OUTPUT "- Updated to $ver\n";
|
---|
| 1761 | }
|
---|
| 1762 | if ($dtype eq "deb") {
|
---|
| 1763 | print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
| 1764 | print $OUTPUT "\n";
|
---|
| 1765 | }
|
---|
| 1766 |
|
---|
| 1767 | $tmp = <INPUT>;
|
---|
| 1768 | while ($tmp !~ /^$/) {
|
---|
| 1769 | if ($dtype eq "deb") {
|
---|
| 1770 | $tmp =~ s/^- //;
|
---|
| 1771 | print $OUTPUT " * $tmp";
|
---|
| 1772 | } elsif ($dtype eq "rpm") {
|
---|
| 1773 | print $OUTPUT "$tmp";
|
---|
| 1774 | } else {
|
---|
| 1775 | print $OUTPUT "$tmp";
|
---|
| 1776 | }
|
---|
| 1777 | last if (eof(INPUT));
|
---|
| 1778 | $tmp = <INPUT>;
|
---|
| 1779 | }
|
---|
| 1780 | print $OUTPUT "\n";
|
---|
| 1781 |
|
---|
| 1782 | if ($dtype eq "deb") {
|
---|
| 1783 | # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
|
---|
[344] | 1784 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
[328] | 1785 | }
|
---|
| 1786 |
|
---|
| 1787 | last if (eof(INPUT));
|
---|
| 1788 | last if ($dtype eq "announce");
|
---|
| 1789 | }
|
---|
| 1790 | close(INPUT);
|
---|
| 1791 | }
|
---|
[2] | 1792 | 1;
|
---|