Changeset 74 in ProjectBuilder for devel/pb/lib
- Timestamp:
- Sep 1, 2007, 1:56:48 AM (17 years ago)
- Location:
- devel/pb/lib/ProjectBuilder
- Files:
-
- 2 deleted
- 1 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/lib/ProjectBuilder/Base.pm
r73 r74 1 1 #!/usr/bin/perl -w 2 2 # 3 # Creates common environment3 # Base subroutines for the Project-Builder project 4 4 # 5 5 # $Id$ … … 8 8 use strict; 9 9 use lib qw (lib); 10 use ProjectBuilder::pb qw (pb_init);11 10 use File::Basename; 12 11 use File::Path; 13 12 use File::Temp qw /tempdir/; 13 use AppConfig qw(ARGCOUNT_HASH); 14 14 use Data::Dumper; 15 use vars qw (%pbrc);16 15 17 16 $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc"; 18 17 19 sub env_init {18 sub pb_env_init { 20 19 21 20 my $proj=shift; … … 38 37 # and use its content 39 38 # 40 my $pbrc = pb_init("$ENV{'PBETC'}","pbrc"); 39 my $pbrc = pb_conf_read("$ENV{'PBETC'}","pbrc"); 40 print "DEBUG pbrc: ".Dumper($pbrc)."\n" if ($debug >= 1); 41 41 42 42 %pbrc = %$pbrc; … … 60 60 if (not defined $ENV{'PBROOT'}) { 61 61 if (-f $pbrc{$proj}) { 62 my $pbroot = pb_ init($pbrc{$proj},"pbroot");62 my $pbroot = pb_conf_read($pbrc{$proj},"pbroot"); 63 63 my %pbroot = %$pbroot; 64 64 # There is normaly only one line in it … … 75 75 die "Project $proj not Project-Builder compliant. Please populate $ENV{'PBCONF'}" if ( not -d "$ENV{'PBCONF'}"); 76 76 77 my %version = (); 78 my %confparam = (); 79 77 80 if (-f "$ENV{'PBCONF'}/$proj.pb") { 78 pb_conf_init("$ENV{'PBCONF'}/$proj.pb"); 81 # main parameter confparam (mandatory) 82 # List of pkg to build by default (mandatory) 83 # List of additional pkg to build when all is called (optional) 84 # Valid version names (optional) 85 # List of files to filter (optional) 86 my $ptr = pb_conf_read("$ENV{'PBCONF'}/$proj.pb","confparam","defpkgdir","extpkgdir","version","filteredfiles"); 87 my ($confparam, $defpkgdir, $extpkgdir, $version, $filteredfiles) = @$ptr; 88 print "DEBUG: confparam: ".Dumper($confparam)."\n" if ($debug >= 1); 89 print "DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n" if ($debug >= 1); 90 print "DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n" if ($debug >= 1); 91 print "DEBUG: version: ".Dumper($version)."\n" if ($debug >= 1); 92 print "DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n" if ($debug >= 1); 93 die "Unable to find confparam in $ENV{'PBCONF'}/$proj.pb" if (not defined $confparam); 94 die "Unable to find defpkgdir in $ENV{'PBCONF'}/$proj.pb" if (not defined $defpkgdir); 95 %confparam = %$confparam; 96 # Global 97 %defpkgdir = %$defpkgdir; 98 # Global 99 %extpkgdir = (); 100 %extpkgdir = %$defpkgdir if (defined $defpkgdir); 101 %version = (); 102 %version = %$version if (defined $version); 103 # Global 104 %filteredfiles = (); 105 %filteredfiles = %$filteredfiles if (defined $filteredfiles); 79 106 } else { 80 107 die "Unable to open $ENV{'PBCONF'}/$proj.pb"; … … 82 109 83 110 # 84 # Check content111 # Export content if needed 85 112 # 86 113 if (defined $confparam{"cvsroot"}) { 87 114 $ENV{'CVSROOT'} = $confparam{"cvsroot"}; 88 115 } 89 90 die "defpkgdir doesn't exist in $ENV{'PBETC'}/$proj.pb" if (not (defined %defpkgdir));91 116 92 117 # … … 110 135 111 136 # 112 # Get global TAG137 # Get global TAG 113 138 # 114 139 open(TAG, "$ENV{'PBCONF'}/TAG") || die "Unable to open $ENV{'PBCONF'}/TAG: $?"; … … 129 154 next if ($d =~ /^\./); 130 155 next if (-f "$ENV{'PBDESTDIR'}/$d"); 131 pb rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d");156 pb_rm_rf("$ENV{'PBDESTDIR'}/$d") if (-d "$ENV{'PBDESTDIR'}/$d"); 132 157 } 133 158 closedir(DIR); 134 159 } 135 160 if (! -d "$ENV{'PBDESTDIR'}") { 136 pb mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}";161 pb_mkdir_p($ENV{'PBDESTDIR'}) || die "Unable to recursively create $ENV{'PBDESTDIR'}"; 137 162 } 138 163 … … 141 166 # 142 167 $ENV{'PBBUILDDIR'}=$topdir."/build"; 143 pb rm_rf($ENV{'PBBUILDDIR'}) if (-d "$ENV{'PBBUILDDIR'}");144 pb mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}";168 pb_rm_rf($ENV{'PBBUILDDIR'}) if (-d "$ENV{'PBBUILDDIR'}"); 169 pb_mkdir_p($ENV{'PBBUILDDIR'}) || die "Unable to recursively create $ENV{'PBBUILDDIR'}"; 145 170 146 171 umask 0022; … … 148 173 } 149 174 150 sub pbmkdir_p { 175 # Internal mkdir -p function 176 sub pb_mkdir_p { 151 177 my @dir = @_; 152 178 my $ret = mkpath(@dir, 0, 0755); … … 154 180 } 155 181 156 sub pbrm_rf { 182 # Internal rm -rf function 183 sub pb_rm_rf { 157 184 my @dir = @_; 158 185 my $ret = rmtree(@dir, 0, 0); … … 160 187 } 161 188 162 sub pbsystem { 189 # Internal system function 190 sub pb_system { 163 191 164 192 my $cmd=shift; … … 175 203 } 176 204 } 205 206 # Function which returns a pointer on a hash 207 # corresponding to a declaration (arg2) in a conf file (arg1) 208 sub pb_conf_read { 209 210 my $conffile = shift; 211 my @param = @_; 212 my $trace; 213 my @ptr; 214 215 if ($debug > 0) { 216 $trace = 1; 217 } else { 218 $trace = 0; 219 } 220 221 222 my $config = AppConfig->new({ 223 # Auto Create variables mentioned in Conf file 224 CREATE => 1, 225 DEBUG => $trace, 226 GLOBAL => { 227 # Each conf item is a hash 228 ARGCOUNT => ARGCOUNT_HASH, 229 }, 230 }); 231 $config->file($conffile); 232 for my $param (@param) { 233 push @ptr,$config->get($param); 234 } 235 if ($#param == 0) { 236 print "DEBUG: param: ".Dumper($ptr[0])."\n" if ($debug >= 1); 237 return($ptr[0]); 238 } else { 239 my $ptr = \@ptr; 240 print "DEBUG: params: ".Dumper($ptr)."\n" if ($debug >= 1); 241 return($ptr); 242 } 243 } 244 245 sub pb_conf_init { 246 247 my $conffile = shift; 248 my $ptr; 249 my $trace; 250 251 if ($debug > 0) { 252 $trace = 1; 253 } else { 254 $trace = 0; 255 } 256 257 my $config = AppConfig->new({ 258 # Auto Create variables mentioned in Conf file 259 DEBUG => $trace, 260 CREATE => '1', 261 GLOBAL => { 262 # Each conf item is a hash 263 ARGCOUNT => ARGCOUNT_HASH, 264 }, 265 }); 266 $config->file($conffile); 267 268 # Root of the project to build 269 # needs at least 2 levels of dir as in the upper 270 # other dirs will be created and used 271 272 } 273 274 # Setup environment for CMS system 275 sub pb_cms_init { 276 277 my $proj = shift || undef; 278 my $ret; 279 280 my $cms = pb_conf_read("$ENV{'PBETC'}","cms"); 281 die "No CMS defined for $proj" if (not defined $cms); 282 my %cms = %$cms; 283 die "No CMS defined for $proj" if (not defined $cms{$proj}); 284 285 if ($cms{$proj} eq "svn") { 286 $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; svnversion .)`; 287 chomp($ENV{'PBREVISION'}); 288 $ENV{'PBCMSLOG'}="svn log"; 289 $ENV{'PBCMSLOGFILE'}="svn.log"; 290 $ENV{'PBCMSEXP'}="svn export"; 291 } elsif ($cms{$proj} eq "cvs") { 292 $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`; 293 chomp($ENV{'PBREVISION'}); 294 $ENV{'PBCMSLOG'}="cvs log"; 295 $ENV{'PBCMSLOGFILE'}="cvs.log"; 296 $ENV{'PBCMSEXP'}="cvs export" 297 } else { 298 die "CMS $cms{$proj} unknown"; 299 } 300 } 301 177 302 1; -
devel/pb/lib/ProjectBuilder/Changelog.pm
r73 r74 10 10 use File::Basename; 11 11 use English; 12 use ProjectBuilder::Base qw (pb_conf_read); 12 13 13 sub changelog {14 sub pb_changelog { 14 15 15 16 my $dtype = shift; … … 65 66 my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z"); 66 67 #print "**$ndate**\n"; 68 my $confparam = pb_conf_read("$ENV{'PBCONF'}/$ENV{'PBPROJ'}.pb", "confparam"); 69 my %confparam = %$confparam; 67 70 if (($dtype eq "rpm") || ($dtype eq "fc")) { 68 71 if ($ver !~ /-/) { -
devel/pb/lib/ProjectBuilder/Distribution.pm
r73 r74 8 8 use strict; 9 9 10 sub distro_init {10 sub pb_distro_init { 11 11 12 12 my $ddir = shift || undef; … … 17 17 18 18 # If we don't know which distribution we're on, then guess it 19 ($ddir,$dver) = get_distro() if ((not defined $ddir) || (not defined $dver));19 ($ddir,$dver) = pb_get_distro() if ((not defined $ddir) || (not defined $dver)); 20 20 21 21 # There shold be unicity of names between ddir dfam and dtype … … 82 82 } 83 83 84 sub get_distro {84 sub pb_get_distro { 85 85 86 86 # Cf: http://linuxmafia.com/faq/Admin/release-files.html … … 173 173 while (($d,$r) = each %single_rel_files) { 174 174 if (-f "$base/$r" && !-l "$base/$r") { 175 my $tmp= get_content("$base/$r");175 my $tmp=pb_get_content("$base/$r"); 176 176 # Found the only possibility. 177 177 # Try to get version and return … … 191 191 # Found one possibility. 192 192 # Get all distros concerned by that file 193 my $tmp= get_content("$base/$r");193 my $tmp=pb_get_content("$base/$r"); 194 194 my $found = 0; 195 195 my $ptr = $distro_similar{$d}; … … 221 221 } 222 222 223 sub get_content { 223 # get content of a file in a variable 224 sub pb_get_content { 224 225 225 226 my $file=shift; -
devel/pb/lib/ProjectBuilder/Version.pm
r53 r74 5 5 # and have been isolated here to avoid unrelated effects 6 6 # 7 use strict; 7 8 8 sub version_init { 9 $projectbuilderver = "PBVER"; 10 $projectbuilderrev = "PBREV"; 11 }; 12 1 9 sub pb_version_init { 10 11 my $projectbuilderver = "PBVER"; 12 my $projectbuilderrev = "PBREV"; 13 14 return($projectbuilderver,$projectbuilderrev); 15 } 16 1;
Note:
See TracChangeset
for help on using the changeset viewer.