You are not logged in.
I accidentally deleted some pacnew files using pacfiles-mode. Is there any way to get these files back? I don't know the name of what I deleted.
Last edited by ThinkPad (2021-09-23 16:43:59)
Offline
Reinstalling the package will create a pacnew.
Your pacman log has a record of them.
Last edited by jasonwryan (2021-09-20 03:27:27)
Offline
Sweet, thanks!
To document the solution:
1. List all pacnew files that have ever touched your system:
$ grep --extended-regexp "\.pac(new|save)" /var/log/pacman.log
2. Search for what package owns the file in question with:
$ pkgfile <file>
3. Reinstall the package:
# pacman -Syu <package>
Sources:
https://wiki.archlinux.org/title/Pacman … pac*_files
https://bbs.archlinux.org/viewtopic.php … 65#p704765
Offline
After doing what I listed, no new pacfiles show up in the log nor are detected by my tool. This was checked before and after reboot.
Offline
You would have to downgrade and upgrade again. pacnew files are only created if something changed between the package installed and the one being installed.
Online
Thank you!
Updated solution:
1. List all pacnew files that have ever touched your system:
$ grep --extended-regexp "\.pac(new|save)" /var/log/pacman.log
2. Note the date of the pacnew in question.
3. Search for what package owns the file in question with:
$ pkgfile <file>
4. Search your cache for the version prior to that date:
$ find /var/cache/pacman/pkg -iname *<package>*
In my case downgrading to the oldest version in the cache was most reliable. That being said, you can skip step 2.
5. Downgrade to that package:
# pacman -U /var/cache/pacman/pkg/<old-package>
NOTE: Be very careful downgrading `pacman`. I did and was not able to perform a system upgrade. Using `pacman-static` got me out of trouble.
6. Upgrade package to force pacnew creation:
# pacman -S <package>
I did this at each interval to avoid putting my system in a broken state. You might get away with doing a full system upgrade at the end.
Sources:
https://wiki.archlinux.org/title/Pacman … pac*_files
https://bbs.archlinux.org/viewtopic.php … 65#p704765
https://wiki.archlinux.org/title/Downgrading_packages
Offline
You should be able to handle this without down/upgrading - especially if you already know which files you're looking for as you can just extract them from the current package file. I have this little script to extract a given file from the current cached package file for a given package (downloading it from a mirror only if it is missing from the local cache):
#!/bin/sh
[ $# -lt 2 ] && exit 1
uri=$(pacman -Sp $1)
path=$(pacman -Flq $1 | grep -m 1 /$2$)
[ -z "$uri" ] && exit 1
[ -z "$path" ] && exit 1
curl -sL $uri | bsdtar xOf - $path
Just pass a package name and a filename and the default content (which is what a pacnew would contain) is printed to stdout.
Last edited by Trilby (2021-09-23 16:59:32)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline