mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
makepkg: add optional package function
This patch allows us to split the building and packaging stages of a PKGBUILD and minimize fakeroot usage. This can be done with less code duplication (run_build and run_package look quite similiar) but the run_package function will be where the package splitting logic is implemented in the future. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
219cb2eaac
commit
08034ceb17
@ -256,6 +256,14 @@ If you create any variables of your own in the build function, it is
|
|||||||
recommended to use the bash `local` keyword to scope the variable to inside
|
recommended to use the bash `local` keyword to scope the variable to inside
|
||||||
the build function.
|
the build function.
|
||||||
|
|
||||||
|
package() 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
|
||||||
|
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
|
||||||
|
run as the user calling makepkg.
|
||||||
|
|
||||||
Install/Upgrade/Remove Scripting
|
Install/Upgrade/Remove Scripting
|
||||||
--------------------------------
|
--------------------------------
|
||||||
Pacman has the ability to store and execute a package-specific script when it
|
Pacman has the ability to store and execute a package-specific script when it
|
||||||
|
@ -682,7 +682,7 @@ run_build() {
|
|||||||
|
|
||||||
local ret=0
|
local ret=0
|
||||||
if [ "$LOGGING" = "1" ]; then
|
if [ "$LOGGING" = "1" ]; then
|
||||||
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log"
|
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log"
|
||||||
if [ -f "$BUILDLOG" ]; then
|
if [ -f "$BUILDLOG" ]; then
|
||||||
local i=1
|
local i=1
|
||||||
while true; do
|
while true; do
|
||||||
@ -710,6 +710,46 @@ run_build() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_package() {
|
||||||
|
# clear user-specified makeflags if requested
|
||||||
|
if [ "$(check_option makeflags)" = "n" ]; then
|
||||||
|
MAKEFLAGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "$(gettext "Starting package()...")"
|
||||||
|
cd "$srcdir"
|
||||||
|
|
||||||
|
# ensure all necessary build variables are exported
|
||||||
|
export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
|
||||||
|
|
||||||
|
local ret=0
|
||||||
|
if [ "$LOGGING" = "1" ]; then
|
||||||
|
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-package.log"
|
||||||
|
if [ -f "$BUILDLOG" ]; then
|
||||||
|
local i=1
|
||||||
|
while true; do
|
||||||
|
if [ -f "$BUILDLOG.$i" ]; then
|
||||||
|
i=$(($i +1))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
mv "$BUILDLOG" "$BUILDLOG.$i"
|
||||||
|
fi
|
||||||
|
|
||||||
|
package 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
|
||||||
|
else
|
||||||
|
package 2>&1 || ret=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $ret -gt 0 ]; then
|
||||||
|
error "$(gettext "Packaging Failed.")"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
remove_deps
|
||||||
|
exit 2 # $E_BUILD_FAILED
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
tidy_install() {
|
tidy_install() {
|
||||||
cd "$pkgdir"
|
cd "$pkgdir"
|
||||||
msg "$(gettext "Tidying install...")"
|
msg "$(gettext "Tidying install...")"
|
||||||
@ -1570,7 +1610,11 @@ fi
|
|||||||
# Run the bare minimum in fakeroot
|
# Run the bare minimum in fakeroot
|
||||||
if [ "$INFAKEROOT" = "1" ]; then
|
if [ "$INFAKEROOT" = "1" ]; then
|
||||||
if [ "$REPKG" = "0" ]; then
|
if [ "$REPKG" = "0" ]; then
|
||||||
|
if [ "$(type -t package)" != "function" ]; then
|
||||||
run_build
|
run_build
|
||||||
|
else
|
||||||
|
run_package
|
||||||
|
fi
|
||||||
tidy_install
|
tidy_install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1662,11 +1706,20 @@ else
|
|||||||
if [ "$REPKG" = "0" ]; then
|
if [ "$REPKG" = "0" ]; then
|
||||||
devel_update
|
devel_update
|
||||||
run_build
|
run_build
|
||||||
|
if [ "$(type -t package)" == "function" ]; then
|
||||||
|
run_package
|
||||||
|
fi
|
||||||
tidy_install
|
tidy_install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_package
|
create_package
|
||||||
else
|
else
|
||||||
|
if [ "$(type -t package)" == "function" ]; then
|
||||||
|
devel_update
|
||||||
|
run_build
|
||||||
|
cd "$startdir"
|
||||||
|
fi
|
||||||
|
|
||||||
msg "$(gettext "Entering fakeroot environment...")"
|
msg "$(gettext "Entering fakeroot environment...")"
|
||||||
|
|
||||||
if [ "$newpkgver" != "" ]; then
|
if [ "$newpkgver" != "" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user