) {
next if ($file =~ /^Package /);
$file =~ s/\r|\n//g;
if ($file eq $_[0]) {
# found it
push(@pkgin, $packages{$i,'name'});
}
}
close(PKGINFO);
}
if (@pkgin) {
local $real = &translate_filename($_[0]);
local @st = stat($real);
$file{'path'} = $_[0];
$file{'type'} = -l $real ? 3 :
-d $real ? 1 : 0;
$file{'user'} = getpwuid($st[4]);
$file{'group'} = getgrgid($st[5]);
$file{'mode'} = sprintf "%o", $st[2] & 07777;
$file{'size'} = $st[7];
$file{'link'} = readlink($real);
$file{'packages'} = join(" ", @pkgin);
return 1;
}
else {
return 0;
}
}
# install_package(file, package)
# Installs the package in the given file, with options from %in
sub install_package
{
local $out = &backquote_logged("$ipkg install $_[1] 2>&1");
if ($?) {
return "$out
";
}
return undef;
}
# delete_package(package)
# Totally remove some package
sub delete_package
{
local $out = &backquote_logged("$ipkg remove $_[0] 2>&1");
if ($?) { return "$out
"; }
return undef;
}
sub package_system
{
return &text('bsd_manager', "SYNOLOGY");
}
sub package_help
{
return $ipkg;
}
sub list_update_system_commands
{
return $ipkg;
}
# update_system_install([package])
# Install some package with IPKG
sub update_system_install
{
local $update = $_[0] || $in{'update'};
local (@rv, @newpacks);
local $cmd = "$ipkg install";
print &text('IPKG_install', "$cmd"),"\n";
print "";
&additional_log('exec', undef, "$cmd $update");
local $qm = join(" ", map { quotemeta($_) } split(/\s+/, $update));
&open_execute_command(CMD, "$cmd $qm", 2);
while() {
s/\r|\n//g;
if (/Installing\s+(\S+)\s+/) {
# Found a package
local $pkg = $1;
$pkg =~ s/\-\d.*//; # remove version
push(@rv, $pkg);
}
print &html_escape($_."\n");
}
close(CMD);
print "\n";
if ($?) {
print "$text{'IPKG_failed'}\n";
return ( );
}
else {
print "$text{'IPKG_ok'}
\n";
return &unique(@rv);
}
}
# update_system_form()
# Shows a form for updating all packages on the system
sub update_system_form
{
print &ui_subheading($text{'IPKG_form'});
print &ui_buttons_start();
print &ui_form_start("ipkg_upgrade.cgi");
print &ui_submit($text{'IPKG_update'}, "update"),"
\n";
print &ui_submit($text{'IPKG_upgrade'}, "upgrade");
print &ui_form_end(), "
";
print &ui_form_start("ipkg-tree.cgi");
print &ui_submit($text{'IPKG_index_tree'});
print &ui_form_end();
print &ui_buttons_end();
}
# update_system_resolve(name)
# Converts a standard package name like apache, sendmail or squid into
# the name used by YUM.
sub update_system_resolve
{
local ($name) = @_;
return $name eq "dhcpd" ? "dhcp-server" :
$name eq "mysql" ? "mariadb" :
$name eq "openldap" ? "openldap openldap-servers" :
$name eq "postgresql" ? "postgresql postgresql-server" :
$name eq "samba" ? "samba-client samba-server" :
$name;
}
# update_system_available()
# Returns a list of package names and versions that are available from IPKG
# including updated versions
sub update_system_available
{
local @rv;
&open_execute_command(PKGINFO, "$ipkg list-upgradable", 1, 1);
while() {
s/\r|\n//g;
if (/^\s*(.+?) - (.+?) - (.+)/) {
local $pkg = { 'name' => $1,
'version' => $3 };
push(@rv, $pkg);
}
}
close(PKG);
return @rv;
}
|