Skip to content

Commit

Permalink
Merge branch 'system-package-quoting' into conda_compiler_pin
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Dec 20, 2023
2 parents 77e692d + 7c0eb33 commit 553ae34
Show file tree
Hide file tree
Showing 103 changed files with 316 additions and 179 deletions.
2 changes: 1 addition & 1 deletion build/bin/sage-get-system-packages
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case "$SYSTEM" in
fi
fi
SYSTEM_PACKAGES_FILE_NAMES="distros/$SYSTEM.txt"
STRIP_COMMENTS="sed s/#.*//;"
STRIP_COMMENTS="sed s/#.*//;s/\${PYTHON_MINOR}/${PYTHON_MINOR}/g"
COLLECT=echo
;;
esac
Expand Down
50 changes: 33 additions & 17 deletions build/bin/sage-print-system-package-command
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ do
;;
--prompt)
PROMPT=' $ '
CONTINUATION=' '
;;
--continuation=*)
CONTINUATION="${1#--continuation=}"
;;
--wrap)
WRAP=78
;;
--wrap=*)
WRAP="${1#--wrap=}"
;;
--no-install-recommends)
NO_INSTALL_RECOMMENDS=yes
Expand Down Expand Up @@ -79,7 +89,13 @@ function print_shell_command()
echo ".. CODE-BLOCK:: bash"
echo
fi
echo "${PROMPT}$1"
# shell-quote arguments if necessary
quoted=$(for a in "$@"; do printf "%q " $a; done)
if [ -z "$WRAP" -o $# -lt 6 ]; then
echo "${PROMPT}${quoted}"
else
sage-bootstrap-python -c "import textwrap; print(' \\\\\n'.join(textwrap.wrap(r'''${quoted}''', $WRAP, initial_indent=r'''${PROMPT}''', subsequent_indent=r'''${CONTINUATION}''', break_long_words=False, break_on_hyphens=False)))"
fi
if [ -n "$OUTPUT_RST" ]; then
echo
fi
Expand Down Expand Up @@ -109,70 +125,70 @@ case $system:$command in
# Verbs handled above are our own inventions. Verbs handled below are apt-get verbs.
#
@(debian*|ubuntu*):update)
print_shell_command "${SUDO}apt-get $command $system_packages"
print_shell_command ${SUDO}apt-get $command $system_packages
;;
@(debian*|ubuntu*):*)
[ "$NO_INSTALL_RECOMMENDS" = yes ] && options="$options --no-install-recommends"
[ "$YES" = yes ] && options="$options --yes" env="DEBIAN_FRONTEND=noninteractive "
[ -n "$system_packages" ] && print_shell_command "${SUDO}${env}apt-get $command $options $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}${env}apt-get $command $options $system_packages
;;
@(fedora*|redhat*|centos*):install)
[ "$YES" = yes ] && options="$options -y"
[ -n "$system_packages" ] && print_shell_command "${SUDO}yum install $options $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}yum install $options $system_packages
;;
gentoo*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}emerge $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}emerge $system_packages
;;
arch*:update)
print_shell_command "${SUDO}pacman -Sy"
;;
arch*:install)
[ "$YES" = yes ] && options="$options --noconfirm"
[ -n "$system_packages" ] && print_shell_command "${SUDO}pacman -S $options $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}pacman -S $options $system_packages
;;
void*:update)
print_shell_command "${SUDO}xbps-install -Su"
;;
void*:install)
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && print_shell_command "${SUDO}xbps-install $options $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}xbps-install $options $system_packages
;;
opensuse*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}zypper install $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}zypper install $system_packages
;;
*conda*:install)
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && print_shell_command "conda install $options $system_packages"
[ -n "$system_packages" ] && print_shell_command conda install $options $system_packages
;;
homebrew*:install)
[ -n "$system_packages" ] && print_shell_command "brew install $system_packages"
[ -n "$system_packages" ] && print_shell_command brew install $system_packages
;;
slackware*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}slackpkg install $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}slackpkg install $system_packages
;;
cygwin*:update)
print_comment "first install apt-cyg from https://github.com/transcode-open/apt-cyg"
;;
cygwin*:install)
[ -n "$system_packages" ] && print_shell_command "apt-cyg install $system_packages"
[ -n "$system_packages" ] && print_shell_command apt-cyg install $system_packages
;;
freebsd*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}pkg install $system_packages"
[ -n "$system_packages" ] && print_shell_command ${SUDO}pkg install $system_packages
;;
nix*:install)
[ -n "$system_packages" ] && print_shell_command "nix-env --install $system_packages"
[ -n "$system_packages" ] && print_shell_command nix-env --install $system_packages
;;
alpine:update)
print_shell_command "apk update"
;;
alpine:install)
[ -n "$system_packages" ] && print_shell_command "apk add $system_packages"
[ -n "$system_packages" ] && print_shell_command apk add $system_packages
;;
pip:install)
[ -n "$system_packages" ] && print_shell_command "sage -pip install $system_packages"
[ -n "$system_packages" ] && print_shell_command sage -pip install $system_packages
;;
cpan:install)
[ -n "$system_packages" ] && print_shell_command "cpan -i $system_packages"
[ -n "$system_packages" ] && print_shell_command cpan -i $system_packages
;;
repology:install)
if [ -n "$system_packages" ]; then
Expand Down
2 changes: 1 addition & 1 deletion build/bin/sage-spkg-info
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ for system in $systems; do
echo "$system:"
;;
esac
sage-print-system-package-command $system --prompt=' $ ' --sudo install $system_packages
sage-print-system-package-command $system --wrap --prompt=' $ ' --continuation=' ' --sudo install $system_packages
echo
done
if [ -z "$system" ]; then
Expand Down
13 changes: 8 additions & 5 deletions build/bin/write-dockerfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ export PATH="$SAGE_ROOT"/build/bin:$PATH
SYSTEM_PACKAGES=$EXTRA_SYSTEM_PACKAGES
CONFIGURE_ARGS="--enable-option-checking "
for SPKG in $(sage-package list --has-file=spkg-configure.m4 $SAGE_PACKAGE_LIST_ARGS) $EXTRA_SAGE_PACKAGES; do
SYSTEM_PACKAGE=$(sage-get-system-packages $SYSTEM $SPKG | sed 's/${PYTHON_MINOR}/'${PYTHON_MINOR}'/g')
SYSTEM_PACKAGE=$(sage-get-system-packages $SYSTEM $SPKG)
if [ -n "${SYSTEM_PACKAGE}" ]; then
# SYSTEM_PACKAGE can be empty if, for example, the environment
# variable ENABLE_SYSTEM_SITE_PACKAGES is empty.
SYSTEM_PACKAGES+=" ${SYSTEM_PACKAGE}"
CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} "
# SYSTEM_PACKAGE can be empty if, for example, the environment
# variable ENABLE_SYSTEM_SITE_PACKAGES is empty.
for a in $SYSTEM_PACKAGE; do
# shell-quote package if necessary
SYSTEM_PACKAGES+=$(printf " %q" "$a")
done
CONFIGURE_ARGS+="--with-system-${SPKG}=${WITH_SYSTEM_SPKG} "
fi
done
echo "# Automatically generated by SAGE_ROOT/build/bin/write-dockerfile.sh"
Expand Down
4 changes: 3 additions & 1 deletion build/pkgs/_bootstrap/distros/arch.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Packages needed for ./bootstrap
autoconf automake libtool
autoconf
automake
libtool
pkgconf
4 changes: 3 additions & 1 deletion build/pkgs/_bootstrap/distros/cygwin.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Packages needed for ./bootstrap
autoconf automake libtool
autoconf
automake
libtool
5 changes: 3 additions & 2 deletions build/pkgs/_bootstrap/distros/fedora.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Packages needed for ./bootstrap
autoconf automake libtool
# Fedora 26 needs:
autoconf
automake
libtool
pkg-config
5 changes: 4 additions & 1 deletion build/pkgs/_bootstrap/distros/freebsd.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Packages needed for ./bootstrap
autoconf automake libtool pkg-config
autoconf
automake
libtool
pkg-config
5 changes: 4 additions & 1 deletion build/pkgs/_bootstrap/distros/homebrew.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Packages needed for ./bootstrap
autoconf automake libtool pkg-config
autoconf
automake
libtool
pkg-config
5 changes: 4 additions & 1 deletion build/pkgs/_bootstrap/distros/nix.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Packages needed for ./bootstrap
autoconf automake libtool pkg-config
autoconf
automake
libtool
pkg-config
7 changes: 5 additions & 2 deletions build/pkgs/_bootstrap/distros/void.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Packages needed for ./bootstrap
autoconf automake libtool
xtools mk-configure
autoconf
automake
libtool
xtools
mk-configure
pkg-config
9 changes: 9 additions & 0 deletions build/pkgs/_prereq/distros/alpine.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This file, build/pkgs/_prereq/distros/alpine.txt, contains names of
# Alpine Linux packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/distros/alpine.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
make
m4
Expand Down
9 changes: 9 additions & 0 deletions build/pkgs/_prereq/distros/arch.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This file, build/pkgs/_prereq/distros/arch.txt, contains names of
# Arch Linux packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/distros/arch.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
make
m4
Expand Down
9 changes: 9 additions & 0 deletions build/pkgs/_prereq/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This file, build/pkgs/_prereq/distros/conda.txt, contains names of
# conda packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/distros/conda.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
compilers<=1.6.0 # 1.7 pulls in c-compiler v.16
make
m4
Expand Down
15 changes: 7 additions & 8 deletions build/pkgs/_prereq/distros/cygwin.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# This file, build/pkgs/cygwin.txt, contains name Cygwin packages
# needed for installation of Sage from source.
# This file, build/pkgs/_prereq/distros/cygwin.txt, contains names of
# Cygwin packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/cygwin.txt contain the names
# of packages that provide the equivalent of SPKG.
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
# In addition, the files build/pkgs/SPKG/distros/cygwin.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
make
m4
# a system python is needed for downloading the sage packages, https://github.com/sagemath/sage/issues/29090
python39-urllib3 python39
python39-urllib3
python39
perl
perl-ExtUtils-MakeMaker
tar
Expand Down
16 changes: 6 additions & 10 deletions build/pkgs/_prereq/distros/debian.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# This file, build/pkgs/debian.txt, contains names of Debian/Ubuntu packages
# needed for installation of Sage from source.
# This file, build/pkgs/_prereq/distros/debian.txt, contains names of
# Debian/Ubuntu/... packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/debian.txt contain the names
# of packages that provide the equivalent of SPKG.
#
# If distinctions between different distributions need to be made,
# files named debian....txt or ubuntu.....txt can be used.
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
# In addition, the files build/pkgs/SPKG/distros/debian.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
make
m4
Expand Down
16 changes: 6 additions & 10 deletions build/pkgs/_prereq/distros/fedora.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# This file, build/pkgs/fedora.txt, contains names of Fedora/Redhat/CentOS packages
# needed for installation of Sage from source.
# This file, build/pkgs/_prereq/distros/fedora.txt, contains names of
# Fedora/Redhat/CentOS/AlmaLinux packages needed for installation
# of Sage from source.
#
# In addition, the files build/pkgs/SPKG/fedora.txt contain the names
# of packages that provide the equivalent of SPKG.
#
# If distinctions between different distributions need to be made,
# files named fedora....txt, redhat...txt, or centos....txt can be used.
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
# In addition, the files build/pkgs/SPKG/distros/fedora.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
Expand Down
9 changes: 4 additions & 5 deletions build/pkgs/_prereq/distros/freebsd.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file, build/pkgs/freebsd.txt, contains names of FreeBSD packages
# needed for installation of Sage from source.
# This file, build/pkgs/_prereq/distros/freebsd.txt, contains names of
# FreeBSD packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/distros/freebsd.txt contain the
# names of packages that provide the equivalent of SPKG.
Expand All @@ -8,10 +8,9 @@
# $ cd /usr/ports/math/sage
# $ sudo make install-missing-packages
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
gmake
automake
bash
Expand Down
9 changes: 9 additions & 0 deletions build/pkgs/_prereq/distros/gentoo.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This file, build/pkgs/_prereq/distros/gentoo.txt, contains names of
# Gentoo packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/distros/gentoo.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
sys-devel/binutils
sys-libs/binutils-libs
sys-devel/make
Expand Down
13 changes: 6 additions & 7 deletions build/pkgs/_prereq/distros/homebrew.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# This file, build/pkgs/homebrew.txt, contains names of homebrew packages
# needed for installation of Sage from source (in addition to XCode).
# This file, build/pkgs/_prereq/distros/homebrew.txt, contains names of
# Homebrew packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/homebrew.txt contain the names
# of packages that provide the equivalent of SPKG.
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
# In addition, the files build/pkgs/SPKG/distros/homebrew.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#

# No packages needed
16 changes: 6 additions & 10 deletions build/pkgs/_prereq/distros/nix.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# This file, build/pkgs/debian.txt, contains names of Debian/Ubuntu packages
# needed for installation of Sage from source.
# This file, build/pkgs/_prereq/distros/nix.txt, contains names of
# nix packages needed for installation of Sage from source.
#
# In addition, the files build/pkgs/SPKG/debian.txt contain the names
# of packages that provide the equivalent of SPKG.
#
# If distinctions between different distributions need to be made,
# files named debian....txt or ubuntu.....txt can be used.
#
# See build/bin/sage-spkg, where this information is processed
# for use in "sage -info SPKG".
# In addition, the files build/pkgs/SPKG/distros/nix.txt contain
# the names of packages that provide the equivalent of SPKG.
#
# One package per line. No need to escape special characters.
# Everything on a line after a # character is ignored.
#
binutils
gnumake
gnum4
Expand Down
Loading

0 comments on commit 553ae34

Please sign in to comment.