1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

makepkg: allow the use of only a package() function

For some packages, generally the 'any' arch ones, a build step is not
required and therefore can be skipped. In these cases, a package()
function without a build() one is sufficient.

As a side effect, this commit makes meta packages without any function
at all in the PKGBUILD possible.

Fixes FS#15147.

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Cedric Staniewski 2009-10-27 12:56:13 +01:00 committed by Dan McGee
parent 564352c4a2
commit 4d2ec3751c
2 changed files with 19 additions and 10 deletions

View File

@ -233,10 +233,10 @@ name. The syntax is: `source=('filename::url')`.
build() Function build() Function
---------------- ----------------
In addition to the above directives, the build() bash function comprises the In addition to the above directives, the optional build() bash function usually
remainder of the PKGBUILD. This is directly sourced and executed by makepkg, so comprises the remainder of the PKGBUILD. This is directly sourced and executed by
anything that bash or the system has available is available for use here. Be makepkg, so anything that bash or the system has available is available for use
sure any exotic commands used are covered by `makedepends`. here. Be sure any exotic commands used are covered by `makedepends`.
All of the above variables such as `pkgname` and `pkgver` are available for use All of the above variables such as `pkgname` and `pkgver` are available for use
in the build function. In addition, makepkg defines three variables for your in the build function. In addition, makepkg defines three variables for your
@ -263,8 +263,8 @@ package() Function
An optional package() function can be specified in addition to the build() function. An optional package() function can be specified in addition to the build() function.
This function is run immediately after the build() function. When specified in This function is run immediately after the build() function. When specified in
combination with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot combination with the fakeroot BUILDENV option in linkman:makepkg.conf[5], fakeroot
usage will be limited to running the packaging stage. The build() function will be usage will be limited to running the packaging stage. An existing build() function
run as the user calling makepkg. will be run as the user calling makepkg.
Package Splitting Package Splitting
----------------- -----------------

View File

@ -70,6 +70,7 @@ LOGGING=0
SOURCEONLY=0 SOURCEONLY=0
IGNOREARCH=0 IGNOREARCH=0
HOLDVER=0 HOLDVER=0
BUILDFUNC=0
PKGFUNC=0 PKGFUNC=0
SPLITPKG=0 SPLITPKG=0
@ -137,7 +138,9 @@ clean_up() {
rm -rf "$pkgdir" "$srcdir" rm -rf "$pkgdir" "$srcdir"
if [[ -n $pkgbase ]]; then if [[ -n $pkgbase ]]; then
# Can't do this unless the BUILDSCRIPT has been sourced. # Can't do this unless the BUILDSCRIPT has been sourced.
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* if (( BUILDFUNC )); then
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"*
fi
if (( PKGFUNC )); then if (( PKGFUNC )); then
rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"*
elif (( SPLITPKG )); then elif (( SPLITPKG )); then
@ -1709,6 +1712,12 @@ if (( ${#pkgname[@]} > 1 )); then
SPLITPKG=1 SPLITPKG=1
fi fi
# test for available PKGBUILD functions
# The exclamation mark is required here to avoid triggering the ERR trap when
# a tested function does not exist.
if [[ $(! type -t build) = "function" ]]; then
BUILDFUNC=1
fi
if [ "$(type -t package)" = "function" ]; then if [ "$(type -t package)" = "function" ]; then
PKGFUNC=1 PKGFUNC=1
elif [ $SPLITPKG -eq 0 -a "$(type -t package_${pkgname})" = "function" ]; then elif [ $SPLITPKG -eq 0 -a "$(type -t package_${pkgname})" = "function" ]; then
@ -1764,7 +1773,7 @@ fi
if (( INFAKEROOT )); then if (( INFAKEROOT )); then
if (( ! SPLITPKG )); then if (( ! SPLITPKG )); then
if (( ! PKGFUNC )); then if (( ! PKGFUNC )); then
if (( ! REPKG )); then if (( BUILDFUNC && ! REPKG )); then
run_build run_build
tidy_install tidy_install
fi fi
@ -1874,7 +1883,7 @@ else
if [[ $(check_buildenv fakeroot) != "y" ]] || (( EUID == 0 )); then if [[ $(check_buildenv fakeroot) != "y" ]] || (( EUID == 0 )); then
if (( ! REPKG )); then if (( ! REPKG )); then
devel_update devel_update
run_build (( BUILDFUNC )) && run_build
fi fi
if (( ! SPLITPKG )); then if (( ! SPLITPKG )); then
if (( PKGFUNC )); then if (( PKGFUNC )); then
@ -1899,7 +1908,7 @@ else
else else
if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then
devel_update devel_update
run_build (( BUILDFUNC )) && run_build
cd "$startdir" cd "$startdir"
fi fi