Mercurial > vpk
changeset 203:c8239d2eee78
build: support split packages
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 03 Aug 2021 14:16:20 +0200 |
parents | 8032b5bfafbe |
children | 9c538f866e67 |
files | exec/build.sh vpk.recipe.7.in |
diffstat | 2 files changed, 67 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/exec/build.sh Tue Aug 03 12:24:51 2021 +0200 +++ b/exec/build.sh Tue Aug 03 14:16:20 2021 +0200 @@ -22,6 +22,8 @@ build_binary=1 build_source=1 +trap "cleanup" EXIT INT TERM + # # cleanup # @@ -307,13 +309,16 @@ # process() ( - trap "cleanup; exit 1" TERM INT QUIT - destdir=$STAGEDIR/$PKGNAME rm -rf $destdir mkdir -p $destdir + for s in $PKGSPLIT; do + rm -rf $STAGEDIR/$PKGNAME-$s + mkdir -p $STAGEDIR/$PKGNAME-$s + done + # # Don't process the build in a subshell because the set -e would be # canceled if the process appears in a conditional. @@ -333,8 +338,6 @@ # Create the source package in $OUTDIR. write_source() ( - trap "cleanup; exit 1" INT TERM QUIT - file=$OUTDIR/source/$(vpk_source_name) cd .. @@ -346,24 +349,43 @@ # # write_binary # -# Create binary package in $OUTDIR +# Create package according to the current global variables PKG*. # write_binary() -( - trap "cleanup; exit 1" INT TERM QUIT - +{ # Package filenames. stagedir=$STAGEDIR/$PKGNAME file=$OUTDIR/$(vpk_arch)/$(vpk_binary_name) # We move into the stage directory to skip leading "./" in tar. + mkmeta cd $stagedir vpk_compress $file * rm -rf $stagedir - rmdir $STAGEDIR > /dev/null 2>&1 vpk_fmt "print.awk" "info|written %s.%s\n" $file $(vpk_compress_extension) -) +} + +# +# write_binaries +# +# Create binary package in $OUTDIR +# +write_binaries() +{ + write_binary + + for s in $PKGSPLIT; do + # Override for vpk_binary_name. + PKGNAME=$PKGNAME-$s + PKGSUMMARY="$PKGSUMMARY ($s split package)" + + # Override depends if defined. + eval PKGDEPENDS=\$PKGDEPENDS_$(printf "$s" | tr "[:lower:]" "[:upper:]") + + write_binary + done +} out="" err="" @@ -402,13 +424,12 @@ vpk_load_script || exit 1 +if [ $build_source -eq 1 ]; then + write_source +fi + if [ $build_binary -eq 1 ]; then prepare process "$out" "$err" || exit 1 - mkmeta - write_binary + write_binaries fi - -if [ $build_source -eq 1 ]; then - write_source -fi
--- a/vpk.recipe.7.in Tue Aug 03 12:24:51 2021 +0200 +++ b/vpk.recipe.7.in Tue Aug 03 14:16:20 2021 +0200 @@ -114,6 +114,9 @@ .It optional Dependency is not strictly required. .El +.Pp +This variable can also be redefined for split packages (see +.Xr PKGSPLIT ) .\" PKGOPTIONS .It Va PKGOPTIONS No (list) A list of options that package supports. The recommandation is to use uppercase @@ -159,6 +162,33 @@ (i.e. without a leading /). .Pp It is also recommended to list init scripts. +.\" PKGSPLIT +.It Va PKGSPLIT No (list) +List of split binary packages to create from this parent package. +.Pp +This feature should be considered as last resort because it's against Vanilla +Linux principles. It should be used on monolithic packages that provides both +large development tools and files with their libraries (e.g. llvm). +.Pp +Any value in this list will create additional binary packages in the form +.Va PKGNAME-<s> +where +.Va s +is split package to build. +.Pp +The recipe file must then create any files under +.Va DESTDIR-<s> +during the build process. +.Pp +Some variables may be redefined specifically for this subpackage (e.g. +.Va PKGDEPENDS ) +to change their meanings. It must be declared in the form +.Va VARIABLE_<S> +where +.Va S +is the uppercase value from the +.Va PKGSPLIT +list. .El .\" ADDITIONAL FILES .Sh ADDITIONAL FILES