Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roadlib setup.py creates libs in wrong directories #104

Open
D3vil0p3r opened this issue Oct 4, 2024 · 6 comments
Open

roadlib setup.py creates libs in wrong directories #104

D3vil0p3r opened this issue Oct 4, 2024 · 6 comments

Comments

@D3vil0p3r
Copy link

Hello,
when I try to build and install roadlib, I note that the .py files are placed in the wrong non-standard python path. Specifically, after the install, the roadlib structure appears to be:

[  30]  /usr/lib/python3.12/site-packages/roadlib-0.27.0-py3.12.egg/
├── [ 152]  EGG-INFO/
│   ├── [   1]  dependency_links.txt
│   ├── [   1]  not-zip-safe
│   ├── [ 710]  PKG-INFO
│   ├── [  32]  requires.txt
│   ├── [ 307]  SOURCES.txt
│   └── [   8]  top_level.txt
└── [ 144]  roadtools/roadlib/
    ├── [ 628]  __pycache__/
    │   ├── [ 74K]  auth.cpython-312.opt-1.pyc
    │   ├── [ 74K]  auth.cpython-312.pyc
    │   ├── [6.2K]  constants.cpython-312.opt-1.pyc
    │   ├── [6.2K]  constants.cpython-312.pyc
    │   ├── [ 11K]  dbgen.cpython-312.opt-1.pyc
    │   ├── [ 11K]  dbgen.cpython-312.pyc
    │   ├── [ 42K]  deviceauth.cpython-312.opt-1.pyc
    │   ├── [ 42K]  deviceauth.cpython-312.pyc
    │   ├── [ 176]  __init__.cpython-312.opt-1.pyc
    │   ├── [ 176]  __init__.cpython-312.pyc
    │   ├── [3.9K]  metagen.cpython-312.opt-1.pyc
    │   └── [3.9K]  metagen.cpython-312.pyc
    ├── [ 67K]  auth.py
    ├── [6.4K]  constants.py
    ├── [ 12K]  dbgen.py
    ├── [ 38K]  deviceauth.py
    ├── [   0]  __init__.py
    └── [2.7K]  metagen.py

so the libs are placed inside the EGG directory that is not correct. In this manner, any attempt to create a Linux package for it could fail.

Is it possible to implement for roadlib and other roadtools the correct installation path as two separated directories, one for libs and one for egg-info, structured as:

[  30]  /usr/lib/python3.12/site-packages/roadlib-0.27.0-py3.12.egg/
│   ├── [   1]  dependency_links.txt
│   ├── [   1]  not-zip-safe
│   ├── [ 710]  PKG-INFO
│   ├── [  32]  requires.txt
│   ├── [ 307]  SOURCES.txt
│   └── [   8]  top_level.txt
 [ 144] /usr/lib/python3.12/site-packages/roadtools/roadlib/
    ├── [ 628]  __pycache__/
    │   ├── [ 74K]  auth.cpython-312.opt-1.pyc
    │   ├── [ 74K]  auth.cpython-312.pyc
    │   ├── [6.2K]  constants.cpython-312.opt-1.pyc
    │   ├── [6.2K]  constants.cpython-312.pyc
    │   ├── [ 11K]  dbgen.cpython-312.opt-1.pyc
    │   ├── [ 11K]  dbgen.cpython-312.pyc
    │   ├── [ 42K]  deviceauth.cpython-312.opt-1.pyc
    │   ├── [ 42K]  deviceauth.cpython-312.pyc
    │   ├── [ 176]  __init__.cpython-312.opt-1.pyc
    │   ├── [ 176]  __init__.cpython-312.pyc
    │   ├── [3.9K]  metagen.cpython-312.opt-1.pyc
    │   └── [3.9K]  metagen.cpython-312.pyc
    ├── [ 67K]  auth.py
    ├── [6.4K]  constants.py
    ├── [ 12K]  dbgen.py
    ├── [ 38K]  deviceauth.py
    ├── [   0]  __init__.py
    └── [2.7K]  metagen.py

Not sure if roadlib should be inside roadtools folder or not...

@dirkjanm
Copy link
Owner

dirkjanm commented Oct 4, 2024

hey, that must be the way you install the tool. Installing via setup.py install is deprecated in general and shouldn't be used. Installing via pip install as listed in the readme doesn't create egg folders.

@D3vil0p3r
Copy link
Author

hey, that must be the way you install the tool. Installing via setup.py install is deprecated in general and shouldn't be used. Installing via pip install as listed in the readme doesn't create egg folders.

I'm trying to package the tools for several Linux distros and I cannot use pip install sadly. Since setup.py is deprecated, what if you migrate to PEP517?

@dirkjanm
Copy link
Owner

dirkjanm commented Oct 4, 2024

Both python setup.py sdist and python -m build create sdists and wheels that confirm to the desired directory structure, would that work for your purposes?

@D3vil0p3r
Copy link
Author

@noraj what do you think?

The current PKGBUILD I'm working on is:

# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=roadtools
_pkgbase=ROADtools
pkgname=('python-roadlib' 'roadrecon' 'roadoidc' 'roadtx')
pkgver=310.03f15f5
pkgrel=1
pkgdesc='Azure AD and O365 exploration framework'
arch=('any')
groups=('blackarch' 'blackarch-networking' 'blackarch-recon')
url='https://github.com/dirkjanm/ROADtools'
license=('MIT')
makedepends=('python-setuptools' 'git')
source=("git+https://github.com/dirkjanm/$_pkgbase.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgbase

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build_python-roadlib() {
  cd "$_pkgbase/roadlib"

  python setup.py build
}

build_roadrecon() {
  cd "$_pkgbase/roadrecon"

  python setup.py build
}

build_python-roadtx() {
  cd "$_pkgbase/roadtx"

  python setup.py build
}

package_python-roadlib() {
  depends=('python' 'python-adal' 'python-sqlalchemy' 'python-pyjwt')

  cd "$_pkgbase/roadlib"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

package_roadoidc() {
  depends=('python' 'python-roadlib' 'roadtx' 'python-flask' 'python-cryptography' 'python-requests' 'python-werkzeug')

  cd "$_pkgbase/roadoidc"

  install -dm 755 "$pkgdir/usr/bin"
  install -Dm 644 requirements.txt "$pkgdir/usr/share/$pkgname/requirements.txt"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/genconfig" << EOF
#!/bin/sh
exec python /usr/share/$pkgname/genconfig.py "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/genconfig"
}

package_roadrecon() {
  depends=('python' 'python-roadlib' 'python-flask' 'python-sqlalchemy'
           'python-marshmallow' 'python-flask-sqlalchemy'
           'python-flask-marshmallow' 'python-flask-cors'
           'python-marshmallow-sqlalchemy' 'python-aiohttp')

  cd "$_pkgbase/roadrecon"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

package_roadtx() {
  depends=('python' 'python-requests' 'python-selenium' 'python-selenium-wire' 'python-pyotp' 'python-pycryptodomex' 'python-blinker')

  cd "$_pkgbase/roadtx"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

@noraj
Copy link

noraj commented Oct 6, 2024

If python setup.py <build|install> (setuptools) won't work, then try PEP517 PKGBUILD template. It may work even without pyproject.toml.

@D3vil0p3r
Copy link
Author

It does not seem to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants