Skip to content

Commit

Permalink
Trac #27219: bootstrap should fail gracefully, if there is no pkg-con…
Browse files Browse the repository at this point in the history
…fig available

When #27114 is merged, `./bootstrap` requires `pkgconf` to run properly.
It should switch to downloading the configure spkg if the `pkgconf` m4
macros are not installed. Otherwise one gets

{{{
checking whether g++ supports C++11 features with -std=gnu++11... yes
checking for gcc option to accept ISO C99... none needed
checking if gcc accepts -dumpversion option... yes
checking gcc version... 5.4.0
checking if g++ accepts -dumpversion option... yes
checking g++ version... 5.4.0
configure: === checking whether to install the libffi SPKG ===
./configure: line 9026: syntax error near unexpected token `LIBFFI,'
./configure: line 9026: `        PKG_CHECK_MODULES(LIBFFI, libffi, ,'
If you would like to try to build Sage anyway (to help porting),
export the variable 'SAGE_PORT' to something non-empty.
Makefile:39: recipe for target 'build/make/Makefile' failed
make[1]: Leaving directory '/var/lib/buildbot/slave/sage_git/build'
make[1]: *** [build/make/Makefile] Error 1
Makefile:31: recipe for target 'build-clean' failed
make: *** [build-clean] Error 2
program finished with exit code 2
}}}

In order to solve this issue, we check for presence of
`PKG_PROG_PKG_CONFIG` at bootstrap/autoconf run. We need renaming of
PKG_ -> SPKG_ in `m4/sage_spkg_collect.m4`, which we take from #27114 in
order not to cause conflicts.

#27114 probably will need a rebase on top of this branch.

URL: https://trac.sagemath.org/27219
Reported by: dimpase
Ticket author(s): Dima Pasechnik
Reviewer(s): Jeroen Demeyer
  • Loading branch information
Release Manager authored and vbraun committed Feb 8, 2019
2 parents 6023e39 + 187de34 commit 8a58b71
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
4 changes: 3 additions & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ SAGE_SPKG_CONFIGURE_$(echo ${pkgname} | tr '[a-z]' '[A-Z]')"
case $st in
0) true;; # Success

63|127) # Autotools not installed or version too old
16|63|127) # no m4 for pkg-config, or autotools not installed, or version too old
if [ $DOWNLOAD = yes ]; then
echo >&2 "Bootstrap failed, downloading required files instead."
bootstrap-download || exit $?
else
if [ $st -eq 127 ]; then
verb="install"
elif [ $st -eq 16 ]; then
verb="install pkg-config m4 macros for"
else
verb="upgrade"
fi
Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ then
AC_MSG_ERROR([Exiting, as the macro processor 'm4' can not be found.])
fi

m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_errprint(
[Error: could not locate the pkg-config autoconf macros. These are
usually located in /usr/share/aclocal/pkg.m4. If your macros are
in a different location, try setting the environment variable
ACLOCAL="aclocal -I/other/macro/dir" before running ./bootstrap
])
dnl Exit autoconf with exit code 16 in this case. This will be
dnl caught by the bootstrap script.
m4_exit(16)])

PKG_PROG_PKG_CONFIG

AC_CHECK_PROG(found_ranlib, ranlib, yes, no)
if test x$found_ranlib != xyes
then
Expand Down
66 changes: 33 additions & 33 deletions m4/sage_spkg_collect.m4
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ AC_MSG_RESULT([])
# Usage: newest_version $pkg
# Print version number of latest package $pkg
newest_version() {
PKG=$[1]
if test -f "$SAGE_ROOT/build/pkgs/$PKG/package-version.txt" ; then
cat "$SAGE_ROOT/build/pkgs/$PKG/package-version.txt"
SPKG=$[1]
if test -f "$SAGE_ROOT/build/pkgs/$SPKG/package-version.txt" ; then
cat "$SAGE_ROOT/build/pkgs/$SPKG/package-version.txt"
else
echo "$PKG"
echo "$SPKG"
fi
}
Expand Down Expand Up @@ -113,74 +113,74 @@ SAGE_SCRIPT_PACKAGES='\
for DIR in $SAGE_ROOT/build/pkgs/*; do
test -d "$DIR" || continue
PKG_TYPE_FILE="$DIR/type"
if test -f "$PKG_TYPE_FILE"; then
PKG_TYPE=`cat $PKG_TYPE_FILE`
SPKG_TYPE_FILE="$DIR/type"
if test -f "$SPKG_TYPE_FILE"; then
SPKG_TYPE=`cat $SPKG_TYPE_FILE`
else
AC_MSG_ERROR(["$PKG_TYPE_FILE" is missing.])
AC_MSG_ERROR(["$SPKG_TYPE_FILE" is missing.])
fi
PKG_NAME=$(basename $DIR)
PKG_VERSION=$(newest_version $PKG_NAME)
SPKG_NAME=$(basename $DIR)
SPKG_VERSION=$(newest_version $SPKG_NAME)
in_sdist=no
# Check consistency of 'DIR/type' file
case "$PKG_TYPE" in
case "$SPKG_TYPE" in
base) ;;
standard)
SAGE_STANDARD_PACKAGES+=" $PKG_NAME \\"$'\n'
SAGE_STANDARD_PACKAGES+=" $SPKG_NAME \\"$'\n'
in_sdist=yes
;;
optional)
if test -f $SAGE_SPKG_INST/$PKG_NAME-*; then
SAGE_OPTIONAL_INSTALLED_PACKAGES+=" $PKG_NAME \\"$'\n'
if test -f $SAGE_SPKG_INST/$SPKG_NAME-*; then
SAGE_OPTIONAL_INSTALLED_PACKAGES+=" $SPKG_NAME \\"$'\n'
fi;
;;
experimental) ;;
script) ;;
pip) ;;
*)
AC_MSG_ERROR([The content of "$PKG_TYPE_FILE" must be 'base', 'standard', 'optional', 'experimental', 'script', or 'pip'])
AC_MSG_ERROR([The content of "$SPKG_TYPE_FILE" must be 'base', 'standard', 'optional', 'experimental', 'script', or 'pip'])
;;
esac
SAGE_PACKAGE_VERSIONS+="vers_$PKG_NAME = $PKG_VERSION"$'\n'
SAGE_PACKAGE_VERSIONS+="vers_$SPKG_NAME = $SPKG_VERSION"$'\n'
# If $sage_spkg_install_{PKG_NAME} is set to no, then set inst_<pkgname> to
# If $sage_spkg_install_{SPKG_NAME} is set to no, then set inst_<pkgname> to
# some dummy file to skip the installation. Note that an explicit
# "./sage -i PKG_NAME" will still install the package.
if test "$PKG_NAME" != "$PKG_VERSION"; then
sage_spkg_install="sage_spkg_install_${PKG_NAME}"
# "./sage -i SPKG_NAME" will still install the package.
if test "$SPKG_NAME" != "$SPKG_VERSION"; then
sage_spkg_install="sage_spkg_install_${SPKG_NAME}"
if test "${!sage_spkg_install}" != no ; then
SAGE_BUILT_PACKAGES+=" $PKG_NAME \\"$'\n'
AC_MSG_RESULT([ $PKG_NAME-$PKG_VERSION])
SAGE_BUILT_PACKAGES+=" $SPKG_NAME \\"$'\n'
AC_MSG_RESULT([ $SPKG_NAME-$SPKG_VERSION])
else
SAGE_DUMMY_PACKAGES+=" $PKG_NAME \\"$'\n'
AC_MSG_RESULT([ $PKG_NAME-$PKG_VERSION not installed (configure check)])
SAGE_DUMMY_PACKAGES+=" $SPKG_NAME \\"$'\n'
AC_MSG_RESULT([ $SPKG_NAME-$SPKG_VERSION not installed (configure check)])
fi
fi
# Packages that should be included in the source distribution
# This includes all standard packages and two special cases
case "$PKG_NAME" in
case "$SPKG_NAME" in
mpir|python2)
in_sdist=yes
;;
esac
if test "$in_sdist" = yes; then
SAGE_SDIST_PACKAGES+=" $PKG_NAME \\"$'\n'
SAGE_SDIST_PACKAGES+=" $SPKG_NAME \\"$'\n'
fi
# Determine package dependencies
DEP_FILE="$SAGE_ROOT/build/pkgs/$PKG_NAME/dependencies"
DEP_FILE="$SAGE_ROOT/build/pkgs/$SPKG_NAME/dependencies"
if test -f "$DEP_FILE"; then
# - the # symbol is treated as comment which is removed
DEPS=`sed 's/^ *//; s/ *#.*//; q' $DEP_FILE`
else
case "$PKG_TYPE" in
case "$SPKG_TYPE" in
optional)
DEPS=' | $(STANDARD_PACKAGES)' # default for optional packages
;;
Expand All @@ -196,18 +196,18 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
esac
fi
SAGE_PACKAGE_DEPENDENCIES+="deps_$PKG_NAME = $DEPS"$'\n'
SAGE_PACKAGE_DEPENDENCIES+="deps_$SPKG_NAME = $DEPS"$'\n'
# Determine package build rules
case "$PKG_TYPE" in
case "$SPKG_TYPE" in
pip)
SAGE_PIP_PACKAGES+=" $PKG_NAME \\"$'\n'
SAGE_PIP_PACKAGES+=" $SPKG_NAME \\"$'\n'
;;
script)
SAGE_SCRIPT_PACKAGES+=" $PKG_NAME \\"$'\n'
SAGE_SCRIPT_PACKAGES+=" $SPKG_NAME \\"$'\n'
;;
*)
SAGE_NORMAL_PACKAGES+=" $PKG_NAME \\"$'\n'
SAGE_NORMAL_PACKAGES+=" $SPKG_NAME \\"$'\n'
;;
esac
done
Expand Down

0 comments on commit 8a58b71

Please sign in to comment.