[pacman-dev] [PATCH] Create split package dirs first
Allan McRae
allan at archlinux.org
Wed Jun 20 08:58:48 EDT 2012
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
More information about the pacman-dev
mailing list