From 827884c0cb7e695f2db1b14ee2e0d4cbb0769b97 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Tue, 12 Mar 2024 14:53:08 +0100 Subject: [PATCH] Add script to build installer and uninstaller Signed-off-by: Vitalii Koshura --- .github/workflows/build.yml | 31 ++++++++++++++ .gitignore | 35 ++-------------- .gitmodules | 3 ++ CADD | 1 + README.md | 45 ++++++++++++++++++++- build.py | 81 +++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .gitmodules create mode 160000 CADD create mode 100644 build.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..baf4c43 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: Build +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + os: [linux, windows] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build + run: | + python build.py ${{ matrix.os }} + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: Raccoon2_BOINC_Installer_${{ matrix.os }} + path: | + raccoon2_boinc_installer.py + raccoon2_boinc_uninstaller.py diff --git a/.gitignore b/.gitignore index 259148f..807ee24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,3 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app +*.pyc +raccoon2_boinc_installer.* +raccoon2_boinc_uninstaller.* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..305a504 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "CADD"] + path = CADD + url = https://github.com/BOINC/CADD.git diff --git a/CADD b/CADD new file mode 160000 index 0000000..ef47df0 --- /dev/null +++ b/CADD @@ -0,0 +1 @@ +Subproject commit ef47df09eefe0ec3baeb10a93dea05476ac8bd66 diff --git a/README.md b/README.md index a6230f1..c97cf92 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,43 @@ -# Raccoon2_BOINC_Plugin -Raccon2 BOINC Plugin +# Raccoon2 BOINC Plugin + +This plugin extends the functionality of Raccoon2 application by adding support for BOINC. It allows to run Raccoon2 tasks on BOINC infrastructure. +For more information please visit [BOINC Central](https://boinc.berkeley.edu/central/). + +## Installation + +To install the plugin, you need to have Raccoon2 1.5.7 installed. +Then, navigate to the `MGLTOOLS_FOLDER` folder, and put `raccoon2_boinc_installer.py` there. +Finally, you can install the plugin using the following command: + +Linux/Mac: + +```bash +./bin/pythonsh raccoon2_boinc_installer.py +``` + +Windows: + +```bash +python.exe raccoon2_boinc_installer.py +``` + +where `MGLTOOLS_FOLDER` is the folder where MGLTools is installed and `PATH_TO_PLUGIN` is the path to the this folder. + +## Uninstallation + +To uninstall the plugin, navigate to the `MGLTOOLS_FOLDER` folder, and put `raccoon2_boinc_installer.py` there. +Then you can use the following command: + +Linux/Mac: + +```bash +./bin/pythonsh raccoon2_boinc_uninstaller.py +``` + +Windows: + +```bash +python.exe raccoon2_boinc_uninstaller.py +``` + +where `MGLTOOLS_FOLDER` is the folder where MGLTools is installed and `PATH_TO_PLUGIN` is the path to the this folder. diff --git a/build.py b/build.py new file mode 100644 index 0000000..3662c7a --- /dev/null +++ b/build.py @@ -0,0 +1,81 @@ +import base64 +import hashlib +import sys + +os = sys.argv[1] + +files = [ + 'CADD/Raccoon2/BoincClient.py', + 'CADD/Raccoon2/gui/AA_setup.py', + 'CADD/Raccoon2/gui/BB_ligand.py', + 'CADD/Raccoon2/gui/CC_receptor.py', + 'CADD/Raccoon2/gui/EE_jobmanager.py', + 'CADD/Raccoon2/gui/FF_anaylsis.py', + 'CADD/Raccoon2/gui/Raccoon2GUI.py', + 'CADD/Raccoon2/gui/RaccoonEngine.py', + 'CADD/Raccoon2/gui/icons/boinc.png' +] + +def get_file_hash(file): + with open(file, 'rb') as f: + return hashlib.sha512(f.read()).hexdigest() + +def get_file_content(file): + with open(file, 'rb') as f: + return base64.b64encode(f.read()) + +def build_installer_py(): + with open('raccoon2_boinc_installer.py', 'w') as f: + f.write('import base64\n') + f.write('import hashlib\n') + f.write('import os\n') + f.write('import shutil\n') + f.write('import sys\n') + f.write('curdir = os.getcwd()\n') + for file in files: + hash = get_file_hash(file) + content = get_file_content(file) + if os == 'linux': + f.write('file = curdir+\'/MGLToolsPckgs/%s\'\n' % file) + elif os == 'windows': + f.write('file = curdir+\'/Lib/site-packages/%s\'\n' % file) + f.write('if os.path.exists(file):\n') + f.write(' with open(file, \'rb\') as f:\n') + f.write(' hash = hashlib.sha512(f.read()).hexdigest()\n') + f.write(' if hash != \'%s\':\n' % hash) + f.write(' shutil.copy(file, file+\'.orig\')\n') + f.write(' with open(file, \'wb\') as f:\n') + f.write(' f.write(base64.b64decode(%s))\n' % content) + f.write(' else:\n') + f.write(' print(\'already updated: \' + file)\n') + f.write('else:\n') + f.write(' with open(file, \'wb\') as f:\n') + f.write(' f.write(base64.b64decode(%s))\n' % content) + f.write('print (\'Done\')\n') + +def build_uninstaller_py(): + with open('raccoon2_boinc_uninstaller.py', 'w') as f: + f.write('import os\n') + f.write('import shutil\n') + f.write('curdir = os.getcwd()\n') + for file in files: + if os == 'linux': + f.write('file = curdir+\'/MGLToolsPckgs/%s\'\n' % file) + elif os == 'windows': + f.write('file = curdir+\'/Lib/site-packages/%s\'\n' % file) + f.write('if os.path.exists(file+\'.orig\'):\n') + f.write(' shutil.copy(file+\'.orig\', file)\n') + f.write(' os.remove(file+\'.orig\')\n') + f.write('print (\'Done\')\n') + +def build(): + for file in files: + hash = get_file_hash(file) + content = get_file_content(file) + # print(file, hash, content) + build_installer_py() + build_uninstaller_py() + +if __name__ == "__main__": + build() + \ No newline at end of file