Hi
Read this: https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave
Would appreciate a bit simpler explanation on how to use “Pacdiff & Meld”, what it does and when to use it.
Thank you!
Hi
Read this: https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave
Would appreciate a bit simpler explanation on how to use “Pacdiff & Meld”, what it does and when to use it.
Thank you!
Really good question, something I always intend on looking up but never do
What I take from this is something I do before any update already. Backup.
Backup is always a very good idea.
Anyway, Pacdiff & Meld combines those programs for easier way of merging changes to config files.
Config file changes may or may not affect the features of an app. Merging is (or should be) optional, i.e. apps should work well even without merging the changes. However, sometimes a config file change may enable new features that a user finds useful. So, looking through the changes may reveal something new that you might have wanted (but never bothered to ask).
Pacdiff contains the logic that drives merging.
Meld is a GUI tool that helps merging changed lines into a config file.
See also:
We have a config file /etc/locale.gen
containing locales for the system.
At times this file will be updated, and file /etc/locale.gen.pacnew
is created that includes all locales. And there may be other config file updates too.
Now, if you want to see what has changed in the config files, click the Pacdiff & Meld button (or run command eos-pacdiff
) to see them. It runs pacdiff
which shows each changed config file in turn. User can now choose what to do. Selecting the (V)iew operation starts meld
that shows the contents of the existing and the new config file, side by side.
Now you should see which of the changes are useful for you, if any. Meld helps you merge the lines you want to merge.
There are files that you should not merge, for example
/etc/passwd
/etc/group
If you blindly merge all changes to those files, you probably won’t be able log in anymore!
100% always make backups and make at least 2
There are likely youtubes that introduce each tool and show it being used. Could be helpful for some if they learn that way. Maybe.
I use meld personally. It has decent keyboard shortcuts. I’d really like to use vim/nvim to do these, but someday I’ll get there.
Yer another thing for people who are learning is try it in a VM first, yes you might be doing double the work but if something screws up in the VM you save yourself a headache later.
VM is overhead for using an application like meld or pacdiff. I have both installed and use them for different items. Arch isn’t that brittle. You’ve got /var/log/pacman.log and can walk your install backwards if needed.
True but still much better to screw up in a VM and save a headache like I said as well
I wouldn’t recommend double handling if you know what you’re doing/how to get yourself out of trouble
Hrm. A potential exercise. Take your ASCII text resume, make two copies. From one copy, remove several lines. From the other, remove some different lines and words.
Use a potential diff tool to reconstruct the two copies to match the original.
Most probably would use diff tools on mirrorlist files. One should still see a valid mirrorlist minus any changes, but they may need to re-enable/uncomment their favorite preferred mirror.
Have fun! These diff tools make it easy to visualize differences. Usually you only want to go one way, but there may be times to go both left and right.
I’m still learning about Arch, so I’m a little unsure about the underlying mechanics of pacdiff
, and pacman
for that matter.
Reading the Arch wiki, I seem to have understood that pacman doesn’t blindly overwrite system config files I (or some process) have (has) changed, and I need to do something about that (“maclean” complains).
But what is the correct way?
eos-pacdiff
invokes Meld (nice!) when I say v
for View, say for /etc/hosts
:
Obviously, the right one is the correct one.
Now should I do the changes (move right to left in this case) in Meld, and save the changes into /etc/hosts.pacnew
, or should I select m
for Merge, or r
for Remove pacnew?
Starting pacdiff & meld as root ...
[sudo] Passwort für matthias:
==> Creating backups under folder /etc/.EOS_BACKUPDIR
==> pacnew file found for /etc/hosts
:: (V)iew, (M)erge, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/m/s/r/o/q] v
:: (V)iew, (M)erge, (S)kip, (R)emove pacnew, (O)verwrite with pacnew, (Q)uit: [v/m/s/r/o/q] v
And what about this /etc/.EOS_BACKUPDIR
? Must I remove/clear it after doing changes, or will eos-pacdiff
do that?
I want to keep my new EOS “clean”, but I also don’t wish for lots of hidden “backups” cluttering the file system.
(And cheers to @cscs for giving us the little maclean
helper tool—without its message I wouldn’ŧ even have known pacman tries to “behave” in respect of config files, and that I need to manually intervene! Looks like I really start falling in love ith EOS…)
Just found @cscs’s explanation on the Manjaro forum.
So it seems I should
.pacnew
) into the right one (mine),r
(emove) the .pacnew
.That correct?
Oh no.
Looks like they took a page out of manjaro’s book ..
You arent supposed to launch pacdiff
as root, or with ‘sudo’.
And you arent supposed to generate some list of of pacnews and then feed that list to ‘sudo $DIFFPROG’.
At least the eos version creates backups I guess.
But the correct way is
pacdiff -s
Which will properly use sudoedit
.. meaning work on temporary files and afterwards use sudo
to move edited files into place.
It may be mentioned that padiff
relies on $DIFFPROG
variable, and if undefined will use vim -d
.
So you really should have $DIFFPROG
set already, but if not then you could use something like
DIFFPROG=meld pacdiff -s
The idea is to apply any needed data from the pacnew into your local file, preserving any custom values that are still applicable. That would be v
to view and make any edits and in the example is ‘taking from the left and putting in the right’ as the pacnew is on the left.
When finished then save and exit the diff prog.
Pacdiff will re-present with the pacnew file and prompt for what to do.
s
will skip and move on (retaining the pacnew for future use or inspection), r
will remove the pacnew, and so on. Assuming all is correct then r
would be a reasonable choice and the ultimate goal.
Yep, the -s
option was added back in 2022. This is the way.
Note that in most cases you don’t have to do anything with the pacnew files.
And in some cases it can be even dangerous to blindly copy from left to right, as explained above.
The idea is to manually check the changes for your system, and carefully merge the relevant changes when needed.
The reason for the backups under .EOS_BACKUPDIR is there have been cases that a user has blindly copied /etc/passwd.pacnew
and after logout or reboot cannot log in to the system.
The backups help fixing that.
eos-pacdiff does not remove the backup files under .EOS_BACKUPDIR because user may want to keep some of them. So user should manually remove the ones that are no more needed.
Thanks all for the explanations, I think I get it now.
I went through them now, and found only two (and expected) changes: the hosts file (changed by setup), and the pacman mirror list (changed by reflector). So all good, no need for manual merging, just removed the .pacnew
files.
Nevertheless, there seems to be some disagreement here between using eos-pacdiff
(as offered by the “Welcome” screen), and using pacdiff -s
manually.
So which should an EOS beginner actually use? Is eos-pacdiff
more “dangerous”? Or can a beginner safely start using the Welcome screen option, then later transition to pacdiff -s
?
Both are OK and safe in my mind. Which one to use is mostly matter of taste.
Here’s some comparison:
eos-pacdiff
has some small additions and changes to pacdiff, like
--no-backup
to disable backing up)meld
for local file comparisonpacdiff
pacdiff
--backup
)vim
for local file comparison by defaultYou skipped the most important parts.
eos-pacdiff
eesentially launches sudo pacdiff
which is not the proper approach.
Whereas pacdiff -s
is the correct approach and uses DIFFPROG on temporary files, not in root/sudo mode, and then uses sudo
afterwards to affect changes.
EDIT
Have a PR:
Thanks for the PR! I’ll look into it.