You are not logged in.

#1 2024-05-04 20:31:36

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Solved: Script pacman conflict resolution

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

#2 2024-05-04 21:01:29

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,892

Re: Solved: Script pacman conflict resolution

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

#3 2024-05-04 21:43:20

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Re: Solved: Script pacman conflict resolution

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

#4 2024-05-04 22:12:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,616
Website

Re: Solved: Script pacman conflict resolution

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

#5 2024-05-04 22:32:36

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Re: Solved: Script pacman conflict resolution

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

#6 2024-05-04 22:54:05

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,411
Website

Re: Solved: Script pacman conflict resolution

pacutils is designed for handling scripting use cases.

Offline

#7 2024-05-04 23:11:42

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Re: Solved: Script pacman conflict resolution

Will investigate that. Ty.

Offline

#8 2024-05-05 02:10:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,616
Website

Re: Solved: Script pacman conflict resolution

jernst wrote:

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

#9 2024-05-05 03:24:03

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Re: Solved: Script pacman conflict resolution

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

#10 2024-05-05 06:59:31

seth
Member
Registered: 2012-09-03
Posts: 52,276

Re: Solved: Script pacman conflict resolution

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

#11 2024-05-05 12:50:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,616
Website

Re: Solved: Script pacman conflict resolution

jernst wrote:

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

#12 2024-05-05 19:57:56

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 296
Website

Re: Solved: Script pacman conflict resolution

I'm not sure I can do this easily in a pacman -Syu scenario. But I haven't tried yet :-)

Offline

Board footer

Powered by FluxBB