You are not logged in.

#1 2015-04-22 16:29:22

GreenRaccoon23
Member
Registered: 2014-09-27
Posts: 33

How to Return Error in PKGBUILD?

When creating a PKGBUILD, is there a way to return an error manually?

In my situation, my package requires a specific font, so I want my PKGBUILD to check whether that font is installed. Since a number of different packages include this font, and also because these packages conflict with each other, I cannot add one of them to the 'requires' part of the PKGBUILD. As a work around, I was going to include in the PKGBUILD a manual check for this font, and if it is not installed, then I would return an error message with a list of packages which include it.

Is there a way to do this? Or does anyone know of a better solution?

Offline

#2 2015-04-22 16:42:49

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

Re: How to Return Error in PKGBUILD?

It's bash. Just do the check, print the error, then return 1.

Online

#3 2015-04-22 16:50:57

GreenRaccoon23
Member
Registered: 2014-09-27
Posts: 33

Re: How to Return Error in PKGBUILD?

So just a `return 1` will stop makepkg from continuing?

Offline

#4 2015-04-22 16:57:42

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

Re: How to Return Error in PKGBUILD?

any error at all will stop makepkg from continuing. You could just run "false" if you wanted.

Edit: shoot, in Bash it would be "exit 1", not "return 1". Been looking at C lately.

Last edited by Scimmia (2015-04-22 17:01:18)

Online

#5 2015-04-22 17:25:32

GreenRaccoon23
Member
Registered: 2014-09-27
Posts: 33

Re: How to Return Error in PKGBUILD?

Cool thanks! I just found this on the wiki too, under the explanation for the `prepare()` function. I must have missed it earlier.

Note: (From man PKGBUILD) The function is run in bash -e mode, meaning any command that exits with a non-zero status will cause the function to exit.

Also, I found out that the PKGBUILD command for an error is called `error`. The other ones are `msg`, `msg2`, and `warning`.

Last edited by GreenRaccoon23 (2015-04-22 17:39:49)

Offline

#6 2015-04-22 18:00:21

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: How to Return Error in PKGBUILD?

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB