2018-11-05 21:09:54 +00:00
#!/usr/bin/env python
2019-02-14 11:17:52 +00:00
import os
import sys
2018-11-05 21:09:54 +00:00
import ci_lib
2018-11-06 13:47:09 +00:00
batches = [ ]
2019-02-14 11:17:52 +00:00
2019-05-27 21:27:50 +00:00
if 0 and os . uname ( ) [ 0 ] == ' Linux ' :
2019-05-26 11:14:31 +00:00
batches + = [
[
" sudo chown `whoami`: ~ " ,
" chmod u=rwx,g=rx,o= ~ " ,
2019-05-26 11:06:14 +00:00
2019-05-26 11:14:31 +00:00
" sudo mkdir /var/run/sshd " ,
" sudo /etc/init.d/ssh start " ,
2019-05-26 11:06:14 +00:00
2019-05-26 11:14:31 +00:00
" mkdir -p ~/.ssh " ,
" chmod u=rwx,go= ~/.ssh " ,
2019-05-26 11:06:14 +00:00
2019-05-26 11:14:31 +00:00
" ssh-keyscan -H localhost >> ~/.ssh/known_hosts " ,
" chmod u=rw,go= ~/.ssh/known_hosts " ,
2019-05-26 11:06:14 +00:00
2019-05-26 11:14:31 +00:00
" cat tests/data/docker/mitogen__has_sudo_pubkey.key > ~/.ssh/id_rsa " ,
" chmod u=rw,go= ~/.ssh/id_rsa " ,
2019-05-26 11:06:14 +00:00
2019-05-26 11:14:31 +00:00
" cat tests/data/docker/mitogen__has_sudo_pubkey.key.pub > ~/.ssh/authorized_keys " ,
" chmod u=rw,go=r ~/.ssh/authorized_keys " ,
]
2019-05-26 11:06:14 +00:00
]
2020-09-23 03:44:46 +00:00
# @dw: The VSTS-shipped Pythons available via UsePythonVErsion are pure garbage,
# broken symlinks, incorrect permissions and missing codecs. So we use the
# deadsnakes PPA to get sane Pythons, and setup a virtualenv to install our
# stuff into. The virtualenv can probably be removed again, but this was a
# hard-fought battle and for now I am tired of this crap.
2019-02-14 11:17:52 +00:00
if ci_lib . have_apt ( ) :
batches . append ( [
' echo force-unsafe-io | sudo tee /etc/dpkg/dpkg.cfg.d/nosync ' ,
' sudo add-apt-repository ppa:deadsnakes/ppa ' ,
' sudo apt-get update ' ,
2019-05-26 11:06:14 +00:00
' sudo apt-get -y install '
' python {pv} '
' python {pv} -dev '
' libsasl2-dev '
' libldap2-dev '
2020-09-23 03:44:46 +00:00
. format ( pv = os . environ [ ' PYTHONVERSION ' ] ) ,
' sudo ln -fs /usr/bin/python {pv} /usr/local/bin/python {pv} '
. format ( pv = os . environ [ ' PYTHONVERSION ' ] )
2019-02-14 11:17:52 +00:00
] )
2020-09-23 03:44:46 +00:00
# Mac's System Integrity Protection prevents symlinking /usr/bin
# and Azure isn't allowing disabling it apparently: https://developercommunityapi.westus.cloudapp.azure.com/idea/558702/allow-disabling-sip-on-microsoft-hosted-macos-agen.html
# so we'll use /usr/local/bin/python for everything
if ci_lib . have_brew ( ) :
batches . append ( [
' brew install python@ {pv} '
. format ( pv = os . environ [ ' PYTHONVERSION ' ] )
] )
# setup venv
# need wheel before building virtualenv because of bdist_wheel and setuptools deps
venv_steps = [ ' /usr/local/bin/python {pv} -m pip install -U pip wheel setuptools ' ]
if os . environ [ ' PYTHONVERSION ' ] . startswith ( ' 2 ' ) :
venv_steps . extend ( [
2020-09-23 04:14:40 +00:00
' /usr/local/bin/python {pv} -m pip install -U virtualenv ' . format ( py = os . environ [ ' PYTHONVERSION ' ] ) ,
2020-09-23 03:44:46 +00:00
' /usr/local/bin/python {pv} -m virtualenv /tmp/venv -p /usr/local/bin/python {pv} ' . format ( py = os . environ [ ' PYTHONVERSION ' ] )
] )
else :
2020-09-23 04:24:24 +00:00
venv_steps . append ( ' /usr/local/bin/python {pv} -m venv /tmp/venv ' . format ( py = os . environ [ ' PYTHONVERSION ' ] ) )
2020-09-23 03:44:46 +00:00
batches . append ( venv_steps )
2019-02-14 11:17:52 +00:00
if ci_lib . have_docker ( ) :
batches . extend (
[ ' docker pull %s ' % ( ci_lib . image_for_distro ( distro ) , ) ]
for distro in ci_lib . DISTROS
)
2018-11-05 21:09:54 +00:00
2018-11-06 13:47:09 +00:00
ci_lib . run_batches ( batches )