xbps-src: revamped build_style.
By default now it's assumed that if $build_style is not set, the template uses 'custom-install' build, .e.g do_{build,configure,install}. If it's set, a helper with the same name with .sh extension will be sourced to set do_{build,configure,install} phases. The exception is "meta-template" which currently it must be set via build_style, probably will change in the future.
This commit is contained in:
parent
31452a3a22
commit
90204b7b28
9 changed files with 86 additions and 123 deletions
12
xbps-src/helpers/configure.sh
Normal file
12
xbps-src/helpers/configure.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# This helper is for templates using configure scripts (not generated
|
||||||
|
# by the GNU autotools).
|
||||||
|
#
|
||||||
|
|
||||||
|
do_configure() {
|
||||||
|
[ -z "$configure_script" ] && configure_script="./configure"
|
||||||
|
${configure_script} ${configure_args}
|
||||||
|
}
|
||||||
|
|
||||||
|
# configure scripts use make(1) to build/install.
|
||||||
|
. $XBPS_HELPERSDIR/gnu-makefile.sh
|
18
xbps-src/helpers/gnu-configure.sh
Normal file
18
xbps-src/helpers/gnu-configure.sh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#
|
||||||
|
# This helper is for templates using GNU configure script.
|
||||||
|
#
|
||||||
|
|
||||||
|
# This variable can be used for packages wanting to use common arguments
|
||||||
|
# to GNU configure scripts.
|
||||||
|
#
|
||||||
|
export CONFIGURE_SHARED_ARGS="--prefix=/usr --sysconfdir=/etc \
|
||||||
|
--infodir=/usr/share/info --mandir=/usr/share/man \
|
||||||
|
--localstatedir=/var"
|
||||||
|
|
||||||
|
do_configure() {
|
||||||
|
[ -z "$configure_script" ] && configure_script="./configure"
|
||||||
|
${configure_script} ${CONFIGURE_SHARED_ARGS} ${configure_args}
|
||||||
|
}
|
||||||
|
|
||||||
|
# GNU configure scripts use make(1) to build/install.
|
||||||
|
. $XBPS_HELPERSDIR/gnu-makefile.sh
|
26
xbps-src/helpers/gnu-makefile.sh
Normal file
26
xbps-src/helpers/gnu-makefile.sh
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#
|
||||||
|
# This helper is for templates using GNU Makefiles.
|
||||||
|
#
|
||||||
|
do_build() {
|
||||||
|
if [ -z "$make_cmd" ]; then
|
||||||
|
make_cmd=make
|
||||||
|
fi
|
||||||
|
if [ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ]; then
|
||||||
|
makejobs="-j$XBPS_MAKEJOBS"
|
||||||
|
fi
|
||||||
|
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
local target
|
||||||
|
|
||||||
|
if [ -z "$make_install_target" ]; then
|
||||||
|
target="DESTDIR=${DESTDIR} install"
|
||||||
|
else
|
||||||
|
target="${make_install_target}"
|
||||||
|
fi
|
||||||
|
if [ -z "$make_cmd" ]; then
|
||||||
|
make_cmd=make
|
||||||
|
fi
|
||||||
|
${make_cmd} ${make_install_args} ${target}
|
||||||
|
}
|
|
@ -4,17 +4,15 @@
|
||||||
#
|
#
|
||||||
# Required vars to be set by a template:
|
# Required vars to be set by a template:
|
||||||
#
|
#
|
||||||
# build_style=perl_module
|
# build_style=perl-module
|
||||||
#
|
#
|
||||||
# Optionally if the module needs more directories to be configured other
|
# Optionally if the module needs more directories to be configured other
|
||||||
# than $XBPS_BUILDDIR/$wrksrc, one can use (relative to $wrksrc):
|
# than $XBPS_BUILDDIR/$wrksrc, one can use (relative to $wrksrc):
|
||||||
#
|
#
|
||||||
# perl_configure_dirs="blob/bob foo/blah"
|
# perl_configure_dirs="blob/bob foo/blah"
|
||||||
#
|
#
|
||||||
|
do_configure() {
|
||||||
perl_module_build()
|
local perlmkf
|
||||||
{
|
|
||||||
local perlmkf=
|
|
||||||
|
|
||||||
if [ -z "$perl_configure_dirs" ]; then
|
if [ -z "$perl_configure_dirs" ]; then
|
||||||
perlmkf="$wrksrc/Makefile.PL"
|
perlmkf="$wrksrc/Makefile.PL"
|
||||||
|
@ -41,3 +39,6 @@ perl_module_build()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Perl modules use standard make(1) to install.
|
||||||
|
. ${XBPS_HELPERSDIR}/gnu-makefile.sh
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
#
|
#
|
||||||
# This helper is for templates installing python modules.
|
# This helper is for templates installing python modules.
|
||||||
#
|
#
|
||||||
|
do_build() {
|
||||||
do_build()
|
|
||||||
{
|
|
||||||
python setup.py build ${make_build_args}
|
python setup.py build ${make_build_args}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install()
|
do_install() {
|
||||||
{
|
|
||||||
if [ -z "$make_install_args" ]; then
|
if [ -z "$make_install_args" ]; then
|
||||||
make_install_args="--prefix=/usr --root=$DESTDIR"
|
make_install_args="--prefix=/usr --root=$DESTDIR"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -66,15 +66,11 @@ install_src_phase()
|
||||||
[ $? -eq 0 ] && touch -f $XBPS_PRE_INSTALL_DONE
|
[ $? -eq 0 ] && touch -f $XBPS_PRE_INSTALL_DONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Type of installation: custom, make or python.
|
# do_install()
|
||||||
if [ "$build_style" = "custom-install" ]; then
|
if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then
|
||||||
run_func do_install
|
. $XBPS_HELPERSDIR/${build_style}.sh
|
||||||
elif [ "$build_style" = "python-module" ]; then
|
|
||||||
. $XBPS_HELPERSDIR/python-module.sh
|
|
||||||
run_func do_install
|
|
||||||
else
|
|
||||||
run_func make_install
|
|
||||||
fi
|
fi
|
||||||
|
run_func do_install
|
||||||
|
|
||||||
cd ${wrksrc} || msg_error "can't change cwd to wrksrc!\n"
|
cd ${wrksrc} || msg_error "can't change cwd to wrksrc!\n"
|
||||||
|
|
||||||
|
@ -106,10 +102,7 @@ install_src_phase()
|
||||||
find ${DESTDIR} -depth -type d -exec rmdir 2>/dev/null {} \;
|
find ${DESTDIR} -depth -type d -exec rmdir 2>/dev/null {} \;
|
||||||
fi
|
fi
|
||||||
msg_normal "$pkgver: installed into destdir.\n"
|
msg_normal "$pkgver: installed into destdir.\n"
|
||||||
|
touch -f $XBPS_INSTALL_DONE
|
||||||
if [ "$build_style" != "custom-install" -a -z "$distfiles" ]; then
|
|
||||||
touch -f $XBPS_INSTALL_DONE
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build subpackages if found.
|
# Build subpackages if found.
|
||||||
|
@ -141,21 +134,6 @@ install_src_phase()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Installs a package via 'make install ...'.
|
|
||||||
#
|
|
||||||
make_install()
|
|
||||||
{
|
|
||||||
if [ -z "$make_install_target" ]; then
|
|
||||||
make_install_target="DESTDIR=${DESTDIR} install"
|
|
||||||
fi
|
|
||||||
[ -z "$make_cmd" ] && make_cmd=make
|
|
||||||
#
|
|
||||||
# Install package via make.
|
|
||||||
#
|
|
||||||
${make_cmd} ${make_install_target} ${make_install_args}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -z "$PKG_TMPLNAME" ] && exit 2
|
[ -z "$PKG_TMPLNAME" ] && exit 2
|
||||||
|
|
||||||
setup_tmpl $PKG_TMPLNAME
|
setup_tmpl $PKG_TMPLNAME
|
||||||
|
|
|
@ -27,25 +27,14 @@
|
||||||
# Runs the "build" phase for a pkg. This builds the binaries and other
|
# Runs the "build" phase for a pkg. This builds the binaries and other
|
||||||
# related stuff.
|
# related stuff.
|
||||||
#
|
#
|
||||||
do_make_build()
|
|
||||||
{
|
|
||||||
#
|
|
||||||
# Build package via make.
|
|
||||||
#
|
|
||||||
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
|
|
||||||
}
|
|
||||||
|
|
||||||
build_src_phase()
|
build_src_phase()
|
||||||
{
|
{
|
||||||
local f rval
|
local rval
|
||||||
|
|
||||||
[ -z $pkgname -o -z $version ] && return 1
|
[ -z $pkgname -o -z $version ] && return 1
|
||||||
|
|
||||||
#
|
# Skip this phase for meta-template style builds.
|
||||||
# Skip this phase for meta-template and only-install style builds.
|
[ "$build_style" = "meta-template" ] && return 0
|
||||||
#
|
|
||||||
[ "$build_style" = "meta-template" -o \
|
|
||||||
"$build_style" = "only-install" ] && return 0
|
|
||||||
|
|
||||||
[ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]\n"
|
[ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]\n"
|
||||||
|
|
||||||
|
@ -54,25 +43,18 @@ build_src_phase()
|
||||||
cd $build_wrksrc || return 1
|
cd $build_wrksrc || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$build_style" = "python-module" ]; then
|
|
||||||
make_cmd="python"
|
|
||||||
make_build_args="setup.py build"
|
|
||||||
else
|
|
||||||
[ -z "$make_cmd" ] && make_cmd=make
|
|
||||||
[ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ] && \
|
|
||||||
makejobs="-j$XBPS_MAKEJOBS"
|
|
||||||
fi
|
|
||||||
# Run pre_build func.
|
# Run pre_build func.
|
||||||
if [ ! -f $XBPS_PRE_BUILD_DONE ]; then
|
if [ ! -f $XBPS_PRE_BUILD_DONE ]; then
|
||||||
run_func pre_build
|
run_func pre_build
|
||||||
[ $? -eq 0 ] && touch -f $XBPS_PRE_BUILD_DONE
|
[ $? -eq 0 ] && touch -f $XBPS_PRE_BUILD_DONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$build_style" = "custom-install" ]; then
|
if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then
|
||||||
run_func do_build
|
. $XBPS_HELPERSDIR/${build_style}.sh
|
||||||
else
|
|
||||||
run_func do_make_build
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# do_build()
|
||||||
|
run_func do_build
|
||||||
rval=$?
|
rval=$?
|
||||||
|
|
||||||
# Run post_build func.
|
# Run post_build func.
|
||||||
|
@ -81,8 +63,6 @@ build_src_phase()
|
||||||
[ $? -eq 0 ] && touch -f $XBPS_POST_BUILD_DONE
|
[ $? -eq 0 ] && touch -f $XBPS_POST_BUILD_DONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset makejobs
|
|
||||||
|
|
||||||
[ "$rval" -eq 0 ] && touch -f $XBPS_BUILD_DONE
|
[ "$rval" -eq 0 ] && touch -f $XBPS_BUILD_DONE
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -28,52 +28,14 @@
|
||||||
# other stuff required to be able to build binaries or such.
|
# other stuff required to be able to build binaries or such.
|
||||||
#
|
#
|
||||||
|
|
||||||
# This variable can be used for packages wanting to use common arguments
|
|
||||||
# to GNU configure scripts.
|
|
||||||
#
|
|
||||||
export CONFIGURE_SHARED_ARGS="--prefix=/usr --sysconfdir=/etc \
|
|
||||||
--infodir=/usr/share/info --mandir=/usr/share/man \
|
|
||||||
--localstatedir=/var"
|
|
||||||
|
|
||||||
do_gnu_configure()
|
|
||||||
{
|
|
||||||
#
|
|
||||||
# Packages using GNU autoconf
|
|
||||||
#
|
|
||||||
${configure_script} ${CONFIGURE_SHARED_ARGS} ${configure_args}
|
|
||||||
}
|
|
||||||
|
|
||||||
do_nongnu_configure()
|
|
||||||
{
|
|
||||||
#
|
|
||||||
# Packages using custom configure scripts.
|
|
||||||
#
|
|
||||||
${configure_script} ${configure_args}
|
|
||||||
}
|
|
||||||
|
|
||||||
do_perl_configure()
|
|
||||||
{
|
|
||||||
#
|
|
||||||
# Packages that are perl modules and use Makefile.PL files.
|
|
||||||
# They are all handled by the helper perl-module.sh.
|
|
||||||
#
|
|
||||||
. $XBPS_HELPERSDIR/perl-module.sh
|
|
||||||
perl_module_build $pkgname
|
|
||||||
}
|
|
||||||
|
|
||||||
configure_src_phase()
|
configure_src_phase()
|
||||||
{
|
{
|
||||||
local f rval
|
local f rval
|
||||||
|
|
||||||
[ -z $pkgname ] && return 1
|
[ -z $pkgname ] && return 1
|
||||||
#
|
|
||||||
# Skip this phase for: meta-template, only-install,
|
# Skip this phase for meta-template style builds.
|
||||||
# gnu_makefile and python-module style builds.
|
[ "$build_style" = "meta-template" ] && return 0
|
||||||
#
|
|
||||||
[ "$build_style" = "meta-template" -o \
|
|
||||||
"$build_style" = "only-install" -o \
|
|
||||||
"$build_style" = "gnu_makefile" -o \
|
|
||||||
"$build_style" = "python-module" ] && return 0
|
|
||||||
|
|
||||||
cd $wrksrc || msg_error "unexistent build directory [$wrksrc].\n"
|
cd $wrksrc || msg_error "unexistent build directory [$wrksrc].\n"
|
||||||
|
|
||||||
|
@ -83,27 +45,16 @@ configure_src_phase()
|
||||||
[ $? -eq 0 ] && touch -f $XBPS_PRECONFIGURE_DONE
|
[ $? -eq 0 ] && touch -f $XBPS_PRECONFIGURE_DONE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$configure_script" ] && configure_script="./configure"
|
|
||||||
|
|
||||||
cd $wrksrc || return 1
|
cd $wrksrc || return 1
|
||||||
if [ -n "$build_wrksrc" ]; then
|
if [ -n "$build_wrksrc" ]; then
|
||||||
cd $build_wrksrc || return 1
|
cd $build_wrksrc || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$build_style" = "gnu_configure" ]; then
|
if [ -r $XBPS_HELPERSDIR/${build_style}.sh ]; then
|
||||||
run_func do_gnu_configure
|
. $XBPS_HELPERSDIR/${build_style}.sh
|
||||||
elif [ "$build_style" = "configure" ]; then
|
|
||||||
run_func do_nongnu_configure
|
|
||||||
elif [ "$build_style" = "perl-module" ]; then
|
|
||||||
run_func do_perl_configure
|
|
||||||
elif [ "$build_style" = "custom-install" ]; then
|
|
||||||
run_func do_configure
|
|
||||||
else
|
|
||||||
#
|
|
||||||
# Unknown build_style type won't work :-)
|
|
||||||
#
|
|
||||||
msg_error "$pkgver: unknown build_style [$build_style]\n"
|
|
||||||
fi
|
fi
|
||||||
|
# run do_configure()
|
||||||
|
run_func do_configure
|
||||||
rval=$?
|
rval=$?
|
||||||
|
|
||||||
# Run post_configure func.
|
# Run post_configure func.
|
||||||
|
|
|
@ -47,7 +47,7 @@ info_tmpl()
|
||||||
echo "maintainer: $maintainer"
|
echo "maintainer: $maintainer"
|
||||||
[ -n "$homepage" ] && echo "Upstream URL: $homepage"
|
[ -n "$homepage" ] && echo "Upstream URL: $homepage"
|
||||||
[ -n "$license" ] && echo "License(s): $license"
|
[ -n "$license" ] && echo "License(s): $license"
|
||||||
echo "build_style: $build_style"
|
[ -n "$build_style" ] && echo "build_style: $build_style"
|
||||||
for i in ${configure_args}; do
|
for i in ${configure_args}; do
|
||||||
[ -n "$i" ] && echo "configure_args: $i"
|
[ -n "$i" ] && echo "configure_args: $i"
|
||||||
done
|
done
|
||||||
|
@ -242,7 +242,7 @@ prepare_tmpl()
|
||||||
{
|
{
|
||||||
local REQ_VARS i found
|
local REQ_VARS i found
|
||||||
|
|
||||||
REQ_VARS="pkgname version build_style short_desc long_desc"
|
REQ_VARS="pkgname version short_desc long_desc"
|
||||||
|
|
||||||
if [ "$build_style" = "meta-template" ]; then
|
if [ "$build_style" = "meta-template" ]; then
|
||||||
nofetch=yes
|
nofetch=yes
|
||||||
|
|
Loading…
Add table
Reference in a new issue