xref: /aosp_15_r20/external/scapy/.travis/install.sh (revision 7dc08ffc4802948ccbc861daaf1e81c405c2c4bd)
1*7dc08ffcSJunyu LaiPIP=`which pip || (python --version 2>&1 | grep -q 'Python 2' && which pip2) || (python --version 2>&1 | grep -q 'Python 3' && which pip3)`
2*7dc08ffcSJunyu Lai
3*7dc08ffcSJunyu Lai# Install dependencies using pip
4*7dc08ffcSJunyu Laiif [ -z "$SCAPY_SUDO" -o "$SCAPY_SUDO" = "false" ]
5*7dc08ffcSJunyu Laithen
6*7dc08ffcSJunyu Lai  SCAPY_SUDO=""
7*7dc08ffcSJunyu Lai  if [ "$TRAVIS_OS_NAME" = "osx" ]
8*7dc08ffcSJunyu Lai  then
9*7dc08ffcSJunyu Lai    PIP_INSTALL_FLAGS="--user"
10*7dc08ffcSJunyu Lai  fi
11*7dc08ffcSJunyu Laielse
12*7dc08ffcSJunyu Lai  SCAPY_SUDO="$SCAPY_SUDO -H"
13*7dc08ffcSJunyu Laifi
14*7dc08ffcSJunyu Lai
15*7dc08ffcSJunyu Lai$SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U mock
16*7dc08ffcSJunyu Lai
17*7dc08ffcSJunyu Laiif python --version 2>&1 | grep -q '^Python 3\.[0123]'
18*7dc08ffcSJunyu Laithen
19*7dc08ffcSJunyu Lai  # cryptography with Python 3 < 3.4 requires enum34
20*7dc08ffcSJunyu Lai  $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U enum34
21*7dc08ffcSJunyu Laifi
22*7dc08ffcSJunyu Lai
23*7dc08ffcSJunyu Laiif ! python --version 2>&1 | grep -q PyPy; then
24*7dc08ffcSJunyu Lai  # cryptography requires PyPy >= 2.6, Travis CI uses 2.5.0
25*7dc08ffcSJunyu Lai  $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U cryptography
26*7dc08ffcSJunyu Laifi
27*7dc08ffcSJunyu Lai
28*7dc08ffcSJunyu Lai# Install coverage
29*7dc08ffcSJunyu Laiif [ "$SCAPY_COVERAGE" = "yes" ]
30*7dc08ffcSJunyu Laithen
31*7dc08ffcSJunyu Lai  $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U coverage
32*7dc08ffcSJunyu Lai  $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U PyX
33*7dc08ffcSJunyu Lai  $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U codecov
34*7dc08ffcSJunyu Laifi
35*7dc08ffcSJunyu Lai
36*7dc08ffcSJunyu Lai# Install pcap & dnet
37*7dc08ffcSJunyu Laiif [ ! -z $SCAPY_USE_PCAPDNET ]
38*7dc08ffcSJunyu Laithen
39*7dc08ffcSJunyu Lai  if [ "$TRAVIS_OS_NAME" = "linux" ]
40*7dc08ffcSJunyu Lai  then
41*7dc08ffcSJunyu Lai    $SCAPY_SUDO apt-get -qy install libdumbnet-dev libpcap-dev
42*7dc08ffcSJunyu Lai    # $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U pypcap  ## sr(timeout) HS
43*7dc08ffcSJunyu Lai    # $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U pcapy   ## sniff HS
44*7dc08ffcSJunyu Lai    # $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U pylibpcap  ## won't install
45*7dc08ffcSJunyu Lai    $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U http://http.debian.net/debian/pool/main/p/python-libpcap/python-libpcap_0.6.4.orig.tar.gz
46*7dc08ffcSJunyu Lai    $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U pydumbnet
47*7dc08ffcSJunyu Lai    # wget https://pypi.python.org/packages/71/60/15b9e0005bf9062bdc04fc8129b4cdb01cc4189a75719441ff2e23e55b15/dnet-real-1.12.tar.gz
48*7dc08ffcSJunyu Lai    # tar zxf dnet-real-1.12.tar.gz
49*7dc08ffcSJunyu Lai    # cd dnet-real-1.12
50*7dc08ffcSJunyu Lai    # sed -i 's/dnet\.h/dumbnet.h/; s/|Py_TPFLAGS_CHECKTYPES//g' dnet.c
51*7dc08ffcSJunyu Lai    # sed -i 's#dnet_extobj = \[\]#dnet_extobj = \["/usr/lib/libdumbnet.so"\]#' setup.py
52*7dc08ffcSJunyu Lai    # $SCAPY_SUDO $PIP install $PIP_INSTALL_FLAGS -U .
53*7dc08ffcSJunyu Lai    # cd ../
54*7dc08ffcSJunyu Lai  elif [ "$TRAVIS_OS_NAME" = "osx" ]
55*7dc08ffcSJunyu Lai  then
56*7dc08ffcSJunyu Lai    mkdir -p /Users/travis/Library/Python/2.7/lib/python/site-packages
57*7dc08ffcSJunyu Lai    echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/travis/Library/Python/2.7/lib/python/site-packages/homebrew.pth
58*7dc08ffcSJunyu Lai
59*7dc08ffcSJunyu Lai    brew update
60*7dc08ffcSJunyu Lai    brew install --with-python libdnet
61*7dc08ffcSJunyu Lai    brew install .travis/pylibpcap.rb
62*7dc08ffcSJunyu Lai  fi
63*7dc08ffcSJunyu Laifi
64*7dc08ffcSJunyu Lai
65*7dc08ffcSJunyu Lai# Install wireshark data
66*7dc08ffcSJunyu Laiif [ ! -z "$SCAPY_SUDO" ] && [ "$TRAVIS_OS_NAME" = "linux" ]
67*7dc08ffcSJunyu Laithen
68*7dc08ffcSJunyu Lai  $SCAPY_SUDO apt-get -qy install openssl libwireshark-data
69*7dc08ffcSJunyu Laifi
70