Finished off freebsd ports support

This commit is contained in:
Jamie Cameron
2013-03-16 10:50:53 -07:00
parent 06931d4a40
commit 78ffb0796c
4 changed files with 26 additions and 16 deletions

View File

@@ -522,6 +522,10 @@ if ($software::update_system eq "yum") {
elsif ($software::update_system eq "apt") {
&execute_command("apt-get update");
}
elsif ($software::update_system eq "ports") {
&execute_command("portsnap fetch");
&execute_command("portsnap update || portsnap extract");
}
}
# split_epoch(version)

View File

@@ -35,3 +35,5 @@ Fixed several bugs related to YUM available package updates.
Added the update_system_updates function to more efficiently find available packages for YUM and APT.
---- Changes since 1.530 ----
Debian packages marked as "hold" are no longer offered as possible updates. This is visible in the Software Package Updates module.
---- Changes since 1.620 ----
Added support for updating and installing packages from FreeBSD ports.

View File

@@ -31,19 +31,20 @@ close(PKGINFO);
return $i;
}
# package_info(package, version)
# package_info(package, [version])
# Returns an array of package information in the order
# name, class, description, arch, version, vendor, installtime
sub package_info
{
local $qm = quotemeta($_[0].'='.$_[1]);
local ($name, $ver) = @_;
local $qm = quotemeta($name.($ver ? '='.$ver : '>=0'));
local $out = &backquote_command("pkg_info $qm 2>&1", 1);
return () if ($?);
local @rv = ( $_[0] );
local @rv = ( $name );
push(@rv, "");
push(@rv, $out =~ /Description:\n([\0-\177]*\S)/i ? $1 : $text{'bsd_unknown'});
push(@rv, $system_arch);
push(@rv, $_[1]);
push(@rv, $out =~ /Information\s+for\s+(\S+)\-(\d\S+)/ ? $2 : $ver);
push(@rv, "FreeBSD");
local @st = stat(&translate_filename("$package_dir/$_[0]"));
push(@rv, @st ? ctime($st[9]) : $text{'bsd_unknown'});
@@ -55,9 +56,10 @@ return @rv;
# to some package. Values in %files are path type user group mode size error
sub check_files
{
local ($name, $ver) = @_;
local $i = 0;
local $file;
local $qm = quotemeta($_[0].'='.$_[1]);
local $qm = quotemeta($name.($ver ? '='.$ver : '>=0'));
&open_execute_command(PKGINFO, "pkg_info -L $qm", 1, 1);
while($file = <PKGINFO>) {
$file =~ s/\r|\n//g;
@@ -82,7 +84,7 @@ return $i;
sub package_files
{
local ($pkg, $v) = @_;
local $qn = quotemeta($pkg.'='.$v);
local $qn = quotemeta($pkg.($v ? '='.$v : '>=0'));
local @rv;
&open_execute_command(RPM, "pkg_info -L $qn", 1, 1);
while(<RPM>) {
@@ -276,7 +278,8 @@ return undef;
# Totally remove some package
sub delete_package
{
local $qm = quotemeta($_[0].'='.$_[2]);
local ($name, $ver) = @_;
local $qm = quotemeta($name.($ver ? '='.$ver : '>=0'));
local $out = &backquote_logged("pkg_delete $qm 2>&1");
if ($?) { return "<pre>$out</pre>"; }
return undef;

View File

@@ -1,9 +1,5 @@
# Functions for FreeBSD ports / package management
#
# XXX uninstall package doesn't un-install port
# XXX check with software package updates module
# XXX need make fetchindex to update DB?
# XXX CHANGELOG
sub list_update_system_commands
{
@@ -32,8 +28,13 @@ foreach my $w (@want) {
}
my $dir = "/usr/ports/".$pkg->{'fullname'};
# Check if already installed
my @info = &package_info($pkg->{'name'});
my $upgrade = scalar(@info) ? 1 : 0;
# Build the packages
my $cmd = "cd $dir && make reinstall";
my $cmd = $upgrade ? "cd $dir && make reinstall"
: "cd $dir && make install";
print $cmd,"\n";
&additional_log('exec', undef, $cmd);
$ENV{'BATCH'} = 1;
@@ -41,8 +42,8 @@ foreach my $w (@want) {
&open_execute_command(CMD, "$cmd </dev/null", 2);
while(<CMD>) {
s/\r|\n//g;
if (/Building\s+package\s+(\S+)/) {
push(@newrv, $2);
if (/Registering\s+installation\s+for\s+(\S+)\-(\d\S+)/) {
push(@newrv, $1);
}
print &html_escape($_."\n");
}
@@ -111,7 +112,7 @@ sub update_system_available
{
local @rv;
&execute_command("cd /usr/ports && make fetchindex");
&open_execute_command(PKG, "cd /usr/ports && make search 'key=*'", 2, 1);
&open_execute_command(PKG, "cd /usr/ports && make search 'key=.*'", 2, 1);
my @rv;
while(my $line = <PKG>) {
s/\r|\n//g;