From b79fd73fd4ca22c0cd9c091249f425a6658006fd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 18 Dec 2023 18:58:03 -0800 Subject: [PATCH 1/6] build/bin/sage-spkg: Use sage-package --- build/bin/sage-spkg | 85 +++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index 790dbbeb232..e5d507b137e 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -149,14 +149,6 @@ exit_with_error_msg() exit 1 } -lookup_param() -{ - local param=$1 - local file=$2 - # Ignore errors if the file does not exist - sed -n "s/^${param} *= *//p" $file 2>/dev/null -} - write_to_tty() { # Try writing to terminal. Suppress the possible error message @@ -321,9 +313,11 @@ export SAGE_SPKG_WHEELS="$SAGE_INST_LOCAL/var/lib/sage/wheels" # VERSION, if provided, must match the version in build/pkgs. PKG_VER="${PKG_NAME#${PKG_BASE}}" PKG_VER="${PKG_VER#-}" -PKG_SCRIPTS="$SAGE_ROOT/build/pkgs/$PKG_BASE" -LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt 2>/dev/null || echo none` -PKG_VER="$LOCAL_PKG_VER" +eval $(sage-package properties $PKG_BASE) +eval PKG_SCRIPTS=\$path_$PKG_BASE \ + PKG_TYPE=\$type_$PKG_BASE \ + PKG_SRC_TYPE=\$source_$PKG_BASE \ + LOCAL_PKG_VER=\$version_with_patchlevel_$PKG_BASE if [ -n "$PKG_VER" -a "$PKG_VER" != "$LOCAL_PKG_VER" ]; then echo >&2 "Error: Selecting a different version of a package is no longer supported" exit 1 @@ -333,11 +327,6 @@ if [ -z "$PKG_VER" ]; then else PKG_NAME="${PKG_BASE}-${PKG_VER}" fi -PKG_BASE_VER=`echo $PKG_VER | sed 's/\.p[0-9][0-9]*$//'` -if [ -f "$PKG_SCRIPTS/checksums.ini" ]; then - # Normal/wheel package - PKG_NAME_UPSTREAM=`lookup_param tarball "$PKG_SCRIPTS/checksums.ini"` -fi # Set the $SAGE_DESTDIR variable to be passed to the spkg-install # script (the script itself could set this, but better to standardize @@ -356,20 +345,20 @@ WRAPPED_SCRIPTS="build install preinst pipinst postinst $INSTALLED_SCRIPTS" warning_for_experimental_packages() { ############################ -if [ x`cat "$PKG_SCRIPTS/type"` = x"experimental" ]; then - if [ $YES != 1 -a -n "$PKG_NAME_UPSTREAM" ]; then +case "$PKG_TYPE:$PKG_SRC_TYPE" in + experimental:normal|experimental:wheel) + if [ $YES != 1 ]; then echo "Error: The package $PKG_NAME is marked as experimental." echo "Use 'sage -i -y $PKG_BASE' to force installation of this package" echo "or use the configure option --enable-experimental-packages" exit 1 - fi -fi + fi;; +esac } ############################## warning_for_experimental_packages ensure_pkg_src() { ############################################### -if [ ! -f "$PKG_SRC" ]; then - if [ -n "$PKG_NAME_UPSTREAM" ]; then - # Normal or wheel package +case "$PKG_SRC_TYPE" in + normal|wheel) PKG_SRC=$(sage-package download $SAGE_DOWNLOAD_FILE_OPTIONS $PKG_BASE) || exit_with_error_msg "Error downloading tarball of $PKG_BASE" # Do a final check that PKG_SRC is a file with an absolute path cd / @@ -378,21 +367,21 @@ if [ ! -f "$PKG_SRC" ]; then echo >&2 "This shouldn't happen, it is a bug in the sage-spkg script." exit 1 fi - fi -fi - -# Go back to SAGE_ROOT where we have less chance of completely messing -# up the system if we do something wrong. -cd "$SAGE_ROOT" || exit $? -# If SAGE_SPKG_COPY_UPSTREAM is set, it should be the name of a directory -# to which all upstream files are copied. This is used in sage-sdist. -if [ -n "$SAGE_SPKG_COPY_UPSTREAM" -a -n "$PKG_NAME_UPSTREAM" ]; then - mkdir -p "$SAGE_SPKG_COPY_UPSTREAM" && cp -p "$PKG_SRC" "$SAGE_SPKG_COPY_UPSTREAM" - if [ $? -ne 0 ]; then - exit_with_error_msg "Error copying upstream tarball to directory '$SAGE_SPKG_COPY_UPSTREAM'" - fi -fi + # Go back to SAGE_ROOT where we have less chance of completely messing + # up the system if we do something wrong. + cd "$SAGE_ROOT" || exit $? + + # If SAGE_SPKG_COPY_UPSTREAM is set, it should be the name of a directory + # to which all upstream files are copied. This is used in sage-sdist. + if [ -n "$SAGE_SPKG_COPY_UPSTREAM" ]; then + mkdir -p "$SAGE_SPKG_COPY_UPSTREAM" && cp -p "$PKG_SRC" "$SAGE_SPKG_COPY_UPSTREAM" + if [ $? -ne 0 ]; then + error_msg "Error copying upstream tarball to directory '$SAGE_SPKG_COPY_UPSTREAM'" + exit 1 + fi + fi;; +esac } ################################################# ensure_pkg_src setup_directories() { ############################################ @@ -438,8 +427,8 @@ extract_the_package() { ########################################## cd "$SAGE_BUILD_DIR" || exit $? echo "Setting up build directory $SAGE_BUILD_DIR/$PKG_NAME" -if [ -z "$PKG_NAME_UPSTREAM" ]; then - # Not a normal or wheel package. +case "$PKG_SRC_TYPE" in + script) # Transplant the 'src' symlink, copy scripts. mkdir -p "$PKG_NAME" if [ -d "$PKG_SCRIPTS"/src ]; then @@ -453,8 +442,9 @@ if [ -z "$PKG_NAME_UPSTREAM" ]; then fi done cd "$PKG_NAME" || exit $? -else - # Normal or wheel package, copy whole directory, resolving symlinks + ;; + normal|wheel) + # Copy whole directory, resolving symlinks cp -RLp "$PKG_SCRIPTS" "$PKG_NAME" cd "$PKG_NAME" || exit $? case "$PKG_SRC" in @@ -476,7 +466,11 @@ else cd .. ;; esac -fi + ;; + *) + error_msg "Unhandled source type $PKG_SRC_TYPE" + ;; +esac if [ "$SAGE_KEEP_BUILT_SPKGS" = "yes" ]; then touch .keep fi @@ -604,13 +598,14 @@ esac # Poison the proxy variable to forbid downloads in spkg-install # for normal packages -if [ -n "$PKG_NAME_UPSTREAM" ]; then - # Normal/wheel package +case $PKG_SRC_TYPE in + normal|wheel) export http_proxy=http://192.0.2.0:5187/ export https_proxy=$http_proxy export ftp_proxy=$http_proxy export rsync_proxy=$http_proxy -fi + ;; +esac # Make sage-logger show the full logs unset SAGE_SILENT_BUILD From 8d6f11a1a5f718a0dc32dd58a464d74e95ab01c8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 18 Dec 2023 20:33:08 -0800 Subject: [PATCH 2/6] build/bin/sage-spkg: Move handling of dummy packages here from build/make/Makefile.in --- build/bin/sage-spkg | 18 +++++++++++++++++- build/make/Makefile.in | 15 +-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index e5d507b137e..d4d5981b27f 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -380,7 +380,23 @@ case "$PKG_SRC_TYPE" in error_msg "Error copying upstream tarball to directory '$SAGE_SPKG_COPY_UPSTREAM'" exit 1 fi - fi;; + fi + ;; + none) + echo >&2 + echo >&2 "Note: $PKG_BASE is a dummy package that the Sage distribution uses" + echo >&2 "to provide information about equivalent system packages." + echo >&2 "It cannot be installed using the Sage distribution." + echo >&2 "Please install it manually, for example using the system packages" + echo >&2 "recommended at the end of a run of './configure'" + echo >&2 "See below for package-specific information." + echo >&2 + sage-spkg-info $PKG_BASE + echo >&2 + echo >&2 "Error: $PKG_BASE is a dummy package and " + echo >&2 "cannot be installed using the Sage distribution." + exit 1 + ;; esac } ################################################# ensure_pkg_src diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 7a13e5a9e23..e6982a473b3 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -741,7 +741,7 @@ $(1)-$(4)-no-deps: echo "Error: The installation tree $(4) has been disabled" 2>&1; \ echo "$$($(4)_DISABLED_MESSAGE)" 2>&1; \ exit 1; \ - elif [ -x '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' -o -r '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install.in' ]; then \ + else \ rm -rf '$$($(4))/var/lib/sage/scripts/$(1)'; \ cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \ . '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \ @@ -759,19 +759,6 @@ $(1)-$(4)-no-deps: sage-logger -p 'SAGE_CHECK=$$(SAGE_CHECK_$(1)) PATH=$$(SAGE_SRC)/bin:$$($(4))/bin:$$$$PATH $$(SAGE_SPKG) $$(SAGE_SPKG_OPTIONS) \ $(if $(filter $(1),$(TOOLCHAIN_DEPS)),--keep-existing) \ $(1)-$(2) $$($(4))' '$$(SAGE_LOGS)/$(1)-$(2).log'; \ - else ( \ - echo; \ - echo "Note: $(1) is a dummy package that the Sage distribution uses"; \ - echo "to provide information about equivalent system packages."; \ - echo "It cannot be installed using the Sage distribution."; \ - echo "Please install it manually, for example using the system packages"; \ - echo "recommended at the end of a run of './configure'"; \ - echo "See below for package-specific information."; \ - echo; \ - $$(SAGE_ROOT)/build/bin/sage-spkg-info $(1); \ - echo; \ - echo "Error: $(1) is a dummy package and "; \ - echo "cannot be installed using the Sage distribution." ) | sage-logger -p 'cat; exit 1' '$$(SAGE_LOGS)/$(1)-$(2).log'; \ fi $(1)-no-deps: $(1)-$(4)-no-deps From 1a97f3c90b323e3f80db11cd0c5044de6b506ee1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 Jun 2024 15:52:43 -0700 Subject: [PATCH 3/6] build/bin/sage-spkg: Update use of 'sage -package properties' --- build/bin/sage-spkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index d4d5981b27f..4465fc905bf 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -313,7 +313,7 @@ export SAGE_SPKG_WHEELS="$SAGE_INST_LOCAL/var/lib/sage/wheels" # VERSION, if provided, must match the version in build/pkgs. PKG_VER="${PKG_NAME#${PKG_BASE}}" PKG_VER="${PKG_VER#-}" -eval $(sage-package properties $PKG_BASE) +eval $(sage-package properties --format=shell $PKG_BASE) eval PKG_SCRIPTS=\$path_$PKG_BASE \ PKG_TYPE=\$type_$PKG_BASE \ PKG_SRC_TYPE=\$source_$PKG_BASE \ From 8f73ee373b5bd7e7b577b65e9a546dbf539780e7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 Jun 2024 16:00:25 -0700 Subject: [PATCH 4/6] build/bin/sage-spkg (write_to_tty): Remove unused function --- build/bin/sage-spkg | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index 4465fc905bf..2f3ab3d88e7 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -149,16 +149,6 @@ exit_with_error_msg() exit 1 } -write_to_tty() -{ - # Try writing to terminal. Suppress the possible error message - if ! ( cat > /dev/tty ) 2> /dev/null ; then - # Fall back to writing to stdout - cat - return 1 - fi -} - # Handle -n, -t, -q options for recursive make # See Issue #12016. if echo "$MAKE $MAKEFLAGS -$MAKEFLAGS" |grep '[ ]-[A-Za-z]*[qnt]' >/dev/null; then From 1b8cc6fe0d2e35f5c5bc6be8269922c32450bb84 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 Jun 2024 16:46:39 -0700 Subject: [PATCH 5/6] build/bin/sage-spkg: Export PKG_BASE, PKG_NAME, PKG_VER for use in unwrapped scripts; do not set in Makefile.in --- build/bin/sage-spkg | 8 ++++---- build/make/Makefile.in | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index 2f3ab3d88e7..6af5214c27f 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -275,7 +275,7 @@ if echo "$PKG_SRC" | grep / >/dev/null; then exit 1 fi PKG_NAME="$PKG_SRC" -PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'` # strip version number +export PKG_BASE=`echo "$PKG_NAME" | sed 's/-.*//'` # strip version number case $# in 1) @@ -302,7 +302,7 @@ export SAGE_SPKG_WHEELS="$SAGE_INST_LOCAL/var/lib/sage/wheels" # PKG_SRC should look like "package-VERSION" or just "package". # VERSION, if provided, must match the version in build/pkgs. PKG_VER="${PKG_NAME#${PKG_BASE}}" -PKG_VER="${PKG_VER#-}" +export PKG_VER="${PKG_VER#-}" eval $(sage-package properties --format=shell $PKG_BASE) eval PKG_SCRIPTS=\$path_$PKG_BASE \ PKG_TYPE=\$type_$PKG_BASE \ @@ -313,9 +313,9 @@ if [ -n "$PKG_VER" -a "$PKG_VER" != "$LOCAL_PKG_VER" ]; then exit 1 fi if [ -z "$PKG_VER" ]; then - PKG_NAME="${PKG_BASE}" + export PKG_NAME="${PKG_BASE}" else - PKG_NAME="${PKG_BASE}-${PKG_VER}" + export PKG_NAME="${PKG_BASE}-${PKG_VER}" fi # Set the $SAGE_DESTDIR variable to be passed to the spkg-install diff --git a/build/make/Makefile.in b/build/make/Makefile.in index e6982a473b3..a59c81db529 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -749,12 +749,6 @@ $(1)-$(4)-no-deps: . '$$(SAGE_ROOT)/src/bin/sage-env' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env' && \ - PKG_BASE="$(1)" \ - PKG_VER="$(2)" \ - PKG_NAME="$(1)-$(2)" \ - SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \ - SAGE_SPKG_SCRIPTS=$$($(4))/var/lib/sage/scripts \ - SAGE_INST_LOCAL=$$($(4)) \ SAGE_CHECK=$$(SAGE_CHECK_$(1)) \ sage-logger -p 'SAGE_CHECK=$$(SAGE_CHECK_$(1)) PATH=$$(SAGE_SRC)/bin:$$($(4))/bin:$$$$PATH $$(SAGE_SPKG) $$(SAGE_SPKG_OPTIONS) \ $(if $(filter $(1),$(TOOLCHAIN_DEPS)),--keep-existing) \ From 9d56b35676c9fc6140361dfbb6621ab70a2f863f Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 24 Jun 2024 17:04:59 -0700 Subject: [PATCH 6/6] build/pkgs/python3/spkg-install.in: Remove unnecessary use of PKG_BASE --- build/pkgs/python3/spkg-install.in | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/build/pkgs/python3/spkg-install.in b/build/pkgs/python3/spkg-install.in index caf91d20c6d..2b2844ea02f 100644 --- a/build/pkgs/python3/spkg-install.in +++ b/build/pkgs/python3/spkg-install.in @@ -20,11 +20,7 @@ cd src sdh_make_install -i -j1 echo "Installing valgrind suppression file..." -if [ "$PKG_BASE" = "python2" ]; then - SUPP_FILENAME="python.supp" -else - SUPP_FILENAME="${PKG_BASE}.supp" -fi +SUPP_FILENAME="python3.supp" sdh_install -T Misc/valgrind-python.supp "$SAGE_LOCAL/lib/valgrind/$SUPP_FILENAME" if [ "$UNAME" = "Linux" ]; then @@ -42,14 +38,9 @@ else fi PYTHON_VERSION=$($PYTHON -c 'import sys; print("%d.%d" % sys.version_info[:2])') -if [ "$PKG_BASE" = "python2" ]; then - PYTHON_LDVERSION="$PYTHON_VERSION" - PYTHON_CONFIG_DIR="$SAGE_LOCAL/lib/python${PYTHON_VERSION}/config" -else - PYTHON_ABIFLAGS=$($PYTHON -c 'import sys; print(sys.abiflags)') - PYTHON_LDVERSION="$PYTHON_VERSION$PYTHON_ABIFLAGS" - PYTHON_CONFIG_DIR="$SAGE_LOCAL/lib/python${PYTHON_VERSION}/config-${PYTHON_LDVERSION}" -fi +PYTHON_ABIFLAGS=$($PYTHON -c 'import sys; print(sys.abiflags)') +PYTHON_LDVERSION="$PYTHON_VERSION$PYTHON_ABIFLAGS" +PYTHON_CONFIG_DIR="$SAGE_LOCAL/lib/python${PYTHON_VERSION}/config-${PYTHON_LDVERSION}" # On OS X with XCode 4, the presence of # $SAGE_LOCAL/lib/python3.x/config/libpython3.x.a causes problems with