Add button to refresh ports DB

This commit is contained in:
Jamie Cameron
2013-03-19 21:54:45 -07:00
parent 9ed262ab34
commit 01217b2ae4
4 changed files with 43 additions and 2 deletions

View File

@@ -523,8 +523,13 @@ 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");
&foreign_require("proc");
foreach my $cmd ("portsnap fetch",
"portsnap update || portsnap extract") {
my ($fh, $pid) = &proc::pty_process_exec($cmd);
while(<$fh>) { }
close($fh);
}
}
}

View File

@@ -399,5 +399,9 @@ ports_ok=.. install complete
ports_input=Package from ports
ports_find=Search Ports
ports_name=FreeBSD ports
ports_form=Update Ports Database
ports_apply=Download Latest Snapshot
ports_upgrade=Downloading Ports Snapshot
ports_running=Running command $1 ..
__norefs=1

View File

@@ -141,4 +141,13 @@ while(my $line = <PKG>) {
return @rv;
}
# update_system_form()
# Show a form for updating the ports DB
sub update_system_form
{
print &ui_subheading($text{'ports_form'});
print &ui_form_start("ports_upgrade.cgi");
print &ui_form_end([ [ undef, $text{'ports_apply'} ] ]);
}
1;

View File

@@ -0,0 +1,23 @@
#!/usr/local/bin/perl
# Update ports snapshot
require './software-lib.pl';
&foreign_require("proc");
&ui_print_unbuffered_header(undef, $text{'ports_upgrade'}, "");
foreach my $cmd ("portsnap fetch",
"portsnap update || portsnap extract") {
print &text('ports_running', "<tt>$cmd</tt>"),"<br>\n";
print "<pre>";
($fh, $pid) = &proc::pty_process_exec($cmd);
while(<$fh>) {
print &html_escape($_);
}
close($fh);
print "</pre>";
last if ($?);
}
&ui_print_footer("", $text{'index_return'});