# rpm-lib.pl # Functions for redhat linux package management sub list_package_system_commands { return ("rpm"); } # list_packages([package]*) # Fills the array %packages with all or listed packages sub list_packages { local($i, $list); $i = 0; $list = @_ ? join(' ', map { quotemeta($_) } @_) : "-a"; %packages = ( ); &open_execute_command(RPM, "rpm -q $list --queryformat \"%{NAME}\\n%{VERSION}-%{RELEASE}\\n%{EPOCH}\\n%{GROUP}\\n%{ARCH}\\n%{SUMMARY}\\n\\n\"", 1, 1); while(my $name = <RPM>) { next if ($name =~ /is\s+not\s+installed$/); $packages{$i,'name'} = $name; chop($packages{$i,'name'}); chop($packages{$i,'version'} = <RPM>); chop($packages{$i,'epoch'} = <RPM>); $packages{$i,'epoch'} = undef if ($packages{$i,'epoch'} eq '(none)'); chop($packages{$i,'class'} = <RPM>); chop($packages{$i,'arch'} = <RPM>); while(<RPM>) { s/\r|\n/ /g; last if (!/\S/); $packages{$i,'desc'} .= $_; } if ($packages{$i,'name'} eq 'gpg-pubkey') { # Bogus pseudo-package we don't want to include $packages{$i,'desc'} = undef; $i--; } $i++; } close(RPM); return 0 if ($?); # couldn't find the package 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 { local(@rv, @tmp, $d); local $n = $_[1] ? "$_[0]-$_[1]" : $_[0]; &open_execute_command(RPM, "rpm -q $n --queryformat \"%{NAME}\\n%{GROUP}\\n%{ARCH}\\n%{VERSION}-%{RELEASE}\\n%{VENDOR}\\n%{INSTALLTIME}\\n\" 2>/dev/null", 1, 1); @tmp = <RPM>; chop(@tmp); local $ex = close(RPM); if (!@tmp || $tmp[0] =~ /not\s+installed/) { return (); } &open_execute_command(RPM, "rpm -q $n --queryformat \"%{DESCRIPTION}\"", 1, 1); while(<RPM>) { $d .= $_; } close(RPM); return ($tmp[0], $tmp[1], $d, $tmp[2], $tmp[3], $tmp[4], &make_date($tmp[5])); } # is_package(file) # Check if some file is a package file sub is_package { local($out); local $real = &translate_filename($_[0]); if (-d $real) { # a directory .. see if it contains any .rpm files opendir(DIR, $real); local @list = grep { /\.rpm$/ } readdir(DIR); closedir(DIR); return @list ? 1 : 0; } elsif ($real =~ /\*|\?/) { # a wildcard .. see what it matches local @list = glob($real); return @list ? 1 : 0; } else { # just a normal file .. check if it is an RPM and not an SRPM local $qm = quotemeta($_[0]); $out = &backquote_command("rpm -q -p $qm 2>&1", 1); if ($out =~ /does not appear|No such file|with major numbers|not an rpm/i || $?) { return 0; } &open_execute_command(OUT, "rpm -q -p -l $qm 2>&1", 1, 1); while(<OUT>) { return 0 if (/^([^\/\s]+)\.spec$/); } close(OUT); return 1; } } # file_packages(file) # Returns a list of all packages in the given file, in the form # package-version description sub file_packages { local $real = &translate_filename($_[0]); local $qm = quotemeta($_[0]); if (-d $real) { local @rv; &open_execute_command(RPM, "cd $qm ; rpm -q -p *.rpm --queryformat \"%{NAME} %{SUMMARY}\\n\" 2>&1", 1, 1); while(<RPM>) { chop; push(@rv, $_) if (!/does not appear|query of.*failed|warning:/); } close(RPM); return @rv; } elsif ($_[0] =~ /\*|\?/) { local @rv; &open_execute_command(RPM, "rpm -q -p $qm --queryformat \"%{NAME} %{SUMMARY}\\n\" 2>&1", 1); while(<RPM>) { chop; push(@rv, $_) if (!/does not appear|query of.*failed|warning:/); } close(RPM); return @rv; } else { local($out); $out = &backquote_command("rpm -q -p $qm --queryformat \"%{NAME} %{SUMMARY}\\n\" 2>&1", 1); $out =~ s/warning:.*\n//; $out =~ s/\n//g; return ($out); } } # install_options(file, package) # Outputs HTML for choosing install options for some package sub install_options { print &yesno_input($text{'rpm_upgrade'}, "upgrade", 1, 0, 1); print &yesno_input($text{'rpm_replacepkgs'}, "replacepkgs", 1, 0); print &yesno_input($text{'rpm_nodeps'}, "nodeps", 1, 0); print &yesno_input($text{'rpm_oldpackage'}, "oldpackage", 1, 0); print &yesno_input($text{'rpm_noscripts'}, "noscripts", 0, 1); print &yesno_input($text{'rpm_excludedocs'}, "excludedocs", 0, 1); print &yesno_input($text{'rpm_notriggers'}, "notriggers", 0, 1); print &yesno_input($text{'rpm_ignoresize'}, "ignoresize", 0, 1); print &yesno_input($text{'rpm_replacefiles'}, "replacefiles", 1, 0); print &ui_table_row(&hlink($text{'rpm_root'}, "root"), &ui_textbox("root", "/", 50)." ". &file_chooser_button("root", 1), 3); } sub yesno_input { return &ui_table_row(&hlink($_[0], $_[1]), &ui_radio($_[1], int($_[4]), [ [ $_[2], $text{'yes'} ], [ $_[3], $text{'no'} ] ])); } # install_package(file, package, [&inputs]) # Install the given package from the given file, using options from %in sub install_package { local $file = $_[0]; local $real = &translate_filename($file); local $in = $_[2] ? $_[2] : \%in; local $opts; foreach $o ('oldpackage', 'replacefiles', 'replacepkgs', 'noscripts', 'excludedocs', 'nodeps', 'upgrade', 'notriggers', 'ignoresize') { if ($in->{$o}) { $opts .= " --$o"; } } if ($in->{'root'} =~ /^\/.+/) { if (!(-d $in{'root'})) { return &text('rpm_eroot', $in->{'root'}); } $opts .= " --root $in->{'root'}"; } if (-d $real) { # Find the package in the directory local ($f, $out); opendir(DIR, $real); while($f = readdir(DIR)) { next if ($f !~ /\.rpm$/); $out = &backquote_command("rpm -q -p $file/$f --queryformat \"%{NAME}\\n\" 2>&1", 1); $out =~ s/warning:.*\n//; $out =~ s/\n//; if ($out eq $_[1]) { $file = "$file/$f"; last; } } closedir(DIR); &error(&text('rpm_erpm', $_[1], $out)) if ($file eq $_[0]); } elsif ($file =~ /\*|\?/) { # Find the package in the glob # XXX won't work when translation is in effect local ($f, $out); foreach $f (glob($real)) { $out = &backquote_command("rpm -q -p $f --queryformat \"%{NAME}\\n\" 2>&1", 1); $out =~ s/warning:.*\n//; $out =~ s/\n//; if ($out eq $_[1]) { $file = $f; last; } } &error(&text('rpm_erpm', $_[1], $out)) if ($file eq $_[0]); } local $temp = &transname(); local $rv = &system_logged("rpm -i $opts ".quotemeta($file)." >$temp 2>&1"); local $out = &backquote_command("cat $temp"); $out =~ s/warning:.*\n//; &unlink_file($temp); if ($rv) { return "<pre>$out</pre>"; } return undef; } # install_packages(file, [&inputs]) # Installs all the packages in the given file or glob sub install_packages { local $file = $_[0]; local $in = $_[1] ? $_[1] : \%in; local $opts; foreach $o ('oldpackage', 'replacefiles', 'replacepkgs', 'noscripts', 'excludedocs', 'nodeps', 'upgrade', 'notriggers', 'ignoresize') { if ($in->{$o}) { $opts .= " --$o"; } } if ($in->{'root'} =~ /^\/.+/) { if (!(-d $in{'root'})) { return &text('rpm_eroot', $in->{'root'}); } $opts .= " --root $in->{'root'}"; } if (-d &translate_filename($file)) { # Install everything in a directory $file = "$file/*.rpm"; } else { # Install packages matching a glob (no need for any special action) } local $temp = &transname(); local $rv = &system_logged("rpm -i $opts $file >$temp 2>&1"); local $out = &backquote_command("cat $temp"); $out =~ s/warning:.*\n//; unlink($temp); if ($rv) { return "<pre>$out</pre>"; } return undef; } # 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 { local($i, $_, @w, %errs, $epath); $i = 0; local $n = $_[1] ? "$_[0]-$_[1]" : $_[0]; local $qn = quotemeta($n); &open_execute_command(RPM, "rpm -V $qn", 1, 1); while(<RPM>) { /^(.{8}) (.) (.*)$/; if ($1 eq "missing ") { $errs{$3} = $text{'rpm_missing'}; } else { $epath = $3; @w = grep { $_ ne "." } split(//, $1); $errs{$epath} = join("\n", map { &text('rpm_checkfail', $etype{$_}) } @w); } } close(RPM); &open_execute_command(RPM, "rpm -q $qn -l --dump", 1, 1); while(<RPM>) { chop; @w = split(/ /); $files{$i,'path'} = $w[0]; if ($w[10] ne "X") { $files{$i,'link'} = $w[10]; } $files{$i,'type'} = $w[10] ne "X" ? 3 : (-d &translate_filename($w[0])) ? 1 : $w[7] ? 5 : 0; $files{$i,'user'} = $w[5]; $files{$i,'group'} = $w[6]; $files{$i,'size'} = $w[1]; $files{$i,'error'} = $w[7] ? "" : $errs{$w[0]}; $i++; } close(RPM); return $i; } # package_files(package, [version]) # Returns a list of all files in some package sub package_files { local ($pkg, $version) = @_; local $qn = quotemeta($version ? "$pkg-$version" : $pkg); local @rv; &open_execute_command(RPM, "rpm -q -l $qn", 1, 1); while(<RPM>) { s/\r|\n//g; push(@rv, $_); } close(RPM); 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 { local($pkg, @w, $_, @pkgs, @vers); undef(%file); local $qm = quotemeta($_[0]); $pkg = &backquote_command("rpm -q -f $qm --queryformat \"%{NAME}\\n\" 2>&1", 1); if ($pkg =~ /not owned/ || $?) { return 0; } @pkgs = split(/\n/, $pkg); $pkg = &backquote_command("rpm -q -f $qm --queryformat \"%{VERSION}-%{RELEASE}\\n\" 2>&1", 1); @vers = split(/\n/, $pkg); &open_execute_command(RPM, "rpm -q $pkgs[0] -l --dump", 1, 1); while(<RPM>) { chop; @w = split(/ /); if ($w[0] eq $_[0]) { $file{'packages'} = join(' ', @pkgs); $file{'versions'} = join(' ', @vers); $file{'path'} = $w[0]; if ($w[10] ne "X") { $files{$i,'link'} = $w[10]; } $file{'type'} = $w[10] ne "X" ? 3 : (-d &translate_filename($w[0])) ? 1 : $w[7] ? 5 : 0; $file{'user'} = $w[5]; $file{'group'} = $w[6]; $file{'mode'} = substr($w[4], -4); $file{'size'} = $w[1]; last; } } close(RPM); return 1; } # delete_options(package) # Outputs HTML for package uninstall options sub delete_options { print "<b>$text{'delete_nodeps'}</b>\n"; print &ui_yesno_radio("nodeps", 0),"<br>\n"; print "<b>$text{'delete_noscripts'}</b>\n"; print &ui_yesno_radio("noscripts", 0),"<br>\n"; } # delete_package(package, [&options], version) # Attempt to remove some package sub delete_package { local $opts; $opts .= $_[1]->{'nodeps'} ? "--nodeps " : ""; $opts .= $_[1]->{'noscripts'} ? "--noscripts " : ""; local $n = $_[2] ? "$_[0]-$_[2]" : $_[0]; local $qm = quotemeta($n); local $out = &backquote_logged("rpm -e $opts $qm 2>&1"); if ($? || $out =~ /error:/) { return "<pre>$out</pre>"; } return undef; } # delete_packages(&packages, [&options], &versions) # Attempt to remove multiple packages at once sub delete_packages { local $opts; $opts .= $_[1]->{'nodeps'} ? "--nodeps " : ""; $opts .= $_[1]->{'noscripts'} ? "--noscripts " : ""; local $cmd = "rpm -e $opts"; local $i; for($i=0; $i<@{$_[0]}; $i++) { if ($_[2]->[$i]) { $cmd .= " ".quotemeta($_[0]->[$i]."-".$_[2]->[$i]); } else { $cmd .= " ".quotemeta($_[0]->[$i]); } } local $out = &backquote_logged("$cmd 2>&1"); if ($? || $out =~ /error:/) { return "<pre>$out</pre>"; } return undef; } sub package_system { return "RPM"; } sub package_help { return "rpm"; } %etype = ( "5", $text{'rpm_md5'}, "S", $text{'rpm_fsize'}, "L", $text{'rpm_sym'}, "T", $text{'rpm_mtime'}, "D", $text{'rpm_dev'}, "U", $text{'rpm_user'}, "M", $text{'rpm_perm'}, "G", $text{'rpm_group'} ); $has_search_system = 1; sub search_system_input { print "<input type=button onClick='window.ifield = document.forms[2].url; chooser = window.open(\"rpmfind.cgi\", \"chooser\", \"toolbar=no,menubar=no,scrollbars=yes,width=800,height=500\")' value=\"$text{'rpm_find'}\">"; } 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 |
|