[pacman-dev] [PATCH] Create split package dirs first
Hi, When creating split packages I always wished one could just do make install in one of the package functions and then directly move the files belonging to other packages off to their respective pkgdirs. If you look at the PKGBUILD for systemd this is basically what it's doing except for one thing: the pkgdirs aren't created before calling the package functions. To work around this it creates it's own temporary _$pkgdir directories, moves the files to there and then from there to their proper destination in the later package functions. The following small patch fixes this. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 718b4e9..2a2901c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1924,9 +1924,11 @@ restore_package_variables() { run_split_packaging() { local pkgname_backup=${pkgname[@]} for pkgname in ${pkgname_backup[@]}; do + mkdir -p "$pkgdir/$pkgname" + chmod a-s "$pkgdir/$pkgname" + done + for pkgname in ${pkgname_backup[@]}; do pkgdir="$pkgdir/$pkgname" - mkdir -p "$pkgdir" - chmod a-s "$pkgdir" backup_package_variables run_package $pkgname tidy_install
On 20/06/12 22:07, Emil Renner Berthing wrote:
Hi,
When creating split packages I always wished one could just do make install in one of the package functions and then directly move the files belonging to other packages off to their respective pkgdirs.
To do this you make a big assumption.... The only guarantee makepkg has about folder locations is that the sources will be found in $srcdir and that $pkgdir will point at the directory containing the package files during its package function. So how are you going to move the files from one package directory to another one in an unknown location? The directory layout has changed before and possibly will again (particularly when splitting debug symbols to their own package happens...). So instead, lets deal with this properly. I mentioned this recently on the mailing list but did not go into details. So here goes an example PKGBUILD snippet: pkgname=('libfoo-headers' 'libfoo') package() { make -C $srcdir/$pkgname-$pkgver install } package_libfoo-headers() { filelist=('usr/include/*') } package_libfoo() { filelist=('*') } makepkg sees this PKGBUILD, notices it is a split package from the pkgname array, but also sees it has a package function. When it comes to packaging, it creates a temporary directory for filling when running the package() function. Then the actual packaging functions are run. makepkg sees the "filelist" variable is set and moves the files from the temporary directory to the package directory. Note that in this example package_libfoo() is called last and just mops up the remaining files. This is not necessary, but if there are files left over after the last package functions is run, makepkg should print a warning. So the patch would look something like: run_split_packaging() { local pkgname_backup=${pkgname[@]} + if (( PKGFUNC )); do + pkgname=$pkgbase + tmpdir=$(mktemp -d ......) + pkgdir=$tmpdir + mkdir -p "$pkgdir" + chmod a-s "$pkgdir" + run_package + fi for pkgname in ${pkgname_backup[@]}; do pkgdir="$pkgdir/$pkgname" mkdir -p "$pkgdir" chmod a-s "$pkgdir" backup_package_variables run_package $pkgname + if [[ -n $filelist ]]; do + for f in ${filelist[@]}; do + // simplified... need to create dirs + mv $tmpdir/$f $pkgdir + done + fi + unset filelist tidy_install create_package $pkgname restore_package_variables pkgdir="${pkgdir%/*}" done pkgname=${pkgname_backup[@]} + leftover=$(find $tmpdir ! -type d) + if (( ${#leftover[*]} != 0 )) { + warning "$(gettext "Files leftover during split packaging")" + fi } The only hard bit that remains is creating the correct directory structure for the files to be moved into. I leave that for someone to finish... Allan
On 20 June 2012 14:58, Allan McRae <allan@archlinux.org> wrote:
On 20/06/12 22:07, Emil Renner Berthing wrote:
Hi,
When creating split packages I always wished one could just do make install in one of the package functions and then directly move the files belonging to other packages off to their respective pkgdirs.
To do this you make a big assumption.... The only guarantee makepkg has about folder locations is that the sources will be found in $srcdir and that $pkgdir will point at the directory containing the package files during its package function. So how are you going to move the files from one package directory to another one in an unknown location? The directory layout has changed before and possibly will again (particularly when splitting debug symbols to their own package happens...).
Yes, this only works if you can trust all the pkgdirs are created as subdirs of the same directory (as they are now). I had another approach lined up if you didn't like this assumption, but I thought I'd start with the least invasive version ;)
So instead, lets deal with this properly. I mentioned this recently on the mailing list but did not go into details. So here goes an example PKGBUILD snippet:
[...] Cool, this is very much what I had imagined only it goes even further. I like it. Thumbs up from here. /Emil
participants (2)
-
Allan McRae
-
Emil Renner Berthing