Software-Packager-Rpm
view release on metacpan or search on metacpan
lib/Software/Packager/Rpm.pm view on Meta::CPAN
print SPEC "Release:" . $self->release() . "\n";
print SPEC "Copyright:" . $self->copyright() . "\n";
print SPEC "Group:" . $self->category() . "\n";
print SPEC "Source:" . $self->source() . "\n";
print SPEC "URL:" . $self->homepage() . "\n";
print SPEC "Vendor:" . $self->vendor() . "\n";
print SPEC "Packager:" . $self->creator() . "\n";
print SPEC "BuildRoot:$tmp_dir\n";
print SPEC "Prefix:". $self->install_dir() . "\n" if $self->install_dir();
print SPEC "\n";
print SPEC "\%description\n" . $self->description() . "\n\n";
# now copy everything to the tmp directory
#print SPEC "\%prep\n\n";
#print SPEC "\%build\n\n";
#print SPEC "\%install\n\n";
foreach my $object ($self->get_directory_objects())
{
my $directory = "$tmp_dir/" . $object->destination();
mkpath($directory, 0, 0755);
}
foreach my $object ($self->get_file_objects())
{
my $source = $object->source();
my $destination = "$tmp_dir/" . $object->destination();
my $dir = dirname($destination);
unless (-d $dir)
{
mkpath($dir, 0, 0755) or
warn "Error: Problems were encountered creating directory \"$dir\": $!\n";
}
copy($source, $destination);
}
foreach my $object ($self->get_link_objects())
{
my $source = $object->source();
my $destination = "$tmp_dir/" . $object->destination();
my $type = $object->type();
if ($type =~ /hard/i)
{
eval link "$source", "$destination";
warn "Warning: Hard links not supported on this operatiing system: $@\n" if $@;
}
elsif ($type =~ /soft/i)
{
eval symlink "$source", "$destination";
warn "Warning: Soft links not supported on this operatiing system: $@\n" if $@;
}
else
{
warn "Error: Not sure what type of link to create soft or hard.";
}
}
# here is where we specify all the installable objects
print SPEC "\%files\n";
foreach my $object ($self->get_directory_objects(), $self->get_file_objects(), $self->get_link_objects())
{
my $destination = $object->destination();
my $user = getpwuid($object->user());
my $group = getgrgid($object->group());
my $mode = $object->mode();
print SPEC "\%attr($mode, $user, $group)";
print SPEC " \%" . $object->kind() if $object->kind();
print SPEC " /$destination\n"
}
close SPEC;
return 1;
}
################################################################################
# Function: _build_package
# Description: This method builds the package and moves it to the output
# directory.
# Arguments: None.
# Returns: True on success else undef
#
sub _build_package
{
my $self = shift;
my $tmp_dir = $self->tmp_dir();
# build the package
unless (system("rpm -bb --rcfile $tmp_dir/rpmrc $tmp_dir/SPECS/package.spec") == 0)
{
warn "Error: There were problems creating the package.\n";
}
# move the pacakge to the output directory
my $package = "$tmp_dir/RPMS/" . $self->architecture();
$package .= "/" . $self->package_name();
my $output_dir = $self->output_dir();
unless (move($package, $output_dir))
{
warn "Error: Couldn't move \"$package\" to \"$output_dir\"\n";
}
return 1;
}
################################################################################
# Function: _cleanup
# Description: This method cleans up the temp directory
# Arguments: None.
# Returns: True on success else undef
#
sub _cleanup
{
my $self = shift;
my $tmp_dir = $self->tmp_dir();
unless (system("chmod -R 0777 $tmp_dir") == 0)
{
warn "Warning: Couldn't change the permissions on $tmp_dir: $!\n";
}
return undef unless rmtree($tmp_dir, 0, 0);
return 1;
( run in 2.066 seconds using v1.01-cache-2.11-cpan-13bb782fe5a )