From 7df0d048d1617df2c5472fd2edd6858b3117d52f Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Fri, 6 Mar 2009 18:28:47 +1000 Subject: 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 --- PKGBUILD-split.proto | 7 +++++-- scripts/makepkg.sh.in | 44 +++++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/PKGBUILD-split.proto b/PKGBUILD-split.proto index 35fb22b9..0baa4964 100644 --- a/PKGBUILD-split.proto +++ b/PKGBUILD-split.proto @@ -5,6 +5,7 @@ # Contributor: Your Name pkgname=('pkg1' 'pkg2') +pkgbase=('pkg') pkgver=VERSION pkgrel=1 pkgdesc="" @@ -20,12 +21,12 @@ replaces=() backup=() options=() install= -source=($pkgname-$pkgver.tar.gz) +source=($pkgbase-$pkgver.tar.gz) noextract=() md5sums=() #generate with 'makepkg -g' build() { - cd "$srcdir/$pkgname-$pkgver" + cd "$srcdir/$pkgbase-$pkgver" ./configure --prefix=/usr make || return 1 } @@ -44,6 +45,7 @@ package_pkg1() { options=() install= + cd "$srcdir/$pkgbase-$pkgver" make DESTDIR="$pkgdir/" install-pkg1 } @@ -51,5 +53,6 @@ package_pkg2() { # options and directives overrides pkgdesc="" + cd "$srcdir/$pkgbase-$pkgver" make DESTDIR="$pkgdir/" install-pkg2 } diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0aa8a9b1..3ff256f6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -689,7 +689,7 @@ run_build() { local ret=0 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 local i=1 while true; do @@ -997,15 +997,15 @@ create_srcpackage() { fi msg "$(gettext "Creating source package...")" local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)" - mkdir "${srclinks}"/${pkgname} + mkdir "${srclinks}"/${pkgbase} msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" - ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgname}/" + ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgbase}/" if [ -n "$install" ]; then if [ -f $install ]; then msg2 "$(gettext "Adding install script...")" - ln -s "${startdir}/$install" "${srclinks}/${pkgname}/" + ln -s "${startdir}/$install" "${srclinks}/${pkgbase}/" else error "$(gettext "Install script %s not found.")" "$install" fi @@ -1013,7 +1013,7 @@ create_srcpackage() { if [ -f ChangeLog ]; then msg2 "$(gettext "Adding %s...")" "ChangeLog" - ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgname}" + ln -s "${startdir}/ChangeLog" "${srclinks}/${pkgbase}" fi local netfile @@ -1021,10 +1021,10 @@ create_srcpackage() { local file=$(get_filename "$netfile") if [ -f "$netfile" ]; then 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 msg2 "$(gettext "Adding %s...")" "$file" - ln -s "$SRCDEST/$file" "${srclinks}/${pkgname}/" + ln -s "$SRCDEST/$file" "${srclinks}/${pkgbase}/" fi done @@ -1036,12 +1036,12 @@ create_srcpackage() { "$SRCEXT" ;; esac - local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" + local pkg_file="$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}" # tar it up msg2 "$(gettext "Compressing source package...")" 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.")" exit 1 # TODO: error code fi @@ -1473,9 +1473,9 @@ if [ "$ASROOT" -eq 0 \ fi fi -unset pkgname pkgver pkgrel pkgdesc url license groups provides md5sums -unset replaces depends conflicts backup source install build makedepends -unset optdepends options noextract +unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides +unset md5sums replaces depends conflicts backup source install build +unset makedepends optdepends options noextract if [ ! -f "$BUILDSCRIPT" ]; then if [ -t 0 ]; then @@ -1507,10 +1507,6 @@ if [ "$(type -t package)" = "function" ]; then PKGFUNC=1 fi -if [ "${#pkgname[@]}" -gt "1" ]; then - SPLITPKG=1 -fi - # check for no-no's in the build script if [ -z "$pkgname" ]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" @@ -1537,9 +1533,11 @@ if [ "$arch" = 'any' ]; then CARCH='any' fi +pkgbase=${pkgbase:-${pkgname[0]}} + if ! in_array $CARCH ${arch[@]}; 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 "such as arch=('%s').")" "$CARCH" exit 1 @@ -1585,6 +1583,10 @@ unset valid_options opt known kopt devel_check devel_update +if [ "${#pkgname[@]}" -gt "1" ]; then + SPLITPKG=1 +fi + if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \ -a "$FORCE" -eq 0 -a "$SOURCEONLY" -eq 0 -a "$NOBUILD" -eq 0 ]; then if [ "$INSTALL" -eq 1 ]; then @@ -1626,17 +1628,17 @@ if [ "$INFAKEROOT" -eq 1 ]; then exit 0 # $E_OK 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 [ "$SOURCEONLY" -ne 0 ]; then - if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \ + if [ -f "$PKGDEST/${pkgbase}-${pkgver}-${pkgrel}${SRCEXT}" \ -a "$FORCE" -eq 0 ]; then error "$(gettext "A package has already been built. (use -f to overwrite)")" exit 1 fi create_srcpackage - msg "$(gettext "Source package created: %s")" "$pkgname ($(date))" + msg "$(gettext "Source package created: %s")" "$pkgbase ($(date))" exit 0 fi @@ -1750,7 +1752,7 @@ else fi fi -msg "$(gettext "Finished making: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" +msg "$(gettext "Finished making: %s")" "$pkgbase $pkgver-$pkgrel $CARCH ($(date))" install_package -- cgit v1.1-4-g5e80 From 7a8ba5a978024228fa3b068fd77d778b44f47ae0 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 14 Mar 2009 23:51:58 +1000 Subject: Refactor testing for color message output Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3ff256f6..a8044896 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -69,6 +69,7 @@ IGNOREARCH=0 HOLDVER=0 PKGFUNC=0 SPLITPKG=0 +COLORMSG=0 # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call # when dealing with svn/cvs/etc PKGBUILDs. @@ -80,7 +81,7 @@ PACMAN_OPTS= plain() { local mesg=$1; shift - if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ $COLORMSG -eq 1 ]; then printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 else printf " ${mesg}\n" "$@" >&2 @@ -89,7 +90,7 @@ plain() { msg() { local mesg=$1; shift - if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ $COLORMSG -eq 1 ]; then printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 else printf "==> ${mesg}\n" "$@" >&2 @@ -98,7 +99,7 @@ msg() { msg2() { local mesg=$1; shift - if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ $COLORMSG -eq 1 ]; then printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 else printf " -> ${mesg}\n" "$@" >&2 @@ -107,7 +108,7 @@ msg2() { warning() { local mesg=$1; shift - if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ $COLORMSG -eq 1 ]; then printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 else printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 @@ -116,7 +117,7 @@ warning() { error() { local mesg=$1; shift - if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + if [ $COLORMSG -eq 1 ]; then printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 else printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 @@ -1382,6 +1383,11 @@ if [ -r ~/.makepkg.conf ]; then source ~/.makepkg.conf fi +# check if messages are to be printed using color +if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then + COLORMSG=1 +fi + # override settings with an environment variable for batch processing PKGDEST=${_PKGDEST:-$PKGDEST} PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined -- cgit v1.1-4-g5e80 From 4c27a776bd6287d6022a014d4d87ebe6ec6c75f9 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Wed, 25 Mar 2009 23:52:27 +1000 Subject: makepkg: adjust install_package for split packages Install all created packages when using the install option with package splitting. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index a8044896..95ee5200 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1052,11 +1052,22 @@ create_srcpackage() { install_package() { [ "$INSTALL" -eq 0 ] && return - msg "$(gettext "Installing package ${pkgname} with pacman -U...")" + + if [ "$SPLITPKG" -eq 0 ]; then + msg "$(gettext "Installing package ${pkgname} with pacman -U...")" + else + msg "$(gettext "Installing ${pkgbase} package group with pacman -U...")" + fi + + local pkglist + for pkg in ${pkgname[@]}; do + pkglist="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" + done + if [ "$ASROOT" -eq 0 ]; then - sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? + sudo pacman $PACMAN_OPTS -U ${pkglist} || exit $? else - pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? + pacman $PACMAN_OPTS -U ${pkglist} || exit $? fi } -- cgit v1.1-4-g5e80 From 7370fd595bc0447e7c17135e3a27cc3ae64015d4 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 26 Mar 2009 01:29:15 +1000 Subject: makepkg: adjust log clean-up for new filenames The log files now have -build or -package at the end and there are separate log files for each *_package() function. Alter clean_up() to deal with this. Also, move glob outside quotes so this actually works. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 95ee5200..ff2663b8 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -155,7 +155,14 @@ clean_up() { rm -rf "$pkgdir" "$srcdir" if [ -n "$pkgname" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. - rm -f "${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*" + rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"* + if [ "$PKGFUNC" -eq 1 ]; then + rm -f "${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + elif [ "$SPLITPKG" -eq 1 ]; then + for pkg in ${pkgname[@]}; do + rm -f "${pkg}-${pkgver}-${pkgrel}-${CARCH}-package.log"* + done + fi fi fi -- cgit v1.1-4-g5e80 From deff57ce8bc2dbe77a9a597505c67ac891718dc0 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 29 Mar 2009 16:49:57 +1000 Subject: makepkg: do not bail on failure to install built package Fixes FS#13417. Do no exit makepkg on a failure to install the built package(s). This allows clean-up to still occur. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index ff2663b8..716c5a9b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1071,10 +1071,16 @@ install_package() { pkglist="${pkglist} $PKGDEST/${pkg}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" done + local ret=0 if [ "$ASROOT" -eq 0 ]; then - sudo pacman $PACMAN_OPTS -U ${pkglist} || exit $? + sudo pacman $PACMAN_OPTS -U ${pkglist} || ret=$? else - pacman $PACMAN_OPTS -U ${pkglist} || exit $? + pacman $PACMAN_OPTS -U ${pkglist} || ret=$? + fi + + if [ $ret -ne 0 ]; then + warning "$(gettext "Failed to install built package(s).")" + return 0 fi } -- cgit v1.1-4-g5e80 From 442b91a5dd522596f55caec40e0026ef65ac2479 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 30 Mar 2009 17:41:34 +1000 Subject: makepkg: run tidy_install with no package() function After the splitpkg implementation, the tidy_install function was not being called in PKGBUILDs with only the build() function. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 716c5a9b..349d0e0e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1635,6 +1635,7 @@ if [ "$INFAKEROOT" -eq 1 ]; then if [ "$PKGFUNC" -eq 0 ]; then if [ "$REPKG" -eq 0 ]; then run_build + tidy_install fi else run_package -- cgit v1.1-4-g5e80