11#! /bin/bash
22
3- set -eou pipefail - x
3+ set -eou pipefail + x
44
55REL_PATH=$( pwd $( dirname $0 ) )
66ERR_STACKSTORM_VERSION=$( python << EOF
3232#
3333# https://gist.github.com/fernandoaleman/1377211/d78d13bd8f134e7d9b9bc3da5895c859d7cbf294
3434# https://gist.githubusercontent.com/fernandoaleman/1377169/raw/3e841ca1a887dd21f3fcb35a3e74b0cc2fc4977b/create-repo-metadata.sh
35+ # https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory
36+ #
3537function title
3638{
3739 echo -e " \033[38;5;206;48;5;57m${1} \033[0m"
@@ -82,61 +84,24 @@ function create_virtual_environment
8284 done
8385}
8486
85- function fetch_archives
86- {
87- title " DOWNLOAD ARCHIVES"
88- export BACKENDS=(" err-backend-discord" " err-backend-slackv3" " err-backend-gitter" " err-backend-mattermost" " err-backend-botframework" )
89-
90- test -d " ${BUILD_DIR} /backends" || mkdir " ${BUILD_DIR} /backends"
91- cd " ${BUILD_DIR} "
92- wget " https://github.com/errbotio/err-backend-discord/archive/refs/tags/v4.0.0.tar.gz" -O " backends/err-backend-discord-v4.0.0.tar.gz"
93- wget " https://github.com/errbotio/err-backend-slackv3/archive/refs/tags/v0.3.1.tar.gz" -O " backends/err-backend-slackv3-v0.3.1.tar.gz"
94- wget " https://github.com/errbotio/err-backend-mattermost/archive/refs/tags/3.0.0.tar.gz" -O " backends/err-backend-mattermost-v3.0.0.tar.gz"
95- wget " https://github.com/nzlosh/err-backend-gitter/archive/refs/tags/v0.1.0.tar.gz" -O " backends/err-backend-gitter-v0.1.0.tar.gz"
96- wget " https://github.com/nzlosh/err-backend-botframework/archive/refs/tags/v0.1.0.tar.gz" -O " backends/err-backend-botframework-v0.1.0.tar.gz"
97-
98- mkdir " ${BUILD_DIR} /plugins"
99- export PLUGINS=(" err-stackstorm" )
100- wget " https://github.com/nzlosh/err-stackstorm/archive/refs/tags/v${ERR_STACKSTORM_VERSION} .tar.gz" -O " plugins/err-stackstorm-v${ERR_STACKSTORM_VERSION} .tar.gz"
101- }
10287
103- function install_extensions
88+ function install_python_packages
10489{
105- title " INSTALL ERRBOT EXTENSIONS"
106- for location in backends plugins
107- do
108- # extract
109- for targz in " ${BUILD_DIR} /${location} " /* .tar.gz
110- do
111- tar xf " $targz " -C " ${ROOT} /${location} "
112- done
113- # install dependencies
114- for proj in " ${ROOT} /${location} " /*
115- do
116- # Install from pyproject
117- test -f " ${proj} /pyproject.toml" && pip install " ${proj} "
118- # Install from requirements
119- test -f " ${proj} /requirements.txt" && pip install -r " ${proj} /requirements.txt"
120- done
121- done
122-
123- for location in " ${ROOT} /backends"
90+ title " INSTALL ERRBOT PYTHON PACKAGES"
91+
92+ PKGS=(
93+ " errbot[IRC,XMPP,telegram]==${ERRBOT_VERSION} "
94+ " err-backend-discord"
95+ " errbot-backend-slackv3"
96+ " err-backend-mattermost"
97+ " git+https://github.com/nzlosh/err-backend-gitter@maint_nzlosh"
98+ # "git+https://github.com/nzlosh/err-backend-botframework"
99+ " err-stackstorm==${ERR_STACKSTORM_VERSION} "
100+ )
101+
102+ for pkg in ${PKGS[@]}
124103 do
125- cd " ${location} "
126- for backend in " ${BACKENDS[@]} "
127- do
128- # Move archive directory names to correct errbot names.
129- mv -f ./* " ${backend} " * " $backend "
130- done
131- done
132-
133- for location in " $ROOT /plugins"
134- do
135- cd " $location "
136- for plugin in " ${PLUGINS[@]} "
137- do
138- mv -f ./* " ${plugin} " * " $plugin "
139- done
104+ pip install " $pkg "
140105 done
141106}
142107
@@ -167,28 +132,20 @@ function prune_installation
167132 done
168133 # remove python build backend directory
169134 rm -rf " $ROOT " /{plugins,backends}/* /build
170- # Remove temp build dir
171- rm -rf " $BUILD_DIR "
172135}
173136
174137
175138
176139function install_errbot
177140{
178- title " INSTALL ERRBOT ( $ ($ROOT /venv/bin/pip --version) )"
141+ title " INSTALL ERRBOT ${ERRBOT_VERSION} $ ($ROOT /venv/bin/pip --version) "
179142 source " ${ROOT} /venv/bin/activate"
180143
144+ # source from stack overflow article (virtualenv site directory).
145+ export VENV_SITE_DIR=$( python3 -c ' import sysconfig; print(sysconfig.get_paths()["purelib"])' )
146+
181147 pip install --upgrade pip
182- # Use tmp dir to download and build errbot/plugins.
183- export BUILD_DIR=$( mktemp -d " $ROOT " /build.XXXXXX)
184- cd " $BUILD_DIR "
185- ERRBOT_VERSION=" 6.2.0"
186- wget " https://github.com/errbotio/errbot/archive/refs/tags/${ERRBOT_VERSION} .tar.gz" -O errbot-v${ERRBOT_VERSION} .tar.gz
187- tar xf errbot-v${ERRBOT_VERSION} .tar.gz
188- cd errbot-${ERRBOT_VERSION}
189- pip install .[IRC,XMPP,telegram]
190- fetch_archives
191- install_extensions
148+ install_python_packages
192149 prune_installation
193150}
194151
@@ -206,6 +163,7 @@ export DISTRO_VERSION=$(source /etc/os-release; echo $VERSION_ID)
206163# Strip the minor version since the script is designed to work on major versions.
207164export DISTRO_COMBO=" ${DISTRO}${DISTRO_VERSION% .* } "
208165export ROOT=" /opt/errbot"
166+ export ERRBOT_VERSION=" 6.2.0"
209167
210168case " ${DISTRO_COMBO} " in
211169 rocky8)
0 commit comments