excalibur1234 / pacui

Bash script providing advanced Pacman and Yay/Pikaur/Aurman/Pakku/Trizen/Pacaur/Pamac-cli functionality in a simple UI
GNU General Public License v3.0
168 stars 13 forks source link

[Extras] Maintain System - Config Files Selective Merging Hook for Meld #42

Closed seafox closed 6 years ago

seafox commented 6 years ago

Coming from this post, it would be great when major DE users would have an ability to perform easy GUI checking & merging of configuration files. As a solid tool I'd suggest meld package. The pacui script could check if meld is installed in user system, then open it with appropriate files (works from shell great), and, after meld instance terminating, continue as usual.

@excalibur1234 if you think it's N/A (i.e. won't fly) feel free to close the ticket, no problem, the Sun is still shining, it's Summer time!

excalibur1234 commented 6 years ago

currently, pacui uses DIFFPROG environment variable as file difference viewer: add the full path of your favorite file difference viewer to your DIFFPROG variable. if this variable is not set, a wrapper for diff gets used, which does not offer the ability to edit .pacsafe/.pacnew files.

everything is described in the help page. please look at the second to last "Attention" to find the answer to your question:

"sudo pacdiff"
A .pacnew file may be created during a package upgrade to avoid overwriting a file (e.g. a config file) which already exists and was previously modified by the user. A .pacsave file may be created during a package removal, or by a package installation (the package must be removed first). These files require manual intervention from the user and it is good practice to handle them regularly - ideally everytime a .pacnew/.pacsave file has been created.
This command offers you a choice, whether you want to keep the original file (and delete the .pacnew/.pacsave file) or overwrite the original file with the .pacnew/.pacsave file (the original file is backed up automatically with an added dash "-" to the end of its file name).
It is strongly recommended to view and compare both files by choosing "v" before making a decision.
If you keep the original config file, the new program version could not recognize the old syntax in the original config file anymore. In the worst case, your program could break or stop working. If you remove the original file and use the new file without any changes, all your configuration settings might be reset to the default values. This can result in changed system behavior, including missing passwords or even sudo capability.
In most cases, the syntax does not change and you can simply remove the .pacnew file. However, if you notice a syntax change, it is highly recommended to solve this conflict in another way (e.g. by manually editing one of those files and deleting the other).
Attention: This command requires a default file difference viewer by setting the environment variable DIFFPROG. If this variable is not set, a minimal default is provided by PacUI using "diff".
Attention: In severe and rare cases, removing your old config file (and using the new .pacnew config file) OR keeping your old config file (and deleting the .pacnew config file) can result in a broken system. PLEASE BE CAUTIOUS WHEN USING THIS COMMAND!

if you think my wording can be improved, feel free to create a pull request.

please go ahead and test pacui with meld and report your results. i have actually never tested pacui with meld.

seafox commented 6 years ago

how to test it? tried to make pacman.pacsafe and pacman.pacnew copies in /etc, still no diff call?

excalibur1234 commented 6 years ago

i do not know how pacdiff works. if it does not start to work when, .pacnew files are added to /etc, i do not know what causes it to trigger.

if you cannot manage to test it, you can wait until the next update, which changes your config files...

seafox commented 6 years ago

ok, I set env var DIFFPROG=meld in .bashrc & will wait for the chance to see how the call goes.

seafox commented 6 years ago

doesn't seem to change anything, just the same console, no meld GUI:

diff

excalibur1234 commented 6 years ago

does

echo "$DIFFPROG"

show you anything? if not, your environment variable is not set correctly.

what happens on your system when you execute

sudo pacdiff

? it should use your DIFFPROG environment variable. btw, you might need the full path to your diff viewer in your environment variable. by default, vim is used as DIFFPROG for sudo pacdiff. if you have not installed vim, an error message appears.

seafox commented 6 years ago

I don't think an ordinary pacui user is expected to have vim, neither it has info about this requirement? Why would we have to install vim while meld wanted?

image

seafox commented 6 years ago

image

excalibur1234 commented 6 years ago

something must be wrong with your environmental variable.

pacui is using the following code:

        if [[ -n $DIFFPROG ]]    #check, if DIFFPROG environment variable is not empty
        then
            sudo pacdiff
        else
            sudo DIFFPROG="pacui --diff" pacdiff
        fi

when you run sudo pacdiff without a set DIFFPROG variable, you get the vim error. also, when pacui does not "see" the DIFFPROG variable, it uses its own diff program.

i guess your environment variable is not set globally and thus bash scripts do not "see" it, but your start shell (bash or something else) "sees" it.

seafox commented 6 years ago

Does it need to be set globally? OK, removed from ~/.bashrc and added it globally with added path, the same outcome: image

seafox commented 6 years ago

Looks like it required full path to pass if [[ -n $DIFFPROG ]] condition. Actually, now it started to show the same error when run pacui 2: image

excalibur1234 commented 6 years ago

you are now at a point, where pacui recognizes correctly that you have set something as your DIFFPROG and executes "sudo pacdiff" for you. it seems that "sudo pacdiff" tries to use DIFFPROG but does not recognize it. you now have to try to get pacdiff to run with your preset DIFFPROG. maybe "pacdiff -h" can help you with it.

please report back, when pacdiff works with your DIFFPROG.

seafox commented 6 years ago

I think you have to change your script to accept pure meld and check for that executable so it will pass the if [[...]] clause. As you see in picture, pacdiff even has exactly the Example 1 just for meld case: image

seafox commented 6 years ago

Also, for all none Manjaro AUR users, it would be great to have the simple step-by-step guide how to update their pacui or pacui-git packages removed from AUR.

excalibur1234 commented 6 years ago

i have just tested this myself:

  1. add following line to /etc/environment file: DIFFPROG=kompare
  2. reboot
  3. (optional) copy and rename any config file in /etc. for example, copy pacman.conf to pacman.conf.pacnew.
  4. run "sudo pacdiff" works as intended and opens kompare when you select "v" to view the changes. you can save your changes in kompare in pacman.conf and then delete pacman.conf.pacnew by selecting "r". "pacui m" displays exactly the same behavior as "sudo pacdiff".

as everything works as intended, i do not see any reason to adjust anything. what exactly do you want me to change?

excalibur1234 commented 6 years ago

Also, for all none Manjaro AUR users, it would be great to have the simple step-by-step guide how to update their pacui or pacui-git packages removed from AUR.

arch trusted users do not want you to install pacui easily from the AUR. please read here: https://github.com/excalibur1234/pacui/issues/45

the simplest method to get pacui for you is described in the readme (if you have not pacui installed, you have to install all its dependencies as well!): https://github.com/excalibur1234/pacui#execute-without-prior-installation

if you want to have pacui in your /usr/bin/ directory (as it is done when installing pacui), do the following (which "installs"/"updates" the latest development build):

  1. wget https://raw.githubusercontent.com/excalibur1234/pacui/master/pacui
  2. chmod +x pacui
  3. sudo mv pacui /usr/bin/
seafox commented 6 years ago

as everything works as intended, i do not see any reason to adjust anything. what exactly do you want me to change?

You are right, that setup seems to work. For some reason looked like if [[...]] clause returned incorrect answer when no full path was supplied for DIFFPROG value in /etc/bash.bashrc, then again, full path caused the error on sudo pacdiff call (see the pic). No idea what was the culprit. BTW the command didn't see sddm.conf.pacnew file in /etc.

seafox commented 6 years ago

For those outside Manjaro who prefer to maintain on package level (not only script):

wget -O ./PKGBUILD https://raw.githubusercontent.com/excalibur1234/pacui/master/PKGBUILD-git
makepkg -C -s -i -c

image

Strange that entering groups=('modified') into PKGBUILD has no effect...

@excalibur1234 you are free to close the issue now.