Skip to content

Commit

Permalink
CTX-5458: Changes regarding implementation of creating coretex.deb in…
Browse files Browse the repository at this point in the history
…stallation package for debian.
  • Loading branch information
Bogdan Tintor committed Aug 20, 2024
1 parent 2040903 commit 3d1e1f6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
32 changes: 29 additions & 3 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash

# Define package name and directory structure
PACKAGE_NAME="coretex"
PACKAGE_DIR="${PACKAGE_NAME}"
DEBIAN_DIR="${PACKAGE_DIR}/DEBIAN"
BIN_DIR="${PACKAGE_DIR}/usr/local/bin"

# Create the necessary directory structure
mkdir -p "${DEBIAN_DIR}"
mkdir -p "${BIN_DIR}"

# Create a Python virtual environment
python -m venv compile_env

Expand All @@ -8,14 +18,30 @@ source compile_env/bin/activate

# Install the current package and pyinstaller
pip install .
pip install toml
pip install pyinstaller

# Run PyInstaller with the specified options
pyinstaller main.py --onedir --copy-metadata readchar --copy-metadata coretex --add-data "coretex/resources/_coretex.py:coretex/resources"
pyinstaller main.py --onedir --name coretex --copy-metadata readchar --copy-metadata coretex --add-data "coretex/resources/_coretex.py:coretex/resources" --workpath coretex --noconfirm

# Move the entire dist/main directory contents directly to /usr/local/bin
mv dist/coretex/* "${BIN_DIR}/"

# Generate the control file using Python (assuming you have the Python script ready)
python generate_control.py

# Deactivate and remove the virtual environment
deactivate
rm -rf compile_env

# Check that everything is fine by running the compiled program
./dist/main/main
# Create the post-installation script to create a symlink
echo "#!/bin/bash
ln -s /usr/local/bin/coretex /usr/local/bin/coretex" > "${DEBIAN_DIR}/postinst"
chmod 755 "${DEBIAN_DIR}/postinst"

# Build the .deb package
dpkg-deb --build "${PACKAGE_DIR}"

# Remove unnecessary dir's
rm -rf $DEBIAN_DIR
rm -rf "${PACKAGE_DIR}/usr"
31 changes: 31 additions & 0 deletions generate_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import toml


def main() -> None:
# Load data from pyproject.toml
with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)

# Extract necessary information
packageName = pyproject['project']['name']
version = pyproject['project']['version']
description = pyproject['project']['description']

# Create control file content
controlContent = f"""
Package: {packageName}
Version: {version}
Section: base
Priority: optional
Architecture: all
Depends: python3
Maintainer: Your Name <[email protected]>
Description: {description}
"""

# Write to control file
with open(f"{packageName}/DEBIAN/control", "w") as controlFile:
controlFile.write(controlContent)

if __name__ == "__main__":
main()

0 comments on commit 3d1e1f6

Please sign in to comment.