Skip to content

Commit

Permalink
linux deployment automatization initial
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimaier committed Mar 19, 2024
1 parent 3a3af22 commit ca15130
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"

# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
qt5-default \
qtdeclarative5-dev \
libqt5quick5 \
libqt5quickcontrols2-5 \
libqt5serialport5-dev \
mesa-common-dev \
libglu1-mesa-dev \
qtquickcontrols2-5-dev \
libqt5opengl5-dev
7 changes: 7 additions & 0 deletions linux_deploy/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: data-plotter
Version: {version}
Architecture: amd64
Essential: no
Priority: optional
Maintainer: Jiri Maier <[email protected]>
Description: Universal GUI for software-defined measuring instruments
8 changes: 8 additions & 0 deletions linux_deploy/data-plotter.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Data Plotter
Comment=Universal GUI for software-defined measuring instruments
Exec=/usr/bin/data-plotter
Icon=/usr/share/icons/hicolor/256x256/apps/data-plotter.png
Categories=Office
77 changes: 77 additions & 0 deletions linux_deploy/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os
import shutil
import subprocess

# Function to get the version from the .pro file
def get_version(file_path):
with open(file_path, 'r') as file:
for line in file:
if line.startswith('VERSION'):
return line.split('=')[1].strip()
return None


# Get the version from the .pro file
version = get_version('DataPlotter.pro')
# Trim the version to three numbers
version = ".".join(version.split(".")[:3])

# Define the base directory
base_dir = os.path.join("linux_deploy",f"data-plotter_{version}_amd64")

if os.path.exists(base_dir):
shutil.rmtree(base_dir)

# Define the directories to be created
dirs = [
os.path.join(base_dir, "DEBIAN"),
os.path.join(base_dir, "usr", "bin"),
os.path.join(base_dir, "usr", "share", "doc", "data-plotter"),
os.path.join(base_dir, "usr", "lib"),
os.path.join(base_dir,"usr","share","icons","hicolor","256x256","apps"),
os.path.join(base_dir,"usr","share","applications"),
]

# Create the directories
for dir in dirs:
os.makedirs(dir, exist_ok=True)

# Define the files to be copied
files = {
os.path.join("linux_deploy","control"): os.path.join(base_dir, "DEBIAN", "control"),
os.path.join("linux_deploy","qt.conf"): os.path.join(base_dir, "usr", "bin", "qt.conf"),
os.path.join("build","DataPlotter"): os.path.join(base_dir, "usr", "bin", "data-plotter"),
os.path.join("documentation","license.txt"): os.path.join(base_dir, "usr", "share", "doc", "data-plotter", "copyright"),
os.path.join("linux_deploy","icon.png"):os.path.join(base_dir,"usr","share","icons","hicolor","256x256","apps","data-plotter.png"),
os.path.join("linux_deploy","data-plotter.desktop"):os.path.join(base_dir,"usr","share","applications","data-plotter.desktop")
}

# Copy the files
for src, dst in files.items():
shutil.copy(src, dst)

with open(os.path.join(base_dir, "DEBIAN", "control"), "r") as file:
content = file.read()
content = content.replace("{version}", f"{version}")
with open(os.path.join(base_dir, "DEBIAN", "control"), "w") as file:
file.write(content)

# Run ldd on the executable
result = subprocess.run(["ldd", os.path.join("build","DataPlotter")], capture_output=True, text=True)

# Extract the paths of the shared libraries
libs = [line.split(" ")[2] for line in result.stdout.splitlines() if "=>" in line and not "linux-vdso" in line]

for lib in libs:
shutil.copy(lib, os.path.join(base_dir, "usr", "lib"))

shutil.copytree(os.path.join("linux_deploy","plugins"),os.path.join(base_dir,"usr","lib","qt5","plugins"))
shutil.copytree(os.path.join("linux_deploy","qml"),os.path.join(base_dir,"usr","lib","qt5","qml"))

# Print a success message
print(f"The Debian package folder structure for {base_dir} has been created and the files have been copied.")

os.remove(base_dir + ".deb")

#result = subprocess.run(["dpkg-deb", "--build", base_dir], capture_output=True, text=True)
#print(result)
Binary file added linux_deploy/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions linux_deploy/qt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Paths]
Prefix = /usr/lib/qt5/
Plugins = plugins
Imports = qml
Qml2Imports = qml

0 comments on commit ca15130

Please sign in to comment.