Skip to content

Commit

Permalink
Trac #30923: tox.ini: Add environments local-sudo-ubuntu-standard, etc.
Browse files Browse the repository at this point in the history
These environments would just run `sudo apt-get ...` etc. to install
(but not remove!) packages, for use at the user's own risk.

To test (on an Ubuntu system):
{{{
    tox -e local-sudo-ubuntu-bionic-standard
}}}
or
{{{
    tox -e local-sudo-standard
}}}

URL: https://trac.sagemath.org/30923
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Tobias Diez, Dima Pasechnik
  • Loading branch information
Release Manager committed Nov 22, 2020
2 parents a91d4b5 + ff34897 commit 40c1674
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
28 changes: 23 additions & 5 deletions build/bin/sage-print-system-package-command
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ do
--prompt)
PROMPT=' $ '
;;
--no-install-recommends)
NO_INSTALL_RECOMMENDS=yes
;;
--yes)
YES=yes
;;
-*)
echo >&2 "$0: unknown option $1"
exit 1
Expand All @@ -37,6 +43,7 @@ if [ -z "$system" -o -z "$command" ]; then
exit 1
fi
system_packages="$*"
options=
shopt -s extglob
case $system:$command in
homebrew*:setup-build-env)
Expand All @@ -56,22 +63,33 @@ case $system:$command in
echo "${PROMPT}${SUDO}apt-get $command $system_packages"
;;
@(debian*|ubuntu*):*)
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}apt-get $command $system_packages"
[ "$NO_INSTALL_RECOMMENDS" = yes ] && options="$options --no-install-recommends"
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}apt-get $command $options $system_packages"
;;
@(fedora*|redhat*|centos*):install)
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}yum install $system_packages"
[ "$YES" = yes ] && options="$options -y"
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}yum install $options $system_packages"
;;
gentoo*:install)
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}emerge $system_packages"
;;
arch*:update)
echo "${PROMPT}${SUDO}pacman -Sy"
;;
arch*:install)
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}pacman -S $system_packages"
[ "$YES" = yes ] && options="$options --noconfirm"
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}pacman -S $options $system_packages"
;;
void*:update)
echo "${PROMPT}${SUDO}xbps-install -Su"
;;

void*:install)
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}xbps-install $system_packages"
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}xbps-install $options $system_packages"
;;
*conda*:install)
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && echo "${PROMPT}conda install $system_packages"
;;
homebrew*:install)
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ setenv =
maximal: TYPE_PATTERN=@(standard|optional)
# local envs need HOME set, also Docker 19.03 needs HOME
{local,docker}: HOME={envdir}
# for local envs we can guess the package system if it is not provided as a factor
local: SYSTEM=$(build/bin/sage-guess-package-system)
#
# default tag is "latest"
#
Expand Down Expand Up @@ -409,6 +411,14 @@ commands =
local-conda-standard: bash -c 'PACKAGES=`sed "s/#.*//;" build/pkgs/*/distros/conda.txt`; {env:SETENV} && {env:CONDA_PREFIX}/bin/conda install --yes --quiet $PACKAGES'
local-conda-maximal: bash -c 'PACKAGES=`sed "s/#.*//;" build/pkgs/*/distros/conda.txt`; {env:SETENV} && {env:CONDA_PREFIX}/bin/conda install --yes --quiet $PACKAGES'
#
# local-sudo
#
local-sudo: bash -c '$(build/bin/sage-print-system-package-command {env:SYSTEM} update) #'
local-sudo: bash -c 'PACKAGES=`sed "s/#.*//;" build/pkgs/{env:SYSTEM}*.txt`; $(build/bin/sage-print-system-package-command {env:SYSTEM} --sudo --yes --no-install-recommends install $PACKAGES) || [ "$IGNORE_MISSING_SYSTEM_PACKAGES" = yes ] && echo "(ignoring errors)" '
# -standard and -maximal are for now the same. This should be fixed when refactoring write-dockerfile.
local-sudo-standard: bash -c 'PACKAGES=`sed "s/#.*//;" build/pkgs/*/distros/{env:SYSTEM}.txt`; $(build/bin/sage-print-system-package-command {env:SYSTEM} --sudo --yes --no-install-recommends install $PACKAGES) || [ "$IGNORE_MISSING_SYSTEM_PACKAGES" = yes ] && echo "(ignoring errors)" '
local-sudo-maximal: bash -c 'PACKAGES=`sed "s/#.*//;" build/pkgs/*/distros/{env:SYSTEM}.txt`; $(build/bin/sage-print-system-package-command {env:SYSTEM} --sudo --yes --no-install-recommends install $PACKAGES) || [ "$IGNORE_MISSING_SYSTEM_PACKAGES" = yes ] && echo "(ignoring errors)" '
#
# All "local" environments
#
# Install symbolic links "config.log" and "logs" in SAGE_ROOT so that log files are written into the tox log directory.
Expand Down

0 comments on commit 40c1674

Please sign in to comment.