#!/usr/bin/env perl use warnings; use strict; use utf8; =encoding utf8 =head1 SYNOPSIS getsrpmdeps BINARY_REPO_ID < LOCAL_SRPM_FILES getsrpmdeps BINARY_REPO_ID FILE_LISTING_LOCAL_SRPM_FILES =head1 DESCRIPTION Resolve local SRPM files dependencies against YUM repository with binary packages specified by BINARY_REPO_ID. The list of local SRPM files is read from standard input or from file given with second argument. The list is separated by new lines. Only direct dependencies are computed. It considers C dependencies only. It prints dependency list for each package from the dependency tree: SOURCE_PACKAGE_NAME SOURCE_PACKAGE_NAME_PROVIDING_THE_DEPENDENCY... ... Unresolvable depenencies are prefixed with an exclamation mark and their value is sanitized. SOURCE_PACKAGE_NAME !UNRESOLVABLE_DEPENDENCY =cut my $repo_id = shift @ARGV; if (!defined $repo_id) { die "Bad usage. See POD.\n"; } use YUM::Deps; # Due to bug in IPC::Run3::run3(), we cannot use STDIN after calling it. # my @srpm_files = (); while (<>) { chomp; if (!/\A\s*(\S+)*/) { next; } push @srpm_files, $1; } for my $srpm_file (@srpm_files) { my $subject = YUM::Deps::rpmfile2basename($srpm_file); my %dependencies; for my $requirement (grep /^perl\(/, YUM::Deps::rpmfile2requires($srpm_file)) { my @providers = YUM::Deps::provides2basenames($repo_id, $requirement); map { $dependencies{$_} = undef; } @providers; if (!@providers) { warn "Unsatisfied `$srpm_file' dependency on `$requirement'\n"; $requirement =~ s/[\s'"]/_/g; $dependencies{"!$requirement"} = undef; } } print $subject, ' ', join(' ', sort keys %dependencies), "\n"; }