You are not logged in.

#1 2023-03-23 00:33:25

hunter10
Member
Registered: 2022-08-29
Posts: 26

[SOLVED]Remove/update file not owned by package when upgrading package

I want to preface by stating I am aware this should never be done in a public facing package.

I need to update the file as described in a previous post https://bbs.archlinux.org/viewtopic.php?id=279872 over the air.

This file has been created on a custom Archiso ISO during install on the computer, and as such is not owned by the package my-application. However, since my-application is hosted on my own arch repository, I can update my-application as need be remotely on these computers with pacman.

When trying to copy or install a new supervision_timeout_change.service to /etc/systemd/system/ in my-application PKGBUILD's package() method, I get

error. failed to commit transaction (conflicting files)
myuser: /etc/systemd/system/supervision_timeout_change.service exists in filesystem

Here's what I've tried in package() method of PKGBUILD:
Try 1:

package() {
  install -Dm644 supervision_timeout_change.service $pkgdir/etc/systemd/system/supervision_timeout_change.service
}

Try 2:

package() {
  # add the BLE supervision timeout change service file
  # must manually copy the file over as install will result in error stating that the file exists on the system already (since it was created
  # by the ISO and not installed from this package in the first place - no package owns the file)
  mkdir -p $pkgdir/etc/systemd/system
  cp supervision_timeout_change.service $pkgdir/etc/systemd/system/supervision_timeout_change.service
  chmod 644 $pkgdir/etc/systemd/system/supervision_timeout_change.service
}

I have also tried to have a .INSTALL file to remove the current file (during testing I am assuming this occurs after the package() method(?), so does not work and results in same error).
my-application.install:

pre_upgrade(){
  rm /etc/systemd/system/supervision_timeout_change.service
}

Where it is referenced in PKGBUILD as

install=my-application.install

Is there any way to update the file in the computer's filesystem during the my-application upgrade (pacman -Syu)?

Last edited by hunter10 (2023-03-23 04:28:13)

Offline

#2 2023-03-23 00:46:59

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

Re: [SOLVED]Remove/update file not owned by package when upgrading package

Use pacman's --overwrite flag.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2023-03-23 00:51:45

hunter10
Member
Registered: 2022-08-29
Posts: 26

Re: [SOLVED]Remove/update file not owned by package when upgrading package

I can go ahead and update my-application to use the --overwrite flag, but just seeing if there's any other ways to do it as I would have to update the software to a new version, add the --overwrite flag, and update the software in the repo again.

Additionally, I don't have control over the computers - so I don't know when they would my-application's package (pacman -Syu is done automatically, not under a user manually performing).

Last edited by hunter10 (2023-03-23 00:51:54)

Offline

#4 2023-03-23 00:57:19

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

Re: [SOLVED]Remove/update file not owned by package when upgrading package

No, you don't update the package to use that flag - you just reinstall the existing package using pacman's overwrite flag.  Please read the man page.

But if you don't have any influence on how updates are conducted on these systems, you're screwed regardless.  It's only a matter of time before there are far more serious problems.  Unattended updates a horrible idea and thus unsupported.  How do you not have any access to these machines?  What exactly is this situation?

Last edited by Trilby (2023-03-23 00:57:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2023-03-23 01:05:37

hunter10
Member
Registered: 2022-08-29
Posts: 26

Re: [SOLVED]Remove/update file not owned by package when upgrading package

All computers are running my-application. These computers do not have any user input in terms of someone there with a keyboard allowing custom commands to be executed on a terminal.

In a broad sense, think kiosk-style presentation of my-application running on arch linux.

Also - sorry, I don't mean the package uses that flag, I mean in my-application it calls the pacman command itself - so I can update the code to update the pacman command that the application calls.

Last edited by hunter10 (2023-03-23 01:41:40)

Offline

#6 2023-03-23 02:37:57

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

Re: [SOLVED]Remove/update file not owned by package when upgrading package

hunter10 wrote:

so I can update the code to update the pacman command that the application calls.

So then why wouldn't the overwrite flag work?

And you don't have any shell access to these machines?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2023-03-23 04:27:56

hunter10
Member
Registered: 2022-08-29
Posts: 26

Re: [SOLVED]Remove/update file not owned by package when upgrading package

Overwrite flag would work. Thanks for the replies.

Last edited by hunter10 (2023-03-23 04:42:21)

Offline

Board footer

Powered by FluxBB