geohot / qira

QEMU Interactive Runtime Analyser
MIT License
3.95k stars 469 forks source link

Installing qira without installing qemu through qemu_build.sh #235

Open aumars opened 5 years ago

aumars commented 5 years ago

Continuing from #234, I used the following script to build and package qira.

build() {
  cd ${pkgname}-${pkgver}/qiradb
  python2 setup.py build
}

package() {
  cd ${pkgname}-${pkgver}

  pushd qiradb
  # python2 setup.py install -O1 --single-version-externally-managed --root="${pkgdir}"
  python2 setup.py install -O1 --root="${pkgdir}"
  popd

  mv qiradb/VERSION VERSION
  rm -r qiradb

  install -d "${pkgdir}/opt/${pkgname}"
  cp -r . "${pkgdir}/opt/${pkgname}"

  install -d "${pkgdir}/usr/bin"
  ln -s "/opt/${pkgname}/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"

  virtualenv2 venv
  source venv/bin/activate

  install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README"
}

However, when I run qira, it doesn't seem to import ipaddr in Python 2.7.

$ qira
Traceback (most recent call last):
  File "/opt/qira/middleware/qira.py", line 6, in <module>
    import ipaddr
ImportError: No module named ipaddr

This shouldn't be the case, importing ipaddr on a separate process works fine.

$ python2.7
Python 2.7.16 (default, Mar 11 2019, 18:59:25) 
[GCC 8.2.1 20181127] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddr
>>> 
aumars commented 5 years ago

Apparently it can't import from /usr/lib64/python2.7/site-packages.

aumars commented 5 years ago

I don't know if this is an issue for my arch or not but I temporarily fixed it by adding sys.path.append('/usr/lib64/python2.7/site-packages') or by running sed -i '/import sys/c\import sys\nsys.path.append('/usr/lib64/python2.7/site-packages')/' middleware/qira.py.