mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-03 10:51:47 -05:00
Merge branch 'am/splitpkg'
* am/splitpkg: makepkg: implement creation of split packages makepkg: Optional argument for run_package and create_package makepkg: hack around tee in run_package function makepkg: add functions for backup and restore of package fields makepkg: add optional package function makepkg: Add PKGBUILD-split.proto
This commit is contained in:
commit
3d49d88009
@ -12,7 +12,7 @@ EXTRA_DIST = HACKING
|
|||||||
|
|
||||||
# Sample makepkg prototype files
|
# Sample makepkg prototype files
|
||||||
pkgdatadir = ${datadir}/${PACKAGE}
|
pkgdatadir = ${datadir}/${PACKAGE}
|
||||||
dist_pkgdata_DATA = PKGBUILD.proto proto.install ChangeLog.proto
|
dist_pkgdata_DATA = PKGBUILD.proto PKGBUILD-split.proto proto.install ChangeLog.proto
|
||||||
|
|
||||||
# run the pactest test suite and vercmp tests
|
# run the pactest test suite and vercmp tests
|
||||||
check-local: pactest src/pacman src/util
|
check-local: pactest src/pacman src/util
|
||||||
|
55
PKGBUILD-split.proto
Normal file
55
PKGBUILD-split.proto
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# This is an example of a PKGBUILD for splitting packages. Use this as a
|
||||||
|
# start to creating your own, and remove these comments. For more information,
|
||||||
|
# see 'man PKGBUILD'. NOTE: Please fill out the license field for your package!
|
||||||
|
# If it is unknown, then please put 'unknown'.
|
||||||
|
|
||||||
|
# Contributor: Your Name <youremail@domain.com>
|
||||||
|
pkgname=('pkg1' 'pkg2')
|
||||||
|
pkgver=VERSION
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc=""
|
||||||
|
arch=()
|
||||||
|
url=""
|
||||||
|
license=('GPL')
|
||||||
|
groups=()
|
||||||
|
depends=()
|
||||||
|
makedepends=()
|
||||||
|
provides=()
|
||||||
|
conflicts=()
|
||||||
|
replaces=()
|
||||||
|
backup=()
|
||||||
|
options=()
|
||||||
|
install=
|
||||||
|
source=($pkgname-$pkgver.tar.gz)
|
||||||
|
noextract=()
|
||||||
|
md5sums=() #generate with 'makepkg -g'
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd "$srcdir/$pkgname-$pkgver"
|
||||||
|
./configure --prefix=/usr
|
||||||
|
make || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
package_pkg1() {
|
||||||
|
# options and directives that can be overridden
|
||||||
|
pkgdesc=""
|
||||||
|
license=()
|
||||||
|
groups=()
|
||||||
|
depends=()
|
||||||
|
optdepends=()
|
||||||
|
provides=()
|
||||||
|
conflicts=()
|
||||||
|
replaces=()
|
||||||
|
backup=()
|
||||||
|
options=()
|
||||||
|
install=
|
||||||
|
|
||||||
|
make DESTDIR="$pkgdir/" install-pkg1
|
||||||
|
}
|
||||||
|
|
||||||
|
package_pkg2() {
|
||||||
|
# options and directives overrides
|
||||||
|
pkgdesc=""
|
||||||
|
|
||||||
|
make DESTDIR="$pkgdir/" install-pkg2
|
||||||
|
}
|
@ -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
|
||||||
|
@ -42,9 +42,12 @@ BUILDSCRIPT='@BUILDSCRIPT@'
|
|||||||
startdir="$PWD"
|
startdir="$PWD"
|
||||||
srcdir="$startdir/src"
|
srcdir="$startdir/src"
|
||||||
pkgdir="$startdir/pkg"
|
pkgdir="$startdir/pkg"
|
||||||
|
|
||||||
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
|
packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge')
|
||||||
other_options=('ccache' 'distcc' 'makeflags' 'force')
|
other_options=('ccache' 'distcc' 'makeflags' 'force')
|
||||||
readonly -a packaging_options other_options
|
splitpkg_overrides=('pkgdesc' 'license' 'groups' 'depends' 'optdepends' 'provides' \
|
||||||
|
'conflicts' 'replaces' 'backup' 'options' 'install')
|
||||||
|
readonly -a packaging_options other_options splitpkg_overrides
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
ASROOT=0
|
ASROOT=0
|
||||||
@ -64,6 +67,7 @@ LOGGING=0
|
|||||||
SOURCEONLY=0
|
SOURCEONLY=0
|
||||||
IGNOREARCH=0
|
IGNOREARCH=0
|
||||||
HOLDVER=0
|
HOLDVER=0
|
||||||
|
SPLITPKG=0
|
||||||
|
|
||||||
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
||||||
# when dealing with svn/cvs/etc PKGBUILDs.
|
# when dealing with svn/cvs/etc PKGBUILDs.
|
||||||
@ -682,7 +686,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 +714,63 @@ run_build() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_package() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
pkgfunc="package"
|
||||||
|
nameofpkg="$pkgname"
|
||||||
|
else
|
||||||
|
pkgfunc="package_$1"
|
||||||
|
nameofpkg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clear user-specified makeflags if requested
|
||||||
|
if [ "$(check_option makeflags)" = "n" ]; then
|
||||||
|
MAKEFLAGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "$(gettext "Starting %s()...")" "$pkgfunc"
|
||||||
|
cd "$srcdir"
|
||||||
|
|
||||||
|
# ensure all necessary build variables are exported
|
||||||
|
export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
|
||||||
|
|
||||||
|
local ret=0
|
||||||
|
if [ "$LOGGING" = "1" ]; then
|
||||||
|
BUILDLOG="${startdir}/${nameofpkg}-${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
|
||||||
|
|
||||||
|
# ensure overridden package variables suvrive tee with split packages
|
||||||
|
logpipe=$(mktemp -u "$startdir/logpipe.XXXXXXXX")
|
||||||
|
mknod "$logpipe" p
|
||||||
|
exec 3>&1
|
||||||
|
tee "$BUILDLOG" < "$logpipe" &
|
||||||
|
exec 1>"$logpipe" 2>"$logpipe"
|
||||||
|
$pkgfunc 2>&1 || ret=$?
|
||||||
|
sync
|
||||||
|
exec 1>&3 2>&3 3>&-
|
||||||
|
rm "$logpipe"
|
||||||
|
else
|
||||||
|
$pkgfunc 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...")"
|
||||||
@ -793,6 +854,12 @@ tidy_install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_package() {
|
create_package() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
nameofpkg="$pkgname"
|
||||||
|
else
|
||||||
|
nameofpkg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "$pkgdir" ]; then
|
if [ ! -d "$pkgdir" ]; then
|
||||||
error "$(gettext "Missing pkg/ directory.")"
|
error "$(gettext "Missing pkg/ directory.")"
|
||||||
plain "$(gettext "Aborting...")"
|
plain "$(gettext "Aborting...")"
|
||||||
@ -817,7 +884,7 @@ create_package() {
|
|||||||
echo "# using $(fakeroot -v)" >>.PKGINFO
|
echo "# using $(fakeroot -v)" >>.PKGINFO
|
||||||
fi
|
fi
|
||||||
echo "# $(LC_ALL=C date -u)" >>.PKGINFO
|
echo "# $(LC_ALL=C date -u)" >>.PKGINFO
|
||||||
echo "pkgname = $pkgname" >>.PKGINFO
|
echo "pkgname = $nameofpkg" >>.PKGINFO
|
||||||
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
|
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
|
||||||
echo "pkgdesc = $pkgdesc" >>.PKGINFO
|
echo "pkgdesc = $pkgdesc" >>.PKGINFO
|
||||||
echo "url = $url" >>.PKGINFO
|
echo "url = $url" >>.PKGINFO
|
||||||
@ -901,7 +968,7 @@ create_package() {
|
|||||||
"$PKGEXT" ;;
|
"$PKGEXT" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
|
local pkg_file="$PKGDEST/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
|
||||||
|
|
||||||
# when fileglobbing, we want * in an empty directory to expand to
|
# when fileglobbing, we want * in an empty directory to expand to
|
||||||
# the null string rather than itself
|
# the null string rather than itself
|
||||||
@ -1139,6 +1206,24 @@ devel_update() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup_package_variables() {
|
||||||
|
for var in ${splitpkg_overrides[@]}; do
|
||||||
|
indirect="${var}_backup"
|
||||||
|
eval "${indirect}=\"${!var}\""
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_package_variables() {
|
||||||
|
for var in ${splitpkg_overrides[@]}; do
|
||||||
|
indirect="${var}_backup"
|
||||||
|
if [ -n "${!indirect}" ]; then
|
||||||
|
eval "${var}=\"${!indirect}\""
|
||||||
|
else
|
||||||
|
unset ${var}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# getopt like parser
|
# getopt like parser
|
||||||
parse_options() {
|
parse_options() {
|
||||||
local short_options=$1; shift;
|
local short_options=$1; shift;
|
||||||
@ -1481,6 +1566,10 @@ if [ "$GENINTEG" = "1" ]; then
|
|||||||
exit 0 # $E_OK
|
exit 0 # $E_OK
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${#pkgname[@]}" -gt "1" ]; then
|
||||||
|
SPLITPKG=1
|
||||||
|
fi
|
||||||
|
|
||||||
# check for no-no's in the build script
|
# check for no-no's in the build script
|
||||||
if [ -z "$pkgname" ]; then
|
if [ -z "$pkgname" ]; then
|
||||||
error "$(gettext "%s is not allowed to be empty.")" "pkgname"
|
error "$(gettext "%s is not allowed to be empty.")" "pkgname"
|
||||||
@ -1569,13 +1658,29 @@ 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 [ "$SPLITPKG" = "0" ]; then
|
||||||
run_build
|
if [ "$REPKG" = "0" ]; then
|
||||||
tidy_install
|
if [ "$(type -t package)" != "function" ]; then
|
||||||
|
run_build
|
||||||
|
else
|
||||||
|
run_package
|
||||||
|
fi
|
||||||
|
tidy_install
|
||||||
|
fi
|
||||||
|
create_package
|
||||||
|
else
|
||||||
|
for pkg in ${pkgname[@]}; do
|
||||||
|
pkgdir="$pkgdir/$pkg"
|
||||||
|
mkdir -p "$pkgdir"
|
||||||
|
backup_package_variables
|
||||||
|
run_package $pkg
|
||||||
|
tidy_install
|
||||||
|
create_package $pkg
|
||||||
|
restore_package_variables
|
||||||
|
pkgdir="${pkgdir%/*}"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_package
|
|
||||||
|
|
||||||
msg "$(gettext "Leaving fakeroot environment.")"
|
msg "$(gettext "Leaving fakeroot environment.")"
|
||||||
exit 0 # $E_OK
|
exit 0 # $E_OK
|
||||||
fi
|
fi
|
||||||
@ -1659,14 +1764,37 @@ else
|
|||||||
|
|
||||||
# if we are root or if fakeroot is not enabled, then we don't use it
|
# if we are root or if fakeroot is not enabled, then we don't use it
|
||||||
if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then
|
if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then
|
||||||
if [ "$REPKG" = "0" ]; then
|
if [ "$SPLITPKG" = "0" ]; then
|
||||||
|
if [ "$REPKG" = "0" ]; then
|
||||||
|
devel_update
|
||||||
|
run_build
|
||||||
|
if [ "$(type -t package)" == "function" ]; then
|
||||||
|
run_package
|
||||||
|
fi
|
||||||
|
tidy_install
|
||||||
|
fi
|
||||||
|
create_package
|
||||||
|
else
|
||||||
devel_update
|
devel_update
|
||||||
run_build
|
run_build
|
||||||
tidy_install
|
for pkg in ${pkgname[@]}; do
|
||||||
|
pkgdir="$pkgdir/$pkg"
|
||||||
|
mkdir -p "$pkgdir"
|
||||||
|
backup_package_variables
|
||||||
|
run_package $pkg
|
||||||
|
tidy_install
|
||||||
|
create_package $pkg
|
||||||
|
restore_package_variables
|
||||||
|
pkgdir="${pkgdir%/*}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$(type -t package)" == "function" -o "$SPLITPKG" = "1" ]; then
|
||||||
|
devel_update
|
||||||
|
run_build
|
||||||
|
cd "$startdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create_package
|
|
||||||
else
|
|
||||||
msg "$(gettext "Entering fakeroot environment...")"
|
msg "$(gettext "Entering fakeroot environment...")"
|
||||||
|
|
||||||
if [ "$newpkgver" != "" ]; then
|
if [ "$newpkgver" != "" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user