summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorpaul <paul@FreeBSD.org>2001-01-14 02:05:02 +0000
committerpaul <paul@FreeBSD.org>2001-01-14 02:05:02 +0000
commit3b9a1f213fbb9437202de442eb2e33f55069b9bd (patch)
tree5d268acf5d30d370a8d978a6e507c61c5ed8b72e /usr.sbin
parent187b13bfd2fa124b2ceb29d4e1e8e6032ba03662 (diff)
downloadFreeBSD-src-3b9a1f213fbb9437202de442eb2e33f55069b9bd.zip
FreeBSD-src-3b9a1f213fbb9437202de442eb2e33f55069b9bd.tar.gz
Fix a nasty bug whereby if the package file didn't have a version number
then all packages would be deinstalled! The tightening up of version number checking also fixes a bug where a package file such as gtk.tgz would have resulting in gtk-engines being deinstalled.
Diffstat (limited to 'usr.sbin')
-rwxr-xr-xusr.sbin/pkg_install/update/pkg_update.pl20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/pkg_install/update/pkg_update.pl b/usr.sbin/pkg_install/update/pkg_update.pl
index e4f6804..727a5ba 100755
--- a/usr.sbin/pkg_install/update/pkg_update.pl
+++ b/usr.sbin/pkg_install/update/pkg_update.pl
@@ -51,12 +51,13 @@ sub error ($) {
sub get_version($) {
my ($pkg) = @_;
- if ($pkg !~ /-/) {
- return("", "");
+
+ $pkg =~ /(.+)-([0-9\.]+)/;
+ if (! $2) {
+ return($pkg, "");
+ } else {
+ return ($1, $2);
}
- $pkg =~ s/(.*)\.tgz/$1/;
- $pkg =~ /(.+)-(.+)/;
- return ($1, $2);
}
sub get_requires($$) {
@@ -146,7 +147,6 @@ if (! -f $pkgfile) {
}
my $newpkg = basename($pkgfile, '.tgz');
-
my ($pkgname, $new_version) = get_version($newpkg);
if ($opt_r && $opt_r ne "") {
@@ -159,13 +159,19 @@ if ($opt_r && $opt_r ne "") {
$update_pkg = $pkgname;
}
+# Safety net to prevent all packages getting deleted
+if ($update_pkg eq "") {
+ die ("Package to update is empty, aborting\n");
+}
+
# Find out what package versions are already installed
open(PKGINFO, "$PKG_INFO|") || die("Can't run $PKG_INFO, $!");
while (<PKGINFO>) {
my ($pkg) = /^(.*?)\s+.*/;
- if ($pkg =~ /^$update_pkg/) {
+
+ if ($pkg =~ /^$update_pkg-[0-9\.]+/) {
push(@installed, $pkg);
}
}
OpenPOWER on IntegriCloud