FS#3244 - pacman wishlist (4/4): Declaration of post_install() and friends inside PKGBUILDs

Attached to Project: Pacman
Opened by Mark Rosenstand (mrose) - Wednesday, 28 September 2005, 00:09 GMT
Last edited by Xavier (shining) - Thursday, 24 July 2008, 12:19 GMT
Task Type Feature Request
Category
Status Closed
Assigned To Aaron Griffin (phrakture)
Architecture not specified
Severity Low
Priority Normal
Reported Version 0.7 Wombat
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

It seems silly that you're declaring a build() function but need an external
file to declare other basic functions. I do realize that it's easier to
include the file with install time functions in the tarball, but it
shouldn't be too hard to extract them from the PKGBUILD and then include.

It's also silly that you have to write the same three lines at the buttom
of every single install-file.
This task depends upon

Closed by  Xavier (shining)
Thursday, 24 July 2008, 12:19 GMT
Reason for closing:  Won't implement
Comment by Mark Rosenstand (bitbull) - Wednesday, 02 November 2005, 10:10 GMT
Reconsidering this, and the fact that this will be hard and probably ugly to implement, I instead suggest that we use a standard name for install files, just like with PKGBUILDs. INSTALL is probably a bad name, though :-)

If the file exists, it gets included. What do you think?
Comment by Aaron Griffin (phrakture) - Thursday, 25 January 2007, 21:29 GMT
Yeah, the way this stuff works, having those functions inside a PKGBUILD is near impossible to do elegantly.

Perhaps we could clean up the way install files actually work though...
Comment by Roman Kyrylych (Romashka) - Friday, 26 January 2007, 12:02 GMT
I think I missed something. What are technical difficulties to include post_install() and friends in PKGBUILD?
Comment by Aaron Griffin (phrakture) - Friday, 26 January 2007, 16:43 GMT
Ok, if post_install is inside a PKGBUILD, that means that the function itself is _defined_ when makepkg runs (it's callable). If bash allowed something like:

echo $FUNCTION(post_install) > install #made up syntax

This would become elegant. As it is now, there are two solutions, both of which seem goofy to me:

1) use complex regex / perl / python to strip the functions from the PKGBUILD, and spit them out to a file
2) include the PKGBUILD inside the package and use bash script, making sure to define all variables like $startdir beforehand so that it doesn't bail out on syntax errors.

Both seem hackish.

I would be more interested in creating say, a helper script for running install scriptlets, that pacman itself can call, removing some of the goofy framing logic (only a few lines anyway) from the scriptlets
Comment by Roman Kyrylych (Romashka) - Friday, 26 January 2007, 16:53 GMT
> 2) include the PKGBUILD inside the package and use bash script, . . .
Ah, my bad, I totally forgot that PKGBUILDs are not included in binary packages. Shame on me. :)

1) can be simplyfied, for example

build() {
. . .
}
#---
post_install() {
}
We can just split the rest of file after #--- to .INSTALL

But then, integrating post_install & friends into PKGBUILD will not improve things much, IMHO.
Anyway templating .install files could be done with something like install=$templates/xcursor.install line in PKGBUILD, so with integrating post_install stuff into PKGBUILD there will still be install= option.
Comment by Xavier (shining) - Monday, 25 February 2008, 11:58 GMT
This bug report was mentioned from the ML, but not the other way around. I think it could help other people that read it.
patch proposed by molok :
http://www.archlinux.org/pipermail/pacman-dev/2007-September/009264.html
last discussion about it :
http://www.archlinux.org/pipermail/pacman-dev/2008-January/010977.html

About the second issue, you don't need "the same three lines at the bottom of every single install-file" anymore :
http://projects.archlinux.org/git/?p=pacman.git;a=commit;h=565d2eeed5fdd85b516cbc76bc48be439e42c41f
Comment by Gavin Bisesi (Daenyth) - Tuesday, 11 March 2008, 18:30 GMT
re:phrackture
>echo $FUNCTION(post_install) > install #made up syntax
Would it work to parse the output from "type"? I'm not sure how that would work, as I'm not familiar with makepkg internels, but:

daenyth@Muspelheimr ~ $ cat testtype.bash
#!/bin/bash
function dummy() { echo "I am a dummy function"; }
type dummy
daenyth@Muspelheimr ~ $ bash testtype.bash
dummy is a function
dummy ()
{
echo "I am a dummy function"
}
Comment by Gavin Bisesi (Daenyth) - Friday, 13 June 2008, 19:35 GMT
After reflecting on this, it seems like every solution is to include the functions in the PKGBUILD... and then when the package is built, split them away from the PKGBUILD back to a second file. That seems rather... suboptimal. Does anyone else have an opinion on this?
Comment by Xavier (shining) - Saturday, 14 June 2008, 08:04 GMT
I agree, that is why this feature request looks silly to me.
Comment by Xavier (shining) - Thursday, 24 July 2008, 12:19 GMT
> It seems silly that you're declaring a build() function but need an external
> file to declare other basic functions. I do realize that it's easier to
> include the file with install time functions in the tarball, but it
> shouldn't be too hard to extract them from the PKGBUILD and then include.

We still need that external file in the end, so it is more simple to always create it in the first place.

> It's also silly that you have to write the same three lines at the buttom
> of every single install-file.

This is no longer the case.

Loading...