# Functions for MacOS pkgsrc repository $ENV{'PATH'} .= ":/usr/pkg/bin:/usr/pkg/sbin"; $pkgin_sqlite_db = "/var/db/pkgin/pkgin.db"; $no_package_install = 1; sub list_package_system_commands { return ("pkgin", "sqlite3"); } # execute_pkgin_sql(command) # Returns an array of rows, each of which is a hash ref from column name to # value for that row sub execute_pkgin_sql { my ($sql) = @_; my $errtemp = &transname(); my $cmd = "sqlite3 -header $pkgin_sqlite_db ".quotemeta($sql)." 2>".quotemeta($errtemp); &open_execute_command(SQL, $cmd, 1, 1); my $headline = <SQL>; $headline =~ s/\r|\n//g; my @cols = split(/\|/, $headline); while(my $row = <SQL>) { $row =~ s/\r|\n//g; my @row = split(/\|/, $row); my $r = { }; for(my $i=0; $i<@cols; $i++) { $r->{lc($cols[$i])} = $row[$i]; } push(@rv, $r); } close(SQL); my $ex = $?; my $err = &read_file_contents($errtemp); &unlink_file($errtemp); if ($err || $?) { &error("SQL command $sql failed : ". ($err || $headline || "Unknown error")); } return @rv; } # list_packages([package]*) # Fills the array %packages with all or listed packages sub list_packages { my (@names) = @_; my $sql = "select * from local_pkg"; if (@names) { $sql .= " where pkgname in (".join(", ", map { "'$_'" } @names).")"; } my @out = &execute_pkgin_sql($sql); my $i = 0; my $arch = &backquote_command("uname -m"); $arch =~ s/\r|\n//g; foreach my $r (@out) { $packages{$i,'name'} = $r->{'pkgname'}; $packages{$i,'version'} = $r->{'pkgvers'}; $packages{$i,'desc'} = $r->{'comment'}; $packages{$i,'arch'} = $arch; $packages{$i,'class'} = (split(/\s+/, $r->{'categories'}))[0]; $packages{$i,'size'} = $r->{'size_pkg'}; $i++; } return $i; } # package_info(package, [version]) # Returns an array of package information in the order # name, class, description, arch, version, vendor, installtime sub package_info { my ($name, $ver) = @_; my $n = &list_packages($name); return ( ) if (!$n); return ($packages{0,'name'}, $packages{0,'class'}, $packages{0,'desc'}, $packages{0,'arch'}, $packages{0,'version'}, undef, undef); } # is_package(file) # Always returns 0, because pkgsrc doesn't support installing from files sub is_package { return 0; } # file_packages(file) # Returns nothing, because pkgsrc doesn't support installing from files sub file_packages { return (); } sub package_system { return "PKGsrc"; } # check_files(package, version) # Fills in the %files array with information about the files belonging # to some package. Values in %files are path type user group size error sub check_files { my ($name, $ver) = @_; my @files = &package_files($name, $ver); my %errs; &open_execute_command(CHECK, "pkg_admin check ".quotemeta($name), 1, 1); while(<CHECK>) { if (/^(\/\S+)\s+(.*)/) { $errs{$1} = $2; } } close(CHECK); %files = ( ); for(my $i=0; $i<@files; $i++) { my @st = stat($files[$i]); $files{$i,'path'} = $files[$i]; $files{$i,'type'} = -l $files[$i] ? 3 : -d $files[$i] ? 1 : 0; $files{$i,'user'} = getpwuid($st[4]); $files{$i,'group'} = getgrgid($st[5]); $files{$i,'mode'} = sprintf "%o", $st[2] & 07777; $files{$i,'size'} = $st[7]; $files{$i,'link'} = readlink($files[$i]); $files{$i,'error'} = $errs{$files[$i]}; } return scalar(@files); } # package_files(package, [version]) # Returns a list of all files in some package sub package_files { my ($name, $ver) = @_; &open_execute_command(DUMP, "pkg_admin dump", 1, 1); while(<DUMP>) { if (/file:\s+(\S.*\S)\s+pkg:\s+(\S+)\-/ && $2 eq $name) { push(@rv, $1); } } close(DUMP); return @rv; } # installed_file(file) # Given a filename, fills %file with details of the given file and returns 1. # If the file is not known to the package system, returns 0 # Usable values in %file are path type user group mode size packages sub installed_file { my ($file) = @_; &open_execute_command(DUMP, "pkg_admin dump", 1, 1); while(<DUMP>) { if (/file:\s+(\S.*\S)\s+pkg:\s+(\S+)\-(\S+)/ && $1 eq $file) { push(@pkgs, $2); push(@vers, $3); } } close(DUMP); return 0 if (!@pkgs); %file = ( ); $file{'packages'} = join(' ', @pkgs); $file{'versions'} = join(' ', @vers); $file{'path'} = $file; my @st = stat($file); $file{'type'} = -l $files ? 3 : -d $files ? 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($file); return 1; } # delete_package(package, [&options], version) # Attempt to remove some package sub delete_package { my ($name, $opts, $ver) = @_; my $out = &backquote_logged("pkgin -y remove ".quotemeta($name)." 2>&1"); return $? ? $out : undef; } # delete_packages(&packages, [&options], &versions) # Attempt to remove multiple packages at once sub delete_packages { my ($names, $opts, $vers) = @_; my $out = &backquote_logged("pkgin -y remove ". join(" ", map { quotemeta($name) } @$names)." 2>&1"); return $? ? $out : undef; } ###### Update system functions sub list_update_system_commands { return ("pkgin"); } # update_system_install([package], [&in], [no-force]) # Install some package with apt sub update_system_install { my $update = $_[0] || $in{'update'}; my $in = $_[1]; my $force = !$_[2]; my @rv; # Build and show command to run $update = join(" ", map { quotemeta($_) } split(/\s+/, $update)); my $cmd = "pkgin -y install ".$update; print "<b>",&text('pkgsrc_install', "<tt>$cmd</tt>"),"</b><p>\n"; print "<pre>"; &additional_log('exec', undef, $cmd); # Run it &open_execute_command(CMD, "$cmd", 2); while(<CMD>) { if (/installing\s+(\S+)\-(\d\S*)/i) { # New package push(@rv, $1); } print &html_escape("$_"); } close(CMD); print "</pre>\n"; if ($?) { print "<b>$text{'pkg_failed'}</b><p>\n"; } else { print "<b>$text{'pkg_ok'}</b><p>\n"; } return @rv; } # update_system_search(text) # Returns a list of packages matching some search sub update_system_search { my ($text) = @_; $text =~ s/\.\*/%/g; $text =~ s/\./?/g; my $sql = "select * from remote_pkg"; if ($text) { $sql .= " where pkgname like '%$text%' or ". "comment like '%$text%'"; } my @out = &execute_pkgin_sql($sql); my @rv; foreach my $r (@out) { push(@rv, { 'name' => $r->{'pkgname'}, 'version' => $r->{'pkgvers'}, 'desc' => $r->{'comment'} }); } return @rv; } # update_system_available() # Returns a list of package names and versions that are available from PKGSRC sub update_system_available { return &update_system_search(undef); } # update_system_updates() # Returns a list of available package updates sub update_system_updates { my $sql = "select remote_pkg.pkgname,remote_pkg.pkgvers ". "from remote_pkg,local_pkg ". "where remote_pkg.pkgname = local_pkg.pkgname ". "and remote_pkg.pkgvers != local_pkg.pkgvers"; my @out = &execute_pkgin_sql($sql); my @rv; foreach my $r (@out) { push(@rv, { 'name' => $r->{'pkgname'}, 'version' => $r->{'pkgvers'}, 'desc' => $r->{'comment'} }); } return @rv; } # update_system_resolve(name) # Converts a standard package name like apache, sendmail or squid into # the name used by ports. sub update_system_resolve { local ($name) = @_; return $name eq "apache" ? "apache ap24-.*" : $name eq "dhcpd" ? "isc-dhcpd" : $name eq "mysql" ? "mysql-server mysql-client" : $name eq "postgresql" ? "postgresql94-client postgresql94-server" : $name eq "openldap" ? "openldap-server openldap-client" : $name; } 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 2.82 KB | 0644 |
|
aix-lib.pl | File | 19.2 KB | 0755 |
|
apt-lib.pl | File | 14.09 KB | 0755 |
|
apt_upgrade.cgi | File | 1.97 KB | 0755 |
|
cgi_args.pl | File | 524 B | 0755 |
|
close.cgi | File | 263 B | 0755 |
|
config-aix | File | 30 B | 0644 |
|
config-cobalt-linux | File | 30 B | 0644 |
|
config-coherent-linux | File | 30 B | 0644 |
|
config-corel-linux | File | 33 B | 0644 |
|
config-cygwin | File | 33 B | 0644 |
|
config-debian-linux | File | 51 B | 0644 |
|
config-freebsd | File | 54 B | 0644 |
|
config-freebsd-8.4-ALL | File | 52 B | 0644 |
|
config-gentoo-linux | File | 33 B | 0644 |
|
config-hpux | File | 31 B | 0644 |
|
config-mandrake-linux | File | 30 B | 0644 |
|
config-msc-linux | File | 30 B | 0644 |
|
config-netbsd | File | 34 B | 0644 |
|
config-open-linux | File | 30 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 30 B | 0644 |
|
config-openbsd | File | 34 B | 0644 |
|
config-openmamba-linux | File | 48 B | 0644 |
|
config-openserver | File | 33 B | 0644 |
|
config-redhat-linux | File | 48 B | 0644 |
|
config-slackware-linux | File | 36 B | 0644 |
|
config-solaris | File | 33 B | 0644 |
|
config-suse-linux | File | 30 B | 0644 |
|
config-syno-linux | File | 50 B | 0644 |
|
config-trustix-linux | File | 30 B | 0644 |
|
config-turbo-linux | File | 30 B | 0644 |
|
config-united-linux | File | 30 B | 0644 |
|
config-unixware | File | 33 B | 0644 |
|
config-windows | File | 30 B | 0644 |
|
config.info | File | 511 B | 0644 |
|
config.info.ca | File | 554 B | 0644 |
|
config.info.cs | File | 372 B | 0644 |
|
config.info.de | File | 523 B | 0644 |
|
config.info.es | File | 320 B | 0644 |
|
config.info.fr | File | 135 B | 0644 |
|
config.info.ja | File | 428 B | 0644 |
|
config.info.ko | File | 409 B | 0644 |
|
config.info.ms | File | 411 B | 0644 |
|
config.info.nl | File | 415 B | 0644 |
|
config.info.no | File | 424 B | 0644 |
|
config.info.pl | File | 392 B | 0644 |
|
config.info.ru | File | 175 B | 0644 |
|
config.info.sv | File | 224 B | 0644 |
|
config.info.tr | File | 123 B | 0644 |
|
config.info.uk | File | 174 B | 0644 |
|
config.info.zh | File | 122 B | 0644 |
|
config.info.zh_TW | File | 125 B | 0644 |
|
csw-lib.pl | File | 2.69 KB | 0755 |
|
cygwin-lib.pl | File | 22.34 KB | 0755 |
|
debian-lib.pl | File | 6.67 KB | 0755 |
|
delete_file.cgi | File | 239 B | 0755 |
|
delete_pack.cgi | File | 1.46 KB | 0755 |
|
delete_packs.cgi | File | 1.85 KB | 0755 |
|
do_install.cgi | File | 2.67 KB | 0755 |
|
edit_pack.cgi | File | 1.13 KB | 0755 |
|
emerge-lib.pl | File | 7.65 KB | 0755 |
|
file_info.cgi | File | 2.09 KB | 0755 |
|
find.cgi | File | 1.63 KB | 0755 |
|
freebsd-lib.pl | File | 7.95 KB | 0755 |
|
hpux-lib.pl | File | 8.01 KB | 0755 |
|
index.cgi | File | 3 KB | 0755 |
|
install_pack.cgi | File | 4.71 KB | 0755 |
|
ipkg-close.cgi | File | 269 B | 0755 |
|
ipkg-edit_pack.cgi | File | 1.45 KB | 0755 |
|
ipkg-lib.pl | File | 7.78 KB | 0755 |
|
ipkg-open.cgi | File | 243 B | 0755 |
|
ipkg-tree.cgi | File | 4 KB | 0755 |
|
ipkg_upgrade.cgi | File | 926 B | 0755 |
|
list_pack.cgi | File | 1.85 KB | 0755 |
|
log_parser.pl | File | 1.34 KB | 0755 |
|
module.info | File | 484 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 127 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 170 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 216 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 214 B | 0644 |
|
module.info.ca | File | 116 B | 0644 |
|
module.info.ca.auto | File | 21 B | 0644 |
|
module.info.cs | File | 30 B | 0644 |
|
module.info.cs.auto | File | 114 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 124 B | 0644 |
|
module.info.de | File | 106 B | 0644 |
|
module.info.de.auto | File | 21 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 220 B | 0644 |
|
module.info.es | File | 29 B | 0644 |
|
module.info.es.auto | File | 106 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 129 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 215 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 130 B | 0644 |
|
module.info.fr | File | 29 B | 0644 |
|
module.info.fr.auto | File | 117 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 152 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 138 B | 0644 |
|
module.info.hu | File | 38 B | 0644 |
|
module.info.hu.auto | File | 108 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 134 B | 0644 |
|
module.info.ja | File | 43 B | 0644 |
|
module.info.ja.auto | File | 157 B | 0644 |
|
module.info.ko | File | 34 B | 0644 |
|
module.info.ko.auto | File | 128 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 162 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 151 B | 0644 |
|
module.info.ms | File | 104 B | 0644 |
|
module.info.ms.auto | File | 18 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 150 B | 0644 |
|
module.info.nl | File | 27 B | 0644 |
|
module.info.nl.auto | File | 104 B | 0644 |
|
module.info.no | File | 26 B | 0644 |
|
module.info.no.auto | File | 107 B | 0644 |
|
module.info.pl | File | 121 B | 0644 |
|
module.info.pl.auto | File | 21 B | 0644 |
|
module.info.pt | File | 28 B | 0644 |
|
module.info.pt.auto | File | 102 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 139 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 134 B | 0644 |
|
module.info.ru | File | 30 B | 0644 |
|
module.info.ru.auto | File | 205 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 145 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 132 B | 0644 |
|
module.info.sv | File | 21 B | 0644 |
|
module.info.sv.auto | File | 100 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 253 B | 0644 |
|
module.info.tr | File | 28 B | 0644 |
|
module.info.tr.auto | File | 107 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 202 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 208 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 144 B | 0644 |
|
module.info.zh | File | 18 B | 0644 |
|
module.info.zh.auto | File | 91 B | 0644 |
|
module.info.zh_TW | File | 24 B | 0644 |
|
module.info.zh_TW.auto | File | 97 B | 0644 |
|
msi-lib.pl | File | 8.45 KB | 0755 |
|
open.cgi | File | 238 B | 0755 |
|
openbsd-lib.pl | File | 4.72 KB | 0755 |
|
pkg-lib.pl | File | 2.5 KB | 0644 |
|
pkgadd-lib.pl | File | 9.97 KB | 0755 |
|
pkgadd-no-ask | File | 164 B | 0644 |
|
pkgsrc-lib.pl | File | 7.24 KB | 0644 |
|
ports-lib.pl | File | 3.49 KB | 0644 |
|
ports_upgrade.cgi | File | 501 B | 0755 |
|
rhn-lib.pl | File | 3.02 KB | 0755 |
|
rhn.cgi | File | 1.3 KB | 0755 |
|
rhn_check.cgi | File | 1.84 KB | 0755 |
|
rpm-lib.pl | File | 11.24 KB | 0755 |
|
rpmfind.cgi | File | 2.11 KB | 0755 |
|
search.cgi | File | 2.27 KB | 0755 |
|
slackware-lib.pl | File | 6.95 KB | 0755 |
|
software-lib.pl | File | 7.57 KB | 0755 |
|
tree.cgi | File | 3.79 KB | 0755 |
|
urpmi-lib.pl | File | 2.14 KB | 0755 |
|
urpmi_upgrade.cgi | File | 839 B | 0755 |
|
view.cgi | File | 931 B | 0755 |
|
yum-lib.pl | File | 13.06 KB | 0755 |
|
yum_upgrade.cgi | File | 908 B | 0755 |
|