[pacman-dev] makepkg3 improvements (for pacman-3.1)

Dan McGee dpmcgee at gmail.com
Fri Mar 23 18:58:26 EDT 2007

On 3/23/07, Andrew Fyfe <andrew at neptune-one.net> wrote:
> Hi,
> I've been using pacman for over a year now on DIY-Linux
> (http://www.diy-linux.org), and to put it simply it's great easy to use
> and easy to setup. So I thought it was about time I contribute something
>   back... an improved version of makepkg. For the impatient :p see the
> script attached.

Welcome to the list, good to have a few new voices.

> makepkg2's use of fakeroot was a bit hackish, it's now very hackish in
> makepkg3. It also kicks up a few strange bugs (flyspray #6208) because
> it's being used where it shouldn't be. So I've rewritten/reordered
> makepkg to reduce the amount of time spent in fakeroot. Specificly it's
> now only used for...
>         fake_install() (if it exists. See below)
>         build() (if there's no fake_install)
>         tidy_install()
>                 - remove docs
>                 - move/compress man pages
>                 - strip binaries/libraries
>                 - remove libtool files
>                 - remove empty directories
>         create_package()
>                 - create .PKGINFO & .FILELIST
>                 - tar it all up
> everything else is run outside of fakeroot.

Yes, this is definitely a better way to go about doing this. makepkg
itself is getting a bit unwieldy, and the original method of recalling
itself with fakeroot is quite ugly.

> Over at DIY-Linux we have a patch that adds an extra function to
> PKGBUILD (fake_install). This way we can prepare, compile, and test the
> package as the user running makepkg. Then fake_install is run inside
> fakeroot to install the package. This further reduces the time spent in
> fakeroot and the possibility of any weird bugs popping up. If the build
> script doesn't contain a fake_install function the build function  is
> run inside of fakeroot instead (maintaining backwards compatibility with
> how things work at the moment).

So if I understand correctly, each PKGBUILD would have a build()
function to actually build, and a fake_install() function that usually
contains something like 'make install'? This seems like a pretty sane
idea, although some of our PKGBUILDs are a bit convoluted.

> Other changes...
> - reordered the code to reduce the number of if..then..else cases
Probably needed on our end as well.

> - renamed a lot of variables so they're a bit more descriptive.

> - started to add error codes for the different reasons why makepkg exits
+1, this is something I started thinking about but never got around to doing.

> - quoted all variables that contain paths so '/home/me/a folder with
> spaces' doesn't cause errors. (but build scripts are still a point of
> failure as the majority don't have $startdir in quotes.)
I think I got all of these in my last run through of the script, but
don't quote me on that (wow, bad joke). :)
> - fixed flyspray bug #6468 -- Localized dates for build/install date
Ooo, we'll definitely look at this.

> - added some more error catching
> - added the ability to choose between usr/man and usr/share/man (var
> (_MAN_DIR) at the top of the script.)
This should maybe even be in makepkg.conf.

> There are still a few things that need fixed, but some discussion is
> probably required.
> - Should build deps be removed after a successful build?
> At the moment deps are only removed if '-r' is used and it removes build
> deps and runtime deps. An extra option to remove build deps?
> - Should root be a loud to run makepkg?
> IMO running makepkg as root is a hanus crime, and anyone foolish enough
> to do so deserves to have their system burn to the ground as the result
> of a broken build script. One mistaken key stroke in a build script can
> result in a successful build or the destruction of a system :p
> I've added a warning that asks the user if they're sure the want to
> continue running makepkg as root.
> With sudo and fakeroot there's no need to run makepkg as root, but thats
> just my opinion.
It's my opinion too. I think we should definitely have a warning and
prompt that has to be answered when building as root.

Welcome to the list, hope you can help us get a lot of these fixes
into the upstream makepkg.


More information about the pacman-dev mailing list