NAME
Repo::RPM - perl module to create RPMs requires tree
DESCRIPTION
This module allow to create sqlite3 database from bunch of RPMs or SRPMs and build requires tree, the list of RPMs names in installation order, and RPMs requires in the GNU Make format.
FUNCTIONS
read_repository( $url, $mirror )
Read RPMs are placed in $mirror local directory. The $url is a reference link to URL of RPMs downloaded into $mirror directory, for example, "https://download.opensuse.org/source/distribution/leap/15.2/repo/oss/src/".
Example:
use Repo;
use Repo::RPM;
my $version = "15.2";
my $mirror = /home/user . "/" . "openSUSE-Leap-" . $version ."-src";
my %repo = Repo::RPM::read_repository( $url, $mirror );
write_database( ".repo.db", \%repo );
Create and fill Sqlite3 database named $mirror . ".repo.db".
Example:
my $ret = Repo::RPM::write_database( ".repo.db", \%repo );
if( ! $ret )
{
print "write DB error\n";
}
build_requires( \%repo, \%requires, "", \@list );
Create RPMs requires in the GNU Make format using RPMs names list.
Example:
my $srpms_list = /home/user . "/input-srpm-names.list";
my (%requires, %reqs);
%requires = ();
#
# Get requires of packages from $srpms_list (where we have package names only):
#
my @list = ();
my @rqlist = ();
my (%pkg, $pkgname);
#
# read LIST from file:
#
open( my $fh, "<", $srpms_list )
or die "Failed to open file: $!\n";
while( <$fh> )
{
chomp;
push @rqlist, $_;
}
close $fh;
foreach $pkgname ( @rqlist )
{
%pkg = Repo::RPM::find_package( \%repo, $pkgname );
if( %pkg )
{
push @list, $pkgname;
}
else
{
print " package: '" . $pkgname . "': not found\n";
}
}
@list = uniq( @list );
#
# NOTE: build_requires() find packages with MAX version.
#
%reqs = Repo::RPM::build_requires( \%repo, \%requires, "", \@list );
#
# Print dependencies in GNU Make style:
#
Repo::RPM::print_requires( \%requires, "requires-tree.make-deps" );
build_install_sequence( \%reqs )
Create the list of RPMs names in the build or installation order according to RPMs dependencies.
Example:
my %sequence = Repo::RPM::build_install_sequence( \%reqs );
#
# Print packages in the installation/build order:
#
Repo::RPM::print_install_sequence( \%sequence, "requires-tree.build-sequence" );
#
# Print RPMs in the installation/build order:
#
Repo::RPM::print_used_rpms( \%repo, \%sequence, "requires-tree.used-rpms" );
build_requires_tree( \%repo, \%reqs );
This function builds the requires tree in the HTML format. When the requires tree is creates the target HTML and JSON files can be printed out using print_json_tree() and print_html_tree() functions:
Example:
my %tree = Repo::RPM::build_requires_tree( \%repo, \%reqs );
if( %tree )
{
my ($w, $h) = Repo::RPM::print_json_tree( \%repo, \%tree, "requires-tree.json" );
if( ! $w )
{
print "write json Error!\n";
}
else
{
my $ret = Repo::RPM::print_html_tree( \%repo, \%tree, $w, $h, "My Custom Distro (oss base)", "https://example.com", "requires-tree.json", "requires-tree.html" );
if( $ret )
{
print "===== Created Requires Thee file: " . "'requires-tree.html'" . "\n";
}
}
}
SEE ALSO
and RPM4::rpmvercmp(version1, version2) function used to compare RPMs versions.