You are not logged in.
Looking for a good way to script the answer to the pacman question:
:: newpackage and oldpackage are in conflict. Remove oldpackage? [y/N]
Experimented with the "--print-format" option to determine what package might need to be removed but a lot of the format strings don't do anything for me, e.g. "%H" does not get resolved. And due to dependencies, the install and uninstall operations should really be part of the same transaction.
What I'm really trying to do is, from a script, to obsolete an already-installed package oldpackage with a new package newpackage. So I made newpackage "conflicts" with oldpackage and "provides" oldpackage and "replaces" oldpackage. Which leads to that question when trying to install newpackage. --noconfirm doesn't seem to apply there.
Last edited by jernst (2024-05-05 03:24:32)
Offline
There is no automated and surefire way to do this which is why the option is prompted in the first place.
FWIW if the default choice is N in this case then your conflicts and replaces are set incorrectly, as a properly set up directive would make Y the default choice. Can you get actually clarity about what exact package you are wanting to do this with?
Offline
My own packages.
newpackage's PKGBUILD has:
provides=(
'oldpackage'
)
conflicts=(
'oldpackage'
)
replaces=(
'oldpackage'
)
Is that wrong? If I could get the default to be Y, then --noconfirm would probably solve my problem.
Offline
Why not just do two steps:
pacman -Rdd oldpackage
pacman -S newpackage
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
V1del: Looking at the source, I'm not seeing a code path in which the question could be Y/n instead of y/N. (But I'm not familiar with the code base so I may well be wrong.)
Trilby: This would probably work, if I could determine the name of oldpackage somehow. Which is why I tried the --print-format %H (see original post) hoping it would tell me the name of the conflicting package, but %H didn't get replaced.
Offline
pacutils is designed for handling scripting use cases.
Offline
Will investigate that. Ty.
Offline
So I made newpackage "conflicts" with oldpackage and "provides" oldpackage and "replaces" oldpackage.
So how can you not know the name of oldpackage?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
It's because it's not about a single package, but a scheme to be applied to several package families. Also the reason I need to script.
Seems I need to investigate pacutils as the better tool for the job.
I'm marking this as resolved.
Offline
Thing is that it's rather odd that you're not defaulting to "Y" and that oddity cannot be explained by some generic "I do about this and get about that" - maybe you need a versioned directive or whatever.
Also: do you default to "N" all the time (even w/ package replacements in the repos) or just w/ your own ones?
Offline
It's because it's not about a single package, but a scheme to be applied to several package families.
The number doesn't matter. If each package's replacement lists the original package as a conflict/replace then you clearly have the (list of) name(s) of the package(s) to be replaced. Making this statement plural has no impact on it's veracity.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
I'm not sure I can do this easily in a pacman -Syu scenario. But I haven't tried yet :-)
Offline