Ticket #44654: cpan2port-uniq-deps.diff
File cpan2port-uniq-deps.diff, 3.5 KB (added by pixilla (Bradley Giesbrecht), 10 years ago) |
---|
-
cpan2port
65 65 use CPAN; 66 66 use Module::Depends; 67 67 use Module::Depends::Intrusive; 68 use List::MoreUtils qw(any );68 use List::MoreUtils qw(any uniq); 69 69 use Module::CoreList; 70 70 71 71 sub is_corelist { … … 95 95 return $name; 96 96 } 97 97 98 sub dependency_name { 99 my ( $name ) = shift; 100 $name = lc "p5\${perl5.major}-$name"; 101 $name =~ y/+/x/; 102 return $name; 103 } 104 98 105 sub debian { 99 106 my ( $name ) = shift; 100 107 $name = lc "lib$name-perl"; … … 132 139 $info; 133 140 } 134 141 135 sub from_port { (about(shift) or return () )->{ port} }142 sub from_port { (about(shift) or return () )->{dependency} } 136 143 137 144 sub about { 138 145 my ( $module_name, $config ) = @_; … … 170 177 $info{description} = $desc; 171 178 MSG::warn $desc; 172 179 } 173 $info{port} = package_name($info{prefix}); 174 $info{debian} = package_name($info{prefix}); 180 $info{port} = package_name($info{prefix}); 181 $info{dependency} = dependency_name($info{prefix}); 182 $info{debian} = package_name($info{prefix}); 175 183 $info{dist_dir} = "$$CPAN::Config{build_dir}/$info{prefix}-$info{version}"; 176 184 $info{module} = $module; 177 185 \%info; … … 219 227 $$info{maintainers} ||= 'nomaintainer'; 220 228 my $checksums = ''; 221 229 my $depends = ''; 222 my $build_depends = ''; 230 my $depends_build = ''; 231 my $depends_lib = ''; 223 232 my $use_module_build = ''; 224 233 225 234 if ( exists $$info{depends} ) { … … 229 238 $checksums = 'checksums '.join(" \\\n".(' 'x20),@hashes); 230 239 } 231 240 232 if ( my $dep_ref = Huggy::depends_on($info ) ) {233 my @depends =map {234 MSG::warn "$$info{name} requires $_";241 if ( my $dep_ref = Huggy::depends_on($info, during=>"build_requires") ) { 242 my @depends_build = Huggy::uniq map { 243 MSG::warn "$$info{name} build_requires $_"; 235 244 'port:'.Huggy::from_port $_ 236 } keys %{ $dep_ref }; 237 if (@depends) { 238 $depends = 'depends_lib-append '.join(" \\\n".(' 'x20),@depends); 245 } sort(keys %{ $dep_ref }); 246 if (@depends_build) { 247 unshift(@depends_build, ' depends_build-append'); 248 $depends_build = join(" \\\n".(' 'x20), @depends_build)."\n"; 239 249 } 240 250 } 241 if ( my $dep_ref = Huggy::depends_on($info , during=>"build_requires") ) {242 my @depends =map {243 MSG::warn "$$info{name} build_requires $_";251 if ( my $dep_ref = Huggy::depends_on($info) ) { 252 my @depends_lib = Huggy::uniq map { 253 MSG::warn "$$info{name} requires $_"; 244 254 'port:'.Huggy::from_port $_ 245 } keys %{ $dep_ref }; 246 if (@depends) { 247 $build_depends = 'depends_build-append '.join(" \\\n".(' 'x21),@depends); 255 } sort(keys %{ $dep_ref }); 256 if (@depends_lib) { 257 unshift(@depends_lib, ' depends_lib-append'); 258 $depends_lib = join(" \\\n".(' 'x20), @depends_lib)."\n"; 248 259 } 249 250 260 } 261 if ($depends_build.$depends_lib ne '') { 262 $depends = "\nif {\${perl5.major} != \"\"} {\n" . $depends_build . $depends_lib . "}\n"; 263 } 251 264 } 252 265 253 266 # If no Makefile.PL is present, maybe we need use_module_build? … … 297 310 298 311 $portfile .= <<STOP; 299 312 $checksums 300 301 $build_depends302 303 313 $depends 304 314 $use_module_build 305 315 STOP