Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit deb84cd

Browse files
author
Matthias Koeppe
committed
sage-print-system-package-command: More options, update uses
1 parent 66c07d8 commit deb84cd

File tree

3 files changed

+76
-43
lines changed

3 files changed

+76
-43
lines changed
Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,85 @@
11
#!/usr/bin/env bash
22
#
33
system=$1
4-
command=$2
5-
if [ -z "$system" -o -z "$command" ]; then
6-
echo >&2 "usage: $0 {debian|arch|conda|...} {install|remove|...} PACKAGES..."
7-
exit 1
8-
fi
9-
shift 2
10-
system_packages="$*"
11-
shopt -s extglob
12-
if [ -n "$system_packages" ]; then
13-
# No command needed to install nothing
14-
case $system:$command in
15-
debian*|ubuntu*)
16-
echo "sudo apt-get $command $system_packages"
17-
;;
18-
@(fedora*|redhat*|centos*):install)
19-
echo "sudo yum install $system_packages"
20-
;;
21-
arch*:install)
22-
echo "sudo pacman -S $system_packages"
4+
shift
5+
IF_VERBOSE=:
6+
SUDO=
7+
PROMPT=
8+
while :
9+
do
10+
case "$1" in
11+
--verbose)
12+
IF_VERBOSE=
2313
;;
24-
*conda*:install)
25-
echo "conda install $system_packages"
14+
--sudo)
15+
# Whether to print sudo for package managers that need sudo for non-root users
16+
SUDO="sudo "
2617
;;
27-
homebrew*:install)
28-
echo "brew install $system_packages"
29-
echo "# Afterwards: "
18+
--prompt)
19+
PROMPT=' $ '
3020
;;
31-
slackware*:install)
32-
echo "sudo slackpkg install $system_packages"
33-
;;
34-
cygwin*:install)
35-
echo "# first install apt-cyg from https://github.com/transcode-open/apt-cyg"
36-
echo "apt-cyg install $system_packages"
21+
-*)
22+
echo >&2 "$0: unknown option $2"
23+
exit 1
3724
;;
3825
*)
39-
echo "# $command the following packages: $system_packages"
40-
;;
26+
break
4127
esac
28+
shift
29+
done
30+
command=$1
31+
shift
32+
if [ -z "$system" -o -z "$command" ]; then
33+
echo >&2 "usage: $0 {debian|arch|conda|...} [--verbose] [--sudo] [--prompt] {update|install|setup-build-env|remove|...} PACKAGES..."
34+
exit 1
4235
fi
43-
# Messages that should go out even if not packages need to be installed
36+
system_packages="$*"
37+
shopt -s extglob
4438
case $system:$command in
45-
homebrew*:install)
46-
echo "# To automatically take care of homebrew messages regarding "
47-
echo "# keg-only packages for the current shell session:"
39+
homebrew*:setup-build-env)
40+
$IF_VERBOSE echo "# To automatically take care of homebrew messages regarding "
41+
$IF_VERBOSE echo "# keg-only packages for the current shell session:"
4842
[ -n "$SAGE_ROOT" ] || SAGE_ROOT=.
49-
echo "# $ source $SAGE_ROOT/.homebrew-build-env"
50-
echo "# Add this to your shell profile if you want it to persist between shell sessions."
43+
echo "${PROMPT}source $SAGE_ROOT/.homebrew-build-env"
44+
$IF_VERBOSE echo "# Add this to your shell profile if you want it to persist between shell sessions."
45+
;;
46+
*:setup-build-env)
47+
# Nothing needed
48+
;;
49+
#
50+
# Verbs handled above are our own inventions. Verbs handled below are apt-get verbs.
51+
#
52+
@(debian*|ubuntu*):update)
53+
echo "${PROMPT}${SUDO}apt-get $command $system_packages"
54+
;;
55+
@(debian*|ubuntu*):*)
56+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}apt-get $command $system_packages"
57+
;;
58+
@(fedora*|redhat*|centos*):install)
59+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}yum install $system_packages"
60+
;;
61+
arch*:install)
62+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}pacman -S $system_packages"
63+
;;
64+
*conda*:install)
65+
[ -n "$system_packages" ] && echo "${PROMPT}conda install $system_packages"
66+
;;
67+
homebrew*:install)
68+
[ -n "$system_packages" ] && echo "${PROMPT}brew install $system_packages"
69+
;;
70+
slackware*:install)
71+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}slackpkg install $system_packages"
72+
;;
73+
cygwin*:update)
74+
echo "# first install apt-cyg from https://github.com/transcode-open/apt-cyg"
75+
;;
76+
cygwin*:install)
77+
[ -n "$system_packages" ] && echo "${PROMPT}apt-cyg install $system_packages"
78+
;;
79+
*:update)
80+
# Nothing needed
81+
;;
82+
*)
83+
echo "# $command the following packages: $system_packages"
5184
;;
5285
esac

m4/sage_spkg_collect.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ AC_DEFUN([SAGE_SYSTEM_PACKAGE_NOTICE], [
318318
AS_IF([test $SYSTEM != unknown], [
319319
SYSTEM_PACKAGES=$(build/bin/sage-get-system-packages $SYSTEM $SAGE_NEED_SYSTEM_PACKAGES)
320320
AS_IF([test -n "$SYSTEM_PACKAGES"], [
321-
COMMAND=$(SAGE_ROOT=$SAGE_ROOT build/bin/sage-print-system-package-command $SYSTEM install $SYSTEM_PACKAGES)
321+
PRINT_SYS="build/bin/sage-print-system-package-command $SYSTEM --verbose --prompt --sudo"
322+
COMMAND=$($PRINT_SYS update && $PRINT_SYS install $SYSTEM_PACKAGES && SAGE_ROOT=$SAGE_ROOT $PRINT_SYS setup-build-env )
322323
AC_MSG_NOTICE([hint: installing the following system packages is recommended and may avoid building some of the above SPKGs from source:])
323-
AC_MSG_NOTICE([ \$ $COMMAND])
324+
AC_MSG_NOTICE([$COMMAND])
324325
AC_MSG_NOTICE([After installation, re-run configure using:])
325326
AC_MSG_NOTICE([ \$ ./config.status --recheck && ./config.status])
326327
], [

src/doc/bootstrap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ fi
1616

1717
cd "$SAGE_ROOT"
1818

19-
PROMPT=' $ '
2019
STRIP_COMMENTS="sed s/#.*//;"
2120
OUTPUT_DIR="src/doc/en/installation"
2221
mkdir -p "$OUTPUT_DIR"
@@ -46,6 +45,6 @@ for SYSTEM in arch debian fedora cygwin homebrew; do
4645
fi
4746
done
4847
echo >&2 $0:$LINENO: installing "$OUTPUT_DIR"/$SYSTEM.txt and "$OUTPUT_DIR"/$SYSTEM-optional.txt
49-
echo "$PROMPT$(sage-print-system-package-command $SYSTEM install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM.txt
50-
echo "$PROMPT$(sage-print-system-package-command $SYSTEM install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
48+
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM.txt
49+
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
5150
done

0 commit comments

Comments
 (0)