Skip to content

Commit 7d31422

Browse files
committed
Update install endpoint for BG installer
1 parent d7e1f60 commit 7d31422

File tree

4 files changed

+62
-58
lines changed

4 files changed

+62
-58
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
Stable library from PyPi:
1111

12-
* Just run `sudo pip install pimoroni-sgp30`
12+
* Just run `python3 -m pip install pimoroni-sgp30`
1313

1414
Latest/development library from GitHub:
1515

1616
* `git clone https://github.com/pimoroni/sgp30-python`
1717
* `cd sgp30-python`
18-
* `sudo ./install.sh`
18+
* `sudo ./install.sh --unstable`
1919

install-bullseye.sh renamed to install-legacy.sh

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
CONFIG=/boot/config.txt
34
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
45
CONFIG_BACKUP=false
@@ -8,16 +9,14 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
89
WD=`pwd`
910
USAGE="sudo ./install.sh (--unstable)"
1011
POSITIONAL_ARGS=()
12+
FORCE=false
1113
UNSTABLE=false
12-
PYTHON="/usr/bin/python3"
1314
CODENAME=`lsb_release -sc`
1415

15-
distro_check() {
16-
if [[ $CODENAME != "bullseye" ]]; then
17-
printf "This installer is for Raspberry Pi OS: Bullseye only, current distro: $CODENAME\n"
18-
exit 1
19-
fi
20-
}
16+
if [[ $CODENAME == "bullseye" ]]; then
17+
bash ./install.sh $@
18+
exit $?
19+
fi
2120

2221
user_check() {
2322
if [ $(id -u) -ne 0 ]; then
@@ -27,7 +26,7 @@ user_check() {
2726
}
2827

2928
confirm() {
30-
if [ "$FORCE" == '-y' ]; then
29+
if $FORCE; then
3130
true
3231
else
3332
read -r -p "$1 [y/N] " response < /dev/tty
@@ -107,9 +106,8 @@ while [[ $# -gt 0 ]]; do
107106
UNSTABLE=true
108107
shift
109108
;;
110-
-p|--python)
111-
PYTHON=$2
112-
shift
109+
-f|--force)
110+
FORCE=true
113111
shift
114112
;;
115113
*)
@@ -123,21 +121,11 @@ while [[ $# -gt 0 ]]; do
123121
esac
124122
done
125123

126-
distro_check
127124
user_check
128125

129-
if [ ! -f "$PYTHON" ]; then
130-
printf "Python path $PYTHON not found!\n"
131-
exit 1
132-
fi
133-
134-
PYTHON_VER=`$PYTHON --version`
135-
136-
inform "Installing. Please wait..."
126+
apt_pkg_install python-configparser
137127

138-
$PYTHON -m pip install --upgrade configparser
139-
140-
CONFIG_VARS=`$PYTHON - <<EOF
128+
CONFIG_VARS=`python - <<EOF
141129
from configparser import ConfigParser
142130
c = ConfigParser()
143131
c.read('library/setup.cfg')
@@ -190,16 +178,30 @@ fi
190178
191179
cd library
192180
193-
printf "Installing for $PYTHON_VER...\n"
194-
apt_pkg_install "${PY3_DEPS[@]}"
181+
printf "Installing for Python 2..\n"
182+
apt_pkg_install "${PY2_DEPS[@]}"
195183
if $UNSTABLE; then
196-
$PYTHON setup.py install > /dev/null
184+
python setup.py install > /dev/null
197185
else
198-
$PYTHON -m pip install --upgrade $LIBRARY_NAME
186+
pip install --upgrade $LIBRARY_NAME
199187
fi
200188
if [ $? -eq 0 ]; then
201189
success "Done!\n"
202-
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
190+
echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
191+
fi
192+
193+
if [ -f "/usr/bin/python3" ]; then
194+
printf "Installing for Python 3..\n"
195+
apt_pkg_install "${PY3_DEPS[@]}"
196+
if $UNSTABLE; then
197+
python3 setup.py install > /dev/null
198+
else
199+
pip3 install --upgrade $LIBRARY_NAME
200+
fi
201+
if [ $? -eq 0 ]; then
202+
success "Done!\n"
203+
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
204+
fi
203205
fi
204206
205207
cd $WD

install.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
CONFIG=/boot/config.txt
43
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
54
CONFIG_BACKUP=false
@@ -9,13 +8,10 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
98
WD=`pwd`
109
USAGE="sudo ./install.sh (--unstable)"
1110
POSITIONAL_ARGS=()
11+
FORCE=false
1212
UNSTABLE=false
13-
CODENAME=`lsb_release -sc`
13+
PYTHON="/usr/bin/python3"
1414

15-
if [[ $CODENAME == "bullseye" ]]; then
16-
bash ./install-bullseye.sh
17-
exit $?
18-
fi
1915

2016
user_check() {
2117
if [ $(id -u) -ne 0 ]; then
@@ -25,7 +21,7 @@ user_check() {
2521
}
2622

2723
confirm() {
28-
if [ "$FORCE" == '-y' ]; then
24+
if $FORCE; then
2925
true
3026
else
3127
read -r -p "$1 [y/N] " response < /dev/tty
@@ -105,6 +101,15 @@ while [[ $# -gt 0 ]]; do
105101
UNSTABLE=true
106102
shift
107103
;;
104+
-f|--force)
105+
FORCE=true
106+
shift
107+
;;
108+
-p|--python)
109+
PYTHON=$2
110+
shift
111+
shift
112+
;;
108113
*)
109114
if [[ $1 == -* ]]; then
110115
printf "Unrecognised option: $1\n";
@@ -118,9 +123,18 @@ done
118123

119124
user_check
120125

121-
apt_pkg_install python-configparser
126+
if [ ! -f "$PYTHON" ]; then
127+
printf "Python path $PYTHON not found!\n"
128+
exit 1
129+
fi
122130

123-
CONFIG_VARS=`python - <<EOF
131+
PYTHON_VER=`$PYTHON --version`
132+
133+
inform "Installing. Please wait..."
134+
135+
$PYTHON -m pip install --upgrade configparser
136+
137+
CONFIG_VARS=`$PYTHON - <<EOF
124138
from configparser import ConfigParser
125139
c = ConfigParser()
126140
c.read('library/setup.cfg')
@@ -173,30 +187,16 @@ fi
173187
174188
cd library
175189
176-
printf "Installing for Python 2..\n"
177-
apt_pkg_install "${PY2_DEPS[@]}"
190+
printf "Installing for $PYTHON_VER...\n"
191+
apt_pkg_install "${PY3_DEPS[@]}"
178192
if $UNSTABLE; then
179-
python setup.py install > /dev/null
193+
$PYTHON setup.py install > /dev/null
180194
else
181-
pip install --upgrade $LIBRARY_NAME
195+
$PYTHON -m pip install --upgrade $LIBRARY_NAME
182196
fi
183197
if [ $? -eq 0 ]; then
184198
success "Done!\n"
185-
echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
186-
fi
187-
188-
if [ -f "/usr/bin/python3" ]; then
189-
printf "Installing for Python 3..\n"
190-
apt_pkg_install "${PY3_DEPS[@]}"
191-
if $UNSTABLE; then
192-
python3 setup.py install > /dev/null
193-
else
194-
pip3 install --upgrade $LIBRARY_NAME
195-
fi
196-
if [ $? -eq 0 ]; then
197-
success "Done!\n"
198-
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
199-
fi
199+
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
200200
fi
201201
202202
cd $WD

library/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ py2deps =
4545
py3deps =
4646
configtxt =
4747
commands =
48+
printf "Setting up i2c..\n"
49+
raspi-config nonint do_i2c 0

0 commit comments

Comments
 (0)