1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-09 04:57:59 -05:00

makepkg: add pkgbase variable

The pkgbase variable is added to improve informational output and
source package naming when using split packages.  Defaults to
${pkgname[0]} if not set.

Also:
 - move splitpkg detection to after pkgname presence is verified
 - add "cd" line to package_foo() functions in splitpkg proto

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2009-03-06 18:28:47 +10:00
parent 9519d22df7
commit 7df0d048d1
2 changed files with 28 additions and 23 deletions

View File

@ -5,6 +5,7 @@
# Contributor: Your Name <youremail@domain.com> # Contributor: Your Name <youremail@domain.com>
pkgname=('pkg1' 'pkg2') pkgname=('pkg1' 'pkg2')
pkgbase=('pkg')
pkgver=VERSION pkgver=VERSION
pkgrel=1 pkgrel=1
pkgdesc="" pkgdesc=""
@ -20,12 +21,12 @@ replaces=()
backup=() backup=()
options=() options=()
install= install=
source=($pkgname-$pkgver.tar.gz) source=($pkgbase-$pkgver.tar.gz)
noextract=() noextract=()
md5sums=() #generate with 'makepkg -g' md5sums=() #generate with 'makepkg -g'
build() { build() {
cd "$srcdir/$pkgname-$pkgver" cd "$srcdir/$pkgbase-$pkgver"
./configure --prefix=/usr ./configure --prefix=/usr
make || return 1 make || return 1
} }
@ -44,6 +45,7 @@ package_pkg1() {
options=() options=()
install= install=
cd "$srcdir/$pkgbase-$pkgver"
make DESTDIR="$pkgdir/" install-pkg1 make DESTDIR="$pkgdir/" install-pkg1
} }
@ -51,5 +53,6 @@ package_pkg2() {
# options and directives overrides # options and directives overrides
pkgdesc="" pkgdesc=""
cd "$srcdir/$pkgbase-$pkgver"
make DESTDIR="$pkgdir/" install-pkg2 make DESTDIR="$pkgdir/" install-pkg2
} }

View File

@ -689,7 +689,7 @@ run_build() {
local ret=0 local ret=0
if [ "$LOGGING" -eq 1 ]; then if [ "$LOGGING" -eq 1 ]; then
BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log" BUILDLOG="${startdir}/${pkgbase}-${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
@ -997,15 +997,15 @@ create_srcpackage() {
fi fi
msg "$(gettext "Creating source package...")" msg "$(gettext "Creating source package...")"
local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)" local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
mkdir "${srclinks}"/${pkgname} mkdir "${srclinks}"/${pkgbase}
msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgname}/" ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgbase}/"
if [ -n "$install" ]; then if [ -n "$install" ]; then
if [ -f $install ]; then if [ -f $install ]; then
msg2 "$(gettext "Adding install script...")" msg2 "$(gettext "Adding install script...")"
ln -s "${startdir}/$install" "${srclinks}/${pkgname}/" ln -s "${startdir}/$install" "${srclinks}/${pkgbase}/"
else else
error "$(gettext "Install script %s not found.")" "$install" error "$(gettext "Install script %s not found.")" "$install"
fi fi
@ -1013,7 +1013,7 @@ create_srcpackage() {
if [ -f ChangeLog ]; then if [ -f ChangeLog ]; then
msg2 "$(gettext "Adding %s...")" "ChangeLog" msg2 "$(gettext "Adding %s...")" "ChangeLog"
ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgname}" ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgbase}"
fi fi
local netfile local netfile
@ -1021,10 +1021,10 @@ create_srcpackage() {
local file=$(get_filename "$netfile") local file=$(get_filename "$netfile")
if [ -f "$netfile" ]; then if [ -f "$netfile" ]; then
msg2 "$(gettext "Adding %s...")" "$netfile" msg2 "$(gettext "Adding %s...")" "$netfile"
ln -s "${startdir}/$netfile" "${srclinks}/${pkgname}" ln -s "${startdir}/$netfile" "${srclinks}/${pkgbase}"
elif [ "$SOURCEONLY" -eq 2 -a -f "$SRCDEST/$file" ]; then elif [ "$SOURCEONLY" -eq 2 -a -f "$SRCDEST/$file" ]; then
msg2 "$(gettext "Adding %s...")" "$file" msg2 "$(gettext "Adding %s...")" "$file"
ln -s "$SRCDEST/$file" "${srclinks}/${pkgname}/" ln -s "$SRCDEST/$file" "${srclinks}/${pkgbase}/"
fi fi
done done
@ -1036,12 +1036,12 @@ create_srcpackage() {
"$SRCEXT" ;; "$SRCEXT" ;;
esac esac
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" local pkg_file="$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}"
# tar it up # tar it up
msg2 "$(gettext "Compressing source package...")" msg2 "$(gettext "Compressing source package...")"
cd "${srclinks}" cd "${srclinks}"
if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgname}; then if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgbase}; then
error "$(gettext "Failed to create source package file.")" error "$(gettext "Failed to create source package file.")"
exit 1 # TODO: error code exit 1 # TODO: error code
fi fi
@ -1473,9 +1473,9 @@ if [ "$ASROOT" -eq 0 \
fi fi
fi fi
unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
unset replaces depends conflicts backup source install build makedepends unset md5sums replaces depends conflicts backup source install build
unset optdepends options noextract unset makedepends optdepends options noextract
if [ ! -f "$BUILDSCRIPT" ]; then if [ ! -f "$BUILDSCRIPT" ]; then
if [ -t 0 ]; then if [ -t 0 ]; then
@ -1507,10 +1507,6 @@ if [ "$(type -t package)" = "function" ]; then
PKGFUNC=1 PKGFUNC=1
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"
@ -1537,9 +1533,11 @@ if [ "$arch" = 'any' ]; then
CARCH='any' CARCH='any'
fi fi
pkgbase=${pkgbase:-${pkgname[0]}}
if ! in_array $CARCH ${arch[@]}; then if ! in_array $CARCH ${arch[@]}; then
if [ "$IGNOREARCH" -eq 0 ]; then if [ "$IGNOREARCH" -eq 0 ]; then
error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH" error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT" plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
plain "$(gettext "such as arch=('%s').")" "$CARCH" plain "$(gettext "such as arch=('%s').")" "$CARCH"
exit 1 exit 1
@ -1585,6 +1583,10 @@ unset valid_options opt known kopt
devel_check devel_check
devel_update devel_update
if [ "${#pkgname[@]}" -gt "1" ]; then
SPLITPKG=1
fi
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \ if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \
-a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then
if [ "$INSTALL" -eq 1 ]; then if [ "$INSTALL" -eq 1 ]; then
@ -1626,17 +1628,17 @@ if [ "$INFAKEROOT" -eq 1 ]; then
exit 0 # $E_OK exit 0 # $E_OK
fi fi
msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" msg "$(gettext "Making package: %s")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
# if we are creating a source-only package, go no further # if we are creating a source-only package, go no further
if [ "$SOURCEONLY" -ne 0 ]; then if [ "$SOURCEONLY" -ne 0 ]; then
if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \ if [ -f "$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}" \
-a "$FORCE" -eq 0 ]; then -a "$FORCE" -eq 0 ]; then
error "$(gettext "A package has already been built. (use -f to overwrite)")" error "$(gettext "A package has already been built. (use -f to overwrite)")"
exit 1 exit 1
fi fi
create_srcpackage create_srcpackage
msg "$(gettext "Source package created: %s")" "$pkgname ($(date))" msg "$(gettext "Source package created: %s")" "$pkgbase ($(date))"
exit 0 exit 0
fi fi
@ -1750,7 +1752,7 @@ else
fi fi
fi fi
msg "$(gettext "Finished making: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" msg "$(gettext "Finished making: %s")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))"
install_package install_package