From 78ffb0796c942f2f6efc21a2a2813feb6e77bedf Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 16 Mar 2013 10:50:53 -0700 Subject: [PATCH] Finished off freebsd ports support --- package-updates/package-updates-lib.pl | 4 ++++ software/CHANGELOG | 2 ++ software/freebsd-lib.pl | 17 ++++++++++------- software/ports-lib.pl | 19 ++++++++++--------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/package-updates/package-updates-lib.pl b/package-updates/package-updates-lib.pl index 8f3bdabe2..1ab7bf377 100644 --- a/package-updates/package-updates-lib.pl +++ b/package-updates/package-updates-lib.pl @@ -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) diff --git a/software/CHANGELOG b/software/CHANGELOG index f13f03c28..6ebc529d3 100644 --- a/software/CHANGELOG +++ b/software/CHANGELOG @@ -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. diff --git a/software/freebsd-lib.pl b/software/freebsd-lib.pl index 40173a800..8ffba0637 100755 --- a/software/freebsd-lib.pl +++ b/software/freebsd-lib.pl @@ -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 = ) { $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() { @@ -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 "
$out
"; } return undef; diff --git a/software/ports-lib.pl b/software/ports-lib.pl index dda33eb82..af23ea23a 100644 --- a/software/ports-lib.pl +++ b/software/ports-lib.pl @@ -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 ) { 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 = ) { s/\r|\n//g;