You are not logged in.

#1 2020-09-01 02:30:05

anacron
Member
Registered: 2020-01-26
Posts: 32

[SOLVED] How to make an installation fail

I'm creating a custom package, and it has a .install file. How do I compose the .install file such that pacman will fail the installation if a critical installation step cannot be completed? I need this functionality to prevent pacman from erroneously believing that my package was successfully installed.

Last edited by anacron (2020-09-02 04:04:58)

Offline

#2 2020-09-01 02:33:00

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: [SOLVED] How to make an installation fail

anacron wrote:

I'm creating a custom package, and it has a .install file. How do I compose the .install file such that pacman will fail the installation if a critical installation step cannot be completed? I need this functionality to prevent pacman from erroneously believing that my package was successfully installed.

exit/return 1?
What do you want to do on install?

Till them so far the sane approach it to log for the user, a big message like the one perl shows complaining for the locale should be enough.

“Hey user, this expected Y but found X, fix it with Z”

Last edited by GaKu999 (2020-09-01 03:30:05)


My reposSome snippets

Heisenberg might have been here.

Offline

#3 2020-09-01 02:42:00

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

Re: [SOLVED] How to make an installation fail

You can't.  Please describe what you actually need to do as this as-is is a perfect example of an XY problem.

Last edited by Trilby (2020-09-01 03:23:41)


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

Offline

#4 2020-09-01 03:09:09

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] How to make an installation fail

The package is already installed by the time the .install file runs, so it's not possible to "abort" the installation in that stage.

As Trilby said, give us the X in this XY Problem (thanks for the link to my site Trilby, nice to spot it 'in the wild' big_smile)

Offline

#5 2020-09-01 04:27:20

anacron
Member
Registered: 2020-01-26
Posts: 32

Re: [SOLVED] How to make an installation fail

GaKu999 wrote:

exit/return 1?

That doesn't work.

fukawi2 wrote:

The package is already installed by the time the .install file runs

What about the pre_install function?

Trilby wrote:

You can't.  Please describe what you actually need to do as this as-is is a perfect example of an XY problem.

Okay.

My package is a set of personal icons for the Dolphin file manager. The package installs svg files to /usr/share/icons/breeze-dark/places. I would like the package to additionally change the icons of several folders in my home directory. Dolphin sets the appearance of a folder by writing to a ".directory" file inside the directory, therefore I was going to include the appropriate .directory files in my package.

However, I use FUSE filesystems (gocryptfs) in my home directory, which are mounted from remote shares, and I want to change only the icons of the underlying, empty directories which serve as mountpoints for my FUSE directories. I want to do this so that when I open Dolphin, it will be visually apparent whether the FUSE is mounted.

Because I know of no other way to access an underlying filesystem, I sought to unmount all of the FUSE filesystems before installation with the help of the pre_install function in a .install script. Using this method, should the script be unable to unmount a directory, I need it to abort the installation in order to preserve the .directory files in the overlaid filesystems. And that's what brought me here.

Offline

#6 2020-09-01 04:33:32

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: [SOLVED] How to make an installation fail

Packages should never change your home dir, so this whole idea is a non-starter. Packages should work for all users, including ones that haven't been created yet.

Offline

#7 2020-09-01 04:33:47

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] How to make an installation fail

anacron wrote:

Using this method, should the script be unable to unmount a directory, I need it to abort the installation in order to preserve the .directory files in the overlaid filesystems. And that's what brought me here.

Why not just abort the script and highlight that something went wrong? The package installation is still a valid action in it's own regard; it's the configuration task that fails. Put another way, these are distinct actions, where configuration depends on installation, but installation does not depend on configuration.

To answer the questions as presented though: I don't know of a way you could achieve this.

Offline

#8 2020-09-01 05:08:24

anacron
Member
Registered: 2020-01-26
Posts: 32

Re: [SOLVED] How to make an installation fail

fukawi2 wrote:

Why not just abort the script and highlight that something went wrong?

I can make the install script output an error, but it will still install to the wrong place and make a mess that I have to clean up manually.

fukawi2 wrote:

The package installation is still a valid action in it's own regard; it's the configuration task that fails. Put another way, these are distinct actions, where configuration depends on installation, but installation does not depend on configuration.

You're right; it's probably best if I separate those tasks.

Scimmia wrote:

Packages should never change your home dir, so this whole idea is a non-starter. Packages should work for all users, including ones that haven't been created yet.

What about xdg-user-dirs? It appears to modify home directories, but not directly. It installs scripts that will do the configuration for the user. Maybe I could do it that way: include the configuration script in the package, and run it at a later time.

Offline

#9 2020-09-01 05:09:43

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] How to make an installation fail

anacron wrote:

...but it will still install to the wrong place and make a mess that I have to clean up manually.

Then your script needs better error handling wink

Offline

#10 2020-09-01 05:18:21

anacron
Member
Registered: 2020-01-26
Posts: 32

Re: [SOLVED] How to make an installation fail

fukawi2 wrote:

Then your script needs better error handling

No, the script can't help it. It's pacman that's making the mess in that case. Pacman calls the script, and subsequently installs those files irrespective of what I had in the script.

Offline

#11 2020-09-01 05:24:03

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: [SOLVED] How to make an installation fail

anacron wrote:
fukawi2 wrote:

Then your script needs better error handling

No, the script can't help it. It's pacman that's making the mess in that case. Pacman calls the script, and subsequently installs those files irrespective of what I had in the script.

Abusing the API doesn’t meant the API is broken...

For user setup, reporting to the user what must be done or wrapping it up in a detailed setup script would be the choices in this case...

Don’t wrap code on install that touches /home...


My reposSome snippets

Heisenberg might have been here.

Offline

#12 2020-09-01 05:28:13

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] How to make an installation fail

Oh I see, the package is installing to your /home directory, and you're using the script to unmount/mount the network shares. I thought the package was installing to /usr or something, and the script was modifying the files in your /home

Yeah, this isn't what the tool was designed for. I don't use KDE so I'm not sure what other options you have to change the icons, but I'd install the icons to /usr or /opt or something, then symlink or edit the files in your home directory appropriately to point to those files.

Offline

#13 2020-09-01 12:36:47

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

Re: [SOLVED] How to make an installation fail

Ah ... what?  So is this package only for you and not to be shared at all?  If it's the former, you don't need an install script ... you just need a script you can run on any machine you want to use this on.  Honestly, I'm not even sure why you'd package this.

If it's for other people ... who exactly?  It'd only be for people who 1) wanted pacman to change settings under their home directory, 2) had the same directory structure under $HOME that you do, 3) use FUSE for directories in their home directory ... and for the same directories you do, and 4) run KDE?

I suspect there might be one person in the universe who meets all of these criteria.  So why are you packaging this?


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

Offline

#14 2020-09-02 04:04:39

anacron
Member
Registered: 2020-01-26
Posts: 32

Re: [SOLVED] How to make an installation fail

Scimmia wrote:

Packages should never change your home dir

GaKu999 wrote:

Don’t wrap code on install that touches /home...

Gotcha.

Trilby wrote:

So is this package only for you and not to be shared at all?  If it's the former, you don't need an install script ... you just need a script you can run on any machine you want to use this on.

Yeah, that's what I'm going to do. I'll separate the icon installation from the home directory configuration.

Thanks, everyone.

Offline

Board footer

Powered by FluxBB