Skip to content

Commit

Permalink
Migrate to Python Standalone PKGBUILD (#4352)
Browse files Browse the repository at this point in the history
* mobsf: version bump

* lief: bump version and add python-lief

Added `python-lief` package.

* Update to-release

* Delete packages/mobsf/mobsf.install

* Update PKGBUILD

* Update PKGBUILD

* Create mobsf.install

* quickscope: add package

* Create quickscope.install

* Update to-release

* Update PKGBUILD

* Update PKGBUILD

* Update PKGBUILD

* Update PKGBUILD

* Update PKGBUILD

* Update PKGBUILD

* Fix LIEF

---------

Co-authored-by: noptrix <[email protected]>
  • Loading branch information
D3vil0p3r and noptrix authored Nov 22, 2024
1 parent 9f317b1 commit 6910cad
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 84 deletions.
67 changes: 40 additions & 27 deletions packages/lief/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=lief
pkgbase=lief
pkgname=(lief python-lief)
_pkgname=LIEF
pkgver=0.13.2
pkgrel=2
pkgdesc='Library to Instrument Executable Formats.'
pkgver=0.15.1
pkgrel=1
pkgdesc='Library to instrument executable formats.'
groups=('blackarch' 'blackarch-disassembler' 'blackarch-reversing')
arch=('x86_64' 'aarch64')
url='https://github.com/lief-project/LIEF/'
license=('Apache')
depends=('python')
makedepends=('python-setuptools' 'cmake' 'python-build' 'python-installer'
'python-wheel' 'ninja')
source=("https://github.com/lief-project/LIEF/archive/$pkgver.tar.gz")
sha512sums=('a8dce9cce9c68d93ec5d78cf9f67eb32dc11d4498c9903f61e34d48683905cdf8040630b390fdaefb66fd18213cdc81682b4acb24ce43fb7fe89202492f71660')
arch=('x86_64')
url='https://github.com/lief-project/lief'
license=('Apache-2.0')
depends=('tl-expected')
makedepends=('cmake' 'python' 'nlohmann-json' 'python-build' 'python-installer'
'python-wheel' 'python-tomli' 'python-scikit-build-core' 'ninja'
'python-cattrs' 'python-packaging' 'python-rich' 'python-setuptools'
'python-pydantic' 'python-pydantic-core' 'python-pyproject-metadata'
'python-pathspec')
provides=('libLIEF.so')
source=("https://github.com/lief-project/lief/archive/refs/tags/$pkgver.tar.gz")
sha512sums=('30f248ce5c77993ccc08a360bfd74562ff1e661233abf7e6017cd11351ee359c67848a1ac4159b82a38e971f41704a6008b8778c817e06ef558efe21b76e04ae')

prepare() {
cd "$_pkgname-$pkgver"

# tmp dirty fix! we need to change this asap
sed -i 's|version = "0.0.0"|version = "0.10.1"|' setup.py
cd "$_pkgname-$pkgver/api/python"

# fix for https://github.com/lief-project/LIEF/issues/918
sed -i '1 i\#include <cstdint>' include/LIEF/DEX/Field.hpp
sed -i 's/==.*//' build-requirements.txt
}

build() {
cd "$_pkgname-$pkgver"

PYTHONPATH="$PWD" python -m build api/python --wheel --no-isolation

cmake \
-B build \
-G Ninja \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D LIEF_EXAMPLES=OFF \
-D LIEF_PYTHON_API=ON \
-D LIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON \
-D LIEF_OPT_EXTERNAL_EXPECTED=ON
cmake --build build

cd api/python
python -m build --wheel --no-isolation
}

package() {
package_lief() {
cd "$_pkgname-$pkgver"

PYTHONHASHSEED=0 python -m installer --destdir="$pkgdir" api/python/dist/*.whl
DESTDIR="$pkgdir" cmake --install build
}

install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md AUTHORS \
CHANGELOG
package_python-lief() {
depends+=(python lief)

cd "$_pkgname-$pkgver/api/python"

for i in "$pkgdir/usr/bin/"*; do
mv $i $(echo $i | sed 's|_|-|g;s|.py||g')
done
python -m installer --destdir="$pkgdir" dist/*.whl
}

51 changes: 17 additions & 34 deletions packages/mobsf/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@
# See COPYING for license details.

pkgname=mobsf
pkgver=1975.3cf21cec
pkgver=v4.1.3.r7.g3cf21ce
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-mobile')
epoch=2
pkgdesc='An intelligent, all-in-one open source mobile application (Android/iOS) automated pen-testing framework capable of performing static, dynamic analysis and web API testing.'
arch=('any')
groups=('blackarch' 'blackarch-mobile')
url='https://github.com/MobSF/Mobile-Security-Framework-MobSF'
license=('GPL3')
depends=('python-django' 'python-lxml' 'python-rsa' 'python-biplist'
'python-requests' 'python-beautifulsoup4' 'python-colorlog'
'python-macholib' 'python-waitress' 'python-whitenoise' 'gunicorn'
'python-psutil' 'python-shelljob' 'libxslt' 'python-asn1crypto'
'python-oscrypto' 'python-distro' 'python-ip2location' 'lief'
'python-http-tools' 'python-libsast' 'python-pdfkit' 'wkhtmltopdf'
'python-google-play-scraper' 'androguard' 'apkid' 'quark-engine'
'python-frida' 'python-tldextract' 'python-openstep-parser'
'python-svgutils' 'python-arpy' 'python-django-ratelimit'
'python-paramiko' 'python-saml' 'python-ruamel-yaml' 'python-click'
'python-decorator' 'git' 'python' 'java-environment' 'libjpeg-turbo'
'python-virtualenv' 'python-pip' 'libffi' 'libxml2' 'python-apksigtool'
'python-tzdata' 'python-bcrypt' 'python-packaging' 'python-psycopg2')
license=('GPL-3.0-or-later')
depends=('python')
makedepends=('git' 'python-setuptools' 'python-pip')
source=("$pkgname::git+https://github.com/MobSF/Mobile-Security-Framework-MobSF.git")
sha512sums=('SKIP')
Expand All @@ -31,37 +19,32 @@ install="$pkgname.install"
pkgver() {
cd $pkgname

echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
cd $pkgname/$pkgname

sed -i 's/USE_HOME = False/USE_HOME = True/g' MobSF/settings.py
( 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)"
)
}

package() {
cd $pkgname

install -dm 755 "$pkgdir/usr/bin"
install -dm 755 "$pkgdir/usr/share/$pkgname"

install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -dm 755 "$pkgdir/usr/"{bin,share/$pkgname}
install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md

rm -f docker-compose.yml Dockerfile LICENSE README.md requirements.txt *.bat \
rm -rf LICENSE .gitignore docker-compose.yml Dockerfile *.bat \
*.sh scripts/*.bat
#rm -r scripts/wheels/ scripts/stack/

cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"
cp -a * "$pkgdir/usr/share/$pkgname/"

cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
source /usr/share/$pkgname/venv/bin/activate
exec gunicorn -b 0.0.0.0:8000 mobsf.MobSF.wsgi:application \
--workers=1 --threads=10 --timeout=3600
EOF

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

27 changes: 14 additions & 13 deletions packages/mobsf/mobsf.install
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
post_install() {
set -e
cd /usr/share/mobsf
python -m venv venv
source venv/bin/activate &&
pip install --isolated --root="/usr/share/mobsf" --prefix='venv' .
echo '==> To initialize mobsf to be run as standard user, execute the following commands:'
echo '==> Clean Up'
bash scripts/clean.sh y
echo 'bash /usr/share/mobsf/scripts/clean.sh y'
echo '==> Migrating Database if exists'
python manage.py makemigrations
python manage.py makemigrations StaticAnalyzer
python manage.py migrate
echo 'python /usr/share/mobsf/manage.py makemigrations'
echo 'python /usr/share/mobsf/manage.py makemigrations StaticAnalyzer'
echo 'python /usr/share/mobsf/manage.py migrate'
echo '==> Installation Complete'
echo '==> Remove old Database in ~/.MobSF/ if migration failed!'
echo '==> Remove old Database in ~/.MobSF/ if migration fails!'
}

post_upgrade() {
set -e
cd /usr/share/mobsf
echo '==> Clean Up'
bash scripts/clean.sh y
echo '==> Migrating Database'
python manage.py makemigrations
python manage.py makemigrations StaticAnalyzer
python manage.py migrate
echo '==> Remove old Database in ~/.MobSF/ if migration failed!'
python -m venv venv
source venv/bin/activate &&
pip install --isolated --root="/usr/share/mobsf" --prefix='venv' .
}

24 changes: 14 additions & 10 deletions packages/quickscope/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@

pkgname=quickscope
_pkgname=qu1cksc0pe
pkgver=507.26e9b4e
pkgver=511.19fe991
pkgrel=1
pkgdesc='Statically analyze windows, linux, osx, executables and also APK files.'
groups=('blackarch' 'blackarch-binary' 'blackarch-reversing')
arch=('any')
url='https://github.com/CYB3RMX/Qu1cksc0pe'
license=('Apache')
depends=('python-puremagic' 'androguard' 'apkid' 'python-prettytable'
'python-tqdm' 'python-colorama' 'python-oletools' 'python-spacy'
'python-pefile' 'quark-engine' 'pyaxmlparser' 'python-yara'
'python-capstone' 'python-rich')
makedepends=('git')
license=('GPL-3.0-or-later')
depends=('python')
makedepends=('git' 'python-setuptools' 'python-pip')
source=("git+https://github.com/CYB3RMX/$_pkgname.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
cd $_pkgname

echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
( 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)"
)
}

package() {
Expand All @@ -38,9 +41,10 @@ package() {

cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname/
exec python $_pkgname.py "\$@"
source /usr/share/$pkgname/venv/bin/activate
exec python /usr/share/$pkgname/qu1cksc0pe.py "\$@"
EOF

chmod +x "$pkgdir/usr/bin/$pkgname"
}

13 changes: 13 additions & 0 deletions packages/quickscope/quickscope.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
post_install() {
set -e
cd /usr/share/quickscope
python -m venv venv
source venv/bin/activate &&
pip install --isolated --root="/usr/share/quickscope" --prefix='venv' \
-r requirements.txt
pip install -e .
}

post_upgrade() {
post_install "$@"
}

0 comments on commit 6910cad

Please sign in to comment.