Changeset 318 in ProjectBuilder
- Timestamp:
- Feb 10, 2008, 4:37:43 PM (17 years ago)
- Location:
- devel/pb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r316 r318 23 23 use ProjectBuilder::Distribution qw (pb_distro_init); 24 24 use ProjectBuilder::Version qw (pb_version_init); 25 use ProjectBuilder::Base qw (pb_conf_read pb_conf_get 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);25 use ProjectBuilder::Base; 26 26 27 27 my %opts; # CLI Options … … 36 36 my %pbtag; # per package 37 37 my $pbrev; # Global REVISION variable 38 my @date =pb_get_date();38 my @date = pb_get_date(); 39 39 my $pbdate = strftime("%Y-%m-%d", @date); 40 my $debug = 0;41 40 my $pbaccount; # Login to use to connect to the VM 42 41 my $pbport; # Port to use to connect to the VM 43 42 my $newver; # New version to create 44 43 my $iso; # ISO iage for the VM to create 45 my $LOG = \*STDOUT;46 44 47 45 getopts('a:hi:l:m:P:p:qr:s:tvV:',\%opts); … … 53 51 } 54 52 if (defined $opts{'v'}) { 55 $debug++; 53 $debug = 2; 54 #$debug = $opts{'v'}; 55 pb_log(0,"Debug value: $debug\n"); 56 56 } 57 57 if (defined $opts{'q'}) { -
devel/pb/lib/ProjectBuilder/Base.pm
r317 r318 5 5 # $Id$ 6 6 # 7 8 package ProjectBuilder::Base; 7 9 8 10 use strict; … … 11 13 use File::Path; 12 14 use File::Copy; 13 use File::Temp qw /tempdir/;15 use File::Temp qw(tempdir); 14 16 use Data::Dumper; 15 17 use POSIX qw(strftime); 18 use Time::localtime qw(localtime); 16 19 17 20 use ProjectBuilder::Changelog qw (pb_changelog); 18 21 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 19 35 $ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc"; 20 21 my $debug = 0;22 my $LOG = \*STDOUT;23 36 24 37 sub pb_env_init { … … 53 66 if (defined $proj) { 54 67 pb_log(0,"WARNING: using $proj as default project as none has been specified\n"); 55 pb_log(0,"Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n"); 68 pb_log(0," Please either create a pbconf reference for project $proj in $ENV{'PBETC'}\n"); 69 pb_log(0," or call pb with the -p project option if you want to use another project\n"); 56 70 } 57 71 } … … 60 74 # That's always the environment variable that will be used 61 75 $ENV{'PBPROJ'} = $proj; 76 pb_log(2,"PBPROJ: $ENV{'PBPROJ'}\n"); 62 77 63 78 if (not defined ($pbconf{$ENV{'PBPROJ'}})) { … … 103 118 if ((not defined $pbdir) || (not defined $pbdir{$ENV{'PBPROJ'}})) { 104 119 pb_log(0,"WARNING: no pbdir defined, using /var/cache\n"); 105 pb_log(0,"Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n"); 120 pb_log(0," Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n"); 121 pb_log(0," if you want to use another directory\n"); 106 122 $ENV{'PBDIR'} = "/var/cache"; 107 123 } else { … … 113 129 eval { $ENV{'PBDIR'} =~ s/(\$ENV.+\})/$1/eeg }; 114 130 131 pb_log(2,"PBDIR: $ENV{'PBDIR'}\n"); 115 132 # 116 133 # Set delivery directory … … 118 135 $ENV{'PBDESTDIR'}="$ENV{'PBDIR'}/$ENV{'PBPROJ'}/delivery"; 119 136 137 pb_log(2,"PBDESTDIR: $ENV{'PBDESTDIR'}\n"); 120 138 # 121 139 # Removes all directory existing below the delivery dir … … 146 164 } 147 165 166 pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n"); 148 167 # 149 168 # Set temp directory … … 153 172 } 154 173 $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 ); 174 pb_log(2,"PBTMP: $ENV{'PBTMP'}\n"); 155 175 156 176 # … … 158 178 # 159 179 $ENV{'PBCONF'} = "$ENV{'PBDIR'}/$ENV{'PBPROJ'}/pbconf"; 180 pb_log(2,"PBCONF: $ENV{'PBCONF'}\n"); 160 181 161 182 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}}); 162 183 163 if (( not-d "$ENV{'PBCONF'}") || (defined $pbinit)) {184 if ((! -d "$ENV{'PBCONF'}") || (defined $pbinit)) { 164 185 pb_log(1,"Checking out pbconf\n"); 165 186 pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'}); … … 167 188 pb_log(1,"pbconf found, checking content\n"); 168 189 my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBCONF'},"URL:"); 169 if ($cmsurl !~ /^$scheme/) { 170 pb_log(1,"Content irrelevant, cleaning up and checking it out\n"); 190 my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl); 191 if ($scheme2 ne $scheme) { 192 pb_log(1,"WARNING: Content of $ENV{'PBCONF'} irrelevant, cleaning up and checking it out\n"); 171 193 pb_rm_rf("$ENV{'PBCONF'}"); 172 194 pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'}); … … 174 196 # The local content doesn't correpond to the repository 175 197 pb_log(0,"ERROR: Inconsistency detected:\n"); 176 pb_log(0," * $ENV{'PBCONF'} refers to $cmsurl but\n");177 pb_log(0," * $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n");198 pb_log(0," * $ENV{'PBCONF'} refers to $cmsurl but\n"); 199 pb_log(0," * $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n"); 178 200 die "Project $ENV{'PBPROJ'} is not Project-Builder compliant."; 179 201 } else { … … 194 216 = stat($d); 195 217 # Keep the most recent 218 pb_log(2,"Looking at $d: $mtime\n"); 196 219 if ($mtime > $maxmtime) { 197 220 $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$d"; … … 202 225 die "No directory found under $ENV{'PBCONF'}" if (not defined $ENV{'PBROOT'}); 203 226 pb_log(0,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n"); 204 pb_log(0," Please use -r release if you want to use another release\n");227 pb_log(0," Please use -r release if you want to use another release\n"); 205 228 } else { 206 229 my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot"); … … 848 871 849 872 # Everything is returned via ptr1 850 my @ptr1 = pb_conf_read_if("$ENV{'PBETC'}", @param); 851 my @ptr2 = pb_conf_read_if("$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb", @param); 873 my @ptr1 = (); 874 my @ptr2 = (); 875 @ptr1 = pb_conf_read_if("$ENV{'PBETC'}", @param) if (defined $ENV{'PBETC'}); 876 @ptr2 = pb_conf_read_if("$ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb", @param) if ((defined $ENV{'PBROOT'}) and (defined $ENV{'PBPROJ'})); 852 877 853 878 my $p1; … … 938 963 my $uri = shift || undef; 939 964 965 pb_log(2,"DEBUG: uri:$uri\n"); 940 966 # A URL has the format protocol://[ac@]host[:port][path[?query][#fragment]]. 941 967 # Cf man URI 942 968 my ($scheme, $authority, $path, $query, $fragment) = 943 $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|; 944 my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?|; 969 $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?| if (defined $uri); 970 my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?| if (defined $authority); 971 972 $scheme = "" if (not defined $scheme); 973 $authority = "" if (not defined $authority); 974 $path = "" if (not defined $path); 975 $account = "" if (not defined $account); 976 $host = "" if (not defined $host); 977 $port = "" if (not defined $port); 978 945 979 pb_log(2,"DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n"); 946 980 return($scheme, $account, $host, $port, $path); … … 986 1020 # Try to make it easy for us 987 1021 #pb_log(2,"WARNING: Assuming a local project under $ENV{'PBDIR'}/$ENV{'PBPROJ'}:\n"); 988 #pb_log(2," If not, pleaase setup a pbproj entry in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb\n");1022 #pb_log(2," If not, pleaase setup a pbproj entry in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb\n"); 989 1023 #return(""); 990 1024 #} … … 1107 1141 1108 1142 sub pb_cms_getinfo { 1143 1109 1144 my $scheme = shift; 1110 1145 my $dir = shift; … … 1119 1154 ($void,$res) = split(/^$info/) if (/^$info/); 1120 1155 } 1156 $res =~ s/^\s*//; 1121 1157 close(PIPE); 1122 1158 chomp($res); … … 1126 1162 die "cms $scheme unknown"; 1127 1163 } 1164 pb_log(2,"Found CMS info: $res\n"); 1128 1165 return($res); 1129 1166 } … … 1378 1415 my $msg = shift; 1379 1416 1380 print $LOG "$msg \n" if ($dlevel <= $debug);1417 print $LOG "$msg" if ($dlevel <= $debug); 1381 1418 } 1382 1419
Note:
See TracChangeset
for help on using the changeset viewer.