From 57f07aafe8921019220c6af1f622fd76a82c76b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 27 Feb 2019 11:17:17 +0100 Subject: [PATCH] Add README.md, update-qt --- Makefile | 4 +- README.md | 4 + build-linux.sh | 214 ------------------------------------------- scripts/update-qt.py | 32 +++++++ 4 files changed, 38 insertions(+), 216 deletions(-) create mode 100644 README.md delete mode 100755 build-linux.sh create mode 100644 scripts/update-qt.py diff --git a/Makefile b/Makefile index 085ecf3..3434ca7 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,8 @@ ${PATCHELF_SRC_DIR}_target=PATCHELF_SRC #QT_SRC_URL=https://download.qt.io/official_releases/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz QT_BIN_FILE=cutter-deps-qt.tar.gz -QT_BIN_URL=https://github.com/thestr4ng3r/cutter-deps-qt/releases/download/v3/cutter-deps-qt.tar.gz -QT_BIN_MD5=a6707ea2ea857c490d1c3886c01267b0 +QT_BIN_URL=https://github.com/radareorg/cutter-deps-qt/releases/download/v4/cutter-deps-qt.tar.gz +QT_BIN_MD5=b47f52d4cbf6106abfd8b294211eabca QT_BIN_DIR=qt QT_PREFIX=${ROOT_DIR}/${QT_BIN_DIR} ${QT_BIN_DIR}_target=QT_BIN diff --git a/README.md b/README.md new file mode 100644 index 0000000..a959a99 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ + +# cutter-deps + +This repository contains scripts to build the dependencies for [Cutter](https://github.com/radareorg/cutter/). diff --git a/build-linux.sh b/build-linux.sh deleted file mode 100755 index 0251d0e..0000000 --- a/build-linux.sh +++ /dev/null @@ -1,214 +0,0 @@ -#!/bin/bash - -PYTHON_SRC_FILE=Python-3.6.4.tar.xz -PYTHON_SRC_MD5=1325134dd525b4a2c3272a1a0214dd54 -PYTHON_SRC_URL=https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz - -PATCHELF_SRC_FILE=patchelf-0.9.tar.bz2 -PATCHELF_SRC_MD5=d02687629c7e1698a486a93a0d607947 -PATCHELF_SRC_URL=https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 - -QT_SRC_FILE=qt-everywhere-src-5.12.1.tar.xz -QT_SRC_MD5=6a37466c8c40e87d4a19c3f286ec2542 -QT_SRC_URL=https://download.qt.io/official_releases/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz - -PYSIDE_SRC_FILE=pyside-setup-everywhere-src-5.12.1.tar.xz -PYSIDE_SRC_MD5=c247fc1de38929d81aedd1c93d629d9e -PYSIDE_SRC_URL=https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-5.12.1-src/pyside-setup-everywhere-src-5.12.1.tar.xz - -BUILD_THREADS=4 - -ROOT_DIR="$PWD" -PYTHON_PREFIX="$PWD/python" -QT_PREFIX="$PWD/qt" -PYSIDE_PREFIX="$PWD/pyside" - -cd "$(dirname "$0")" - -check_md5() { - echo "$2 $1" | md5sum -c - || exit 1 -} - -download() { - if [ ! -f "$2" ]; then - echo "Downloading $2" - curl -L "$1" -o "$2" || exit 1 - fi - check_md5 "$2" "$3" -} - -build_python() { - echo "" - echo "#########################" - echo "# Building Python #" - echo "#########################" - echo "" - - cd Python-3.6.4 || exit 1 - - echo "Building Python to install to prefix $PYTHON_PREFIX" - ./configure --enable-shared --prefix="$PYTHON_PREFIX" || exit 1 - make -j$BUILD_THREADS > /dev/null || exit 1 - make install > /dev/null || exit 1 - cd "$ROOT_DIR" - - echo "Patching libs in $CUSTOM_PYTHON_PREFIX/lib/python3.6/lib-dynload to have the correct rpath" - cd patchelf-0.9 || exit 1 - PATCHELF_DIR="$PWD" - ./configure || exit 1 - make > /dev/null || exit 1 - - for lib in "$PYTHON_PREFIX/lib/python3.6/lib-dynload"/*.so; do - echo " patching $lib" - "$PATCHELF_DIR/src/patchelf" --set-rpath '$ORIGIN/../..' "$lib" || exit 1 - done - - - cd "$ROOT_DIR" -} - -build_qt() { - echo "" - echo "#########################" - echo "# Building Qt5 #" - echo "#########################" - echo "" - - cd qt-everywhere-src-5.12.1 || exit 1 - mkdir -p build && cd build || exit 1 - - ../configure \ - -prefix "`pwd`/../../qt" \ - -opensource -confirm-license \ - -release \ - -no-opengl \ - -no-feature-cups \ - -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite2 -no-sql-sqlite -no-sql-tds \ - -nomake tests -nomake examples \ - -skip qtwebengine \ - -skip qt3d \ - -skip qtcanvas3d \ - -skip qtcharts \ - -skip qtconnectivity \ - -skip qtdeclarative \ - -skip qtdoc \ - -skip qtscript \ - -skip qtdatavis3d \ - -skip qtgamepad \ - -skip qtlocation \ - -skip qtgraphicaleffects \ - -skip qtmultimedia \ - -skip qtpurchasing \ - -skip qtscxml \ - -skip qtsensors \ - -skip qtserialbus \ - -skip qtserialport \ - -skip qtspeech \ - -skip qttools \ - -skip qttranslations \ - -skip qtvirtualkeyboard \ - -skip qtwebglplugin \ - -skip qtwebsockets \ - -skip qtwebview \ - || exit 1 - - make -j$BUILD_THREADS > /dev/null || exit 1 - make install > /dev/null || exit 1 - - cd ../.. -} - -build_pyside() { - echo "" - echo "#########################" - echo "# Preparing PySide2 #" - echo "#########################" - echo "" - - cd pyside-setup-everywhere-src-5.12.1 || exit 1 - - # Patch needed, so the PySide2 CMakeLists.txt doesn't search for Qt5UiTools and other stuff, - # which would mess up finding the actual modules later. - patch sources/pyside2/CMakeLists.txt ../patch/pyside2-CMakeLists.txt.patch || exit 1 - echo "" > sources/pyside2/cmake/Macros/FindQt5Extra.cmake || exit 1 - - # Patches to remove OpenGL-related source files. - patch sources/pyside2/PySide2/QtGui/CMakeLists.txt ../patch/pyside2-QtGui-CMakeLists.txt.patch || exit 1 - patch sources/pyside2/PySide2/QtWidgets/CMakeLists.txt ../patch/pyside2-QtWidgets-CMakeLists.txt.patch || exit 1 - - mkdir -p build && cd build || exit 1 - - LLVM_LIBDIR=`llvm-config --libdir` - echo "LLVM libdir: \"$LLVM_LIBDIR\"" - - export LD_LIBRARY_PATH="$PYTHON_PREFIX/lib:$QT_PREFIX/lib:$LLVM_LIBDIR:$LD_LIBRARY_PATH" - - PYTHON_VERSION=3 - - echo "" - echo "#########################" - echo "# Building Shiboken2 #" - echo "#########################" - echo "" - - mkdir -p shiboken2 && cd shiboken2 || exit 1 - cmake \ - -DCMAKE_PREFIX_PATH="$QT_PREFIX" \ - -DCMAKE_INSTALL_PREFIX="$PYSIDE_PREFIX" \ - -DUSE_PYTHON_VERSION=$PYTHON_VERSION \ - -DPYTHON_LIBRARY="$PYTHON_PREFIX/lib/libpython3.so" \ - -DPYTHON_INCLUDE_DIR="$PYTHON_PREFIX/include/python3.6m" \ - -DPYTHON_EXECUTABLE="$PYTHON_PREFIX/bin/python3.6" \ - -DBUILD_TESTS=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - ../../sources/shiboken2 || exit 1 - make -j$BUILD_THREADS > /dev/null || exit 1 - make install > /dev/null || exit 1 - cd .. - - echo "" - echo "#########################" - echo "# Building PySide2 #" - echo "#########################" - echo "" - - mkdir -p pyside2 && cd pyside2 || exit 1 - cmake \ - -DCMAKE_PREFIX_PATH="$QT_PREFIX;$PYSIDE_PREFIX" \ - -DCMAKE_INSTALL_PREFIX="$PYSIDE_PREFIX" \ - -DUSE_PYTHON_VERSION=$PYTHON_VERSION \ - -DPYTHON_LIBRARY="$PYTHON_PREFIX/lib/libpython3.so" \ - -DPYTHON_INCLUDE_DIR="$PYTHON_PREFIX/include/python3.6m" \ - -DPYTHON_EXECUTABLE="$PYTHON_PREFIX/bin/python3.6" \ - -DBUILD_TESTS=OFF \ - -DCMAKE_BUILD_TYPE=Release \ - -DMODULES="Core;Gui;Widgets" \ - ../../sources/pyside2 || exit 1 - make -j$BUILD_THREADS > /dev/null || exit 1 - make install > /dev/null || exit 1 - cd .. - - cd .. -} - -download "$QT_SRC_URL" "$QT_SRC_FILE" "$QT_SRC_MD5" -tar -xf "$QT_SRC_FILE" || exit 1 -download "$PYSIDE_SRC_URL" "$PYSIDE_SRC_FILE" "$PYSIDE_SRC_MD5" -tar -xf "$PYSIDE_SRC_FILE" || exit 1 -download "$PYTHON_SRC_URL" "$PYTHON_SRC_FILE" "$PYTHON_SRC_MD5" -tar -xf "$PYTHON_SRC_FILE" || exit 1 -download "$PATCHELF_SRC_URL" "$PATCHELF_SRC_FILE" "$PATCHELF_SRC_MD5" -tar -xf "$PATCHELF_SRC_FILE" || exit 1 - -build_python -build_qt -build_pyside - -echo "" -echo "#########################" -echo "# Creating archive #" -echo "#########################" -echo "" - -tar -czf cutter-deps.tar.gz qt python pyside || exit 1 - diff --git a/scripts/update-qt.py b/scripts/update-qt.py new file mode 100644 index 0000000..b655689 --- /dev/null +++ b/scripts/update-qt.py @@ -0,0 +1,32 @@ + +import sys +import os +import requests +import re +import subprocess + +makefile_path = os.path.join(os.path.dirname(sys.argv[0]), "..", "Makefile") + +print("Fetching latest release") +json = requests.get("https://api.github.com/repos/radareorg/cutter-deps-qt/releases/latest").json() + +release_url = json["assets"][0]["browser_download_url"] + +print(f"Getting MD5 for {release_url}") + +curl = subprocess.Popen(["curl", "-L", release_url], stdout=subprocess.PIPE) +md5sum = subprocess.run(["md5sum"], stdin=curl.stdout, capture_output=True, encoding="utf-8").stdout +curl.wait() + +md5sum = re.match("([a-zA-Z0-9]+) ", md5sum).group(1) + +print(f"MD5: {md5sum}") + +with open(makefile_path) as f: + makefile = f.read() + +makefile = re.sub("^QT_BIN_URL=.*$", f"QT_BIN_URL={release_url}".replace("\\", r"\\"), makefile, flags=re.MULTILINE) +makefile = re.sub("^QT_BIN_MD5=.*$", f"QT_BIN_MD5={md5sum}".replace("\\", r"\\"), makefile, flags=re.MULTILINE) + +with open(makefile_path, "w") as f: + f.write(makefile)