summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2023-01-25 13:25:08 +0000
committerMarc Espie <espie@cvs.openbsd.org>2023-01-25 13:25:08 +0000
commit3d253b2508b0d080e5fb798b133e74b4cafc5a36 (patch)
treeeb3b2e3b0aefbd1f70fb5b6a7a499978fc0c5eca /usr.sbin/pkg_add/OpenBSD
parenta4487944e99f81caf58c914742880c1678cc3bb1 (diff)
change naming convention for the lru "save history" cache, so that
ports like "lang/chicken/core" do generate files like lang.chicken.core.lru instead of lang.chicken.core (which can create confusion in people's mind) do so transparently by reading the old file if need be, and removing it afterwards. Funny thing noticed by tb@ ok tb@, sthen@
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index d4e139ca5ee..7767d31d77a 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.184 2022/11/01 17:41:19 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.185 2023/01/25 13:25:07 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -1600,7 +1600,8 @@ sub save_history
my $name = $plist->fullpkgpath;
$name =~ s,/,.,g;
- my $fname = "$dir/$name";
+ my $oldfname = "$dir/$name";
+ my $fname = "$oldfname.lru";
# if we have history, we record the order of checksums
my $known = {};
@@ -1610,6 +1611,12 @@ sub save_history
$known->{$_} //= $.;
}
close($f);
+ } elsif (open(my $f2, '<', $oldfname)) {
+ while (<$f2>) {
+ chomp;
+ $known->{$_} //= $.;
+ }
+ close($f2);
}
my $todo = [];
@@ -1646,6 +1653,7 @@ sub save_history
close($f);
rename($name2, $fname) or
$state->fatal("Can't rename #1->#2: #3", $name2, $fname, $!);
+ unlink($oldfname);
# even with no former history, it's a good idea to save chunks
# for instance: packages like texlive will not change all that
# fast, so there's a good chance the end chunks will be ordered