Re: pkgsave cleanup
- In reply to: Roger Marquis : "Re: pkgsave cleanup"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 12 Nov 2023 11:57:31 UTC
On 11/11/2023 19:00, Roger Marquis wrote: > For those who are concerned about backup files being left in non-backup > directories this small script will cleanup .pkgsave files: > > > DBPATH=/var/db/pkgsave/`date +%G%m%d%H%M` > if [ ! -d $DBPATH ]; then > mkdir -p $DBPATH > fi > for f in `find / -type f -name \*.pkgsave` ; do > fori="`echo $f | sed 's/.pkgsave//'`" > diff $f $fori >/dev/null 2>&1 > if [ $? = 0 ]; then > rm -f $f > else > oripath="`dirname $f`" > if [ ! -d $DBPATH/$oripath ]; then > mkdir -p $DBPATH/$oripath > fi > mv -f $f $DBPATH/$oripath > fi > done I too have been busy converting everything to base packages, and it's all gone very smoothly, albeit with a lot of mopping up of .pkgsave files. A couple of things I noticed: * /var/db/locate.database is replaced by the installation of FreeBSD-runtime and you then would want to restore the original .pkgsave file. However, after that it's then flagged by `pkg check`: ``` # pkg check -s FreeBSD-runtime Checking FreeBSD-runtime: 0% FreeBSD-runtime-14.snap20231109173050: checksum mismatch for /var/db/locate.database Checking FreeBSD-runtime: 100% ``` Which makes no sense -- by its nature /var/db/locate.database is going to be rewritten with contents that vary week-to-week. In fact, this file probably shouldn't be included in any package. It will be created by the 310.locate periodic script whenever that runs, and the locate(1) command handles a non-existent /var/db/locate.database quite sensibly. ``` % git diff diff --git a/etc/Makefile b/etc/Makefile index b76d6e6462f4..dd9ddfef373f 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -84,10 +84,6 @@ distribution: ${INSTALL_SYMLINK} -T "package=sendmail" \ mail/aliases ${DESTDIR}/etc/aliases; \ fi -.endif -.if ${MK_LOCATE} != "no" - ${INSTALL} -o nobody -g ${BINGRP} -m 644 -T "package=runtime"\ - /dev/null ${DESTDIR}/var/db/locate.database .endif cd ${.CURDIR}/..; ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 \ -T "package=runtime" ${FREEBSD} ${DESTDIR}/ ``` This is the only mismatched checksum I've seen as a result of switching to packages. * There are several symbolic links to directories that get replaced and renamed adding .pkgsave, for instance: /usr/share/nls/en_US.US_ASCII.pkgsave -> C /usr/share/nls/POSIX.pkgsave -> C ... and many more but their target isn't changed, so they resolve to the "new" content of /usr/share/nls/C/ pkg(8) doesn't create .pkgsave versions of directories, and I think it should treat symbolic links likewise, according to what the target of the link is. So a link to a directory doesn't get a .pkgsave copy. A link to a file should only get a .pkgsave copy if the target file itself gets a .pkgsave copy and in that case, the new .pkgsave link should point at that .pkgsave copy. Cheers, Matthew