From: espie Date: Wed, 25 Jan 2023 13:25:07 +0000 (+0000) Subject: change naming convention for the lru "save history" cache, so that X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9356e752d591198118cf8bef06371fbd332b5a91;p=openbsd 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@ --- 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 # @@ -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 diff --git a/usr.sbin/pkg_add/pkg_create.1 b/usr.sbin/pkg_add/pkg_create.1 index 31909c08889..d2e28a90181 100644 --- a/usr.sbin/pkg_add/pkg_create.1 +++ b/usr.sbin/pkg_add/pkg_create.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkg_create.1,v 1.127 2022/11/09 10:10:53 espie Exp $ +.\" $OpenBSD: pkg_create.1,v 1.128 2023/01/25 13:25:07 espie Exp $ .\" .\" Documentation and design originally from FreeBSD. All the code has .\" been rewritten since. We keep the documentation's notice: @@ -21,7 +21,7 @@ .\" [jkh] Took John's changes back and made some additional extensions for .\" better integration with FreeBSD's new ports collection. .\" -.Dd $Mdocdate: November 9 2022 $ +.Dd $Mdocdate: January 25 2023 $ .Dt PKG_CREATE 1 .Os .Sh NAME @@ -141,7 +141,7 @@ Set package (mandatory). .It Cm HISTORY_DIR Record checksums of files in permanent location -.Pa ${HISTORY_DIR}/${FULLPKGPATH:S,/,./g} . +.Pa ${HISTORY_DIR}/${FULLPKGPATH:S,/,./g}.lru . .It Cm FTP Set to the port's Makefile .Va PERMIT_PACKAGE_FTP .