Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
matrix/debs/*
matrix/build_matrix.py
matrix/Dockerfile
47 changes: 47 additions & 0 deletions .github/workflows/debs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Debian Packages

on:
push:
tags:
- '*-release'

permissions:
contents: read

jobs:
debs:
name: Build Debian Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Debian Packages
run: make debs
- name: Upload Debian Packages
uses: actions/upload-artifact@v4
with:
name: packages-debian
path: matrix/debs

release:
permissions:
contents: write # for actions/create-release
name: Create GitHub Release
needs: [debs]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Debian Packages
uses: actions/download-artifact@v4
with:
pattern: packages-*
merge-multiple: true
path: ./dist
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ github.event.head_commit.message }}
artifacts: ./dist/*.deb
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ all:
clean:
scons -C cbang -c
scons -c

# build debian packages in docker images
debs:
python matrix/build_matrix.py
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ by C!, can be installed with the following command line:

sudo apt-get update
sudo apt-get -y install scons build-essential libqt5websockets5-dev \
libqt5opengl5-dev libnode-dev libglu1-mesa-dev pkgconf git
libqt5opengl5-dev qttools5-dev-tools libnode-dev libglu1-mesa-dev \
pkgconf git

## Building C! (cbang)
Clone the C! git repository, build the software using scons and set the
environment variable CBANG_HOME so the CAMotics build system can find it
later. **You must install V8 or ChakraCore before this step.**
later. **You must install V8 before this step.**

git clone https://github.com/CauldronDevelopmentLLC/cbang.git
scons -C cbang
Expand Down
113 changes: 94 additions & 19 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os, sys, json
import os
import sys
import json
import subprocess

# local cbang
if not os.environ.get('CBANG_HOME'): os.environ['CBANG_HOME'] = './cbang'
Expand All @@ -8,6 +11,20 @@ cbang = os.environ.get('CBANG_HOME')
with open('package.json', 'r') as f: pkg_meta = json.load(f)
version = pkg_meta['version']

# Debian Distro Code

try:
# if we're on debian get the distro code, i.e. `noble`, `trixie`
distro_code = subprocess.check_output(
['lsb_release', '-cs']).decode().strip().lower()
except BaseException as E:
print(f"Not on Debian or no `apt install lsb-release: `{E}`")
distro_code = None

# True, except on newer debian with the libnode-dev issue
default_tpl = distro_code not in {'plucky', 'trixie'}


# Setup
env = Environment(ENV = os.environ,
TARGET_ARCH = os.environ.get('TARGET_ARCH', 'x86'))
Expand All @@ -19,10 +36,9 @@ env.CBAddVariables(
('install_prefix', 'Installation directory prefix', '/usr/local/'),
BoolVariable('qt_deps', 'Enable Qt package dependencies', True),
('python_version', 'Set python version', '3'),
BoolVariable('with_tpl', 'Enable TPL', True),
BoolVariable('with_tpl', 'Enable TPL', default_tpl),
BoolVariable('with_gui', 'Enable graphical user interface', True),
BoolVariable('wrap_glibc', 'Enable GlibC function wrapping',
env['PLATFORM'] == 'posix'),
BoolVariable('wrap_glibc', 'Enable GlibC function wrapping', False)
)
conf = env.CBConfigure()

Expand Down Expand Up @@ -70,14 +86,12 @@ if not env.GetOption('clean'):

conf.CBConfig('cbang')
env.CBDefine('USING_CBANG') # Using CBANG macro namespace
for lib in 'mariadbclient snappy leveldb yaml re2 sqlite3'.split():
for lib in 'mariadbclient snappy leveldb yaml sqlite3'.split():
if lib in env['LIBS']: env['LIBS'].remove(lib)

# Include path
env.AppendUnique(CPPPATH = ['#/src'])

if env['PLATFORM'] != 'win32': env.AppendUnique(CCFLAGS = ['-fPIC'])

# Python
have_python = conf.CBConfig('python', False)

Expand Down Expand Up @@ -176,8 +190,8 @@ if env['with_tpl']:

# DXFlib
if not have_dxflib:
libDXFlib = SConscript('src/dxflib/SConscript',
variant_dir = 'build/dxflib')
libDXFlib = SConscript(
'src/dxflib/SConscript', variant_dir = 'build/dxflib')
env.Append(LIBS = libDXFlib)


Expand Down Expand Up @@ -346,7 +360,6 @@ material or breaking tools.'''

# Package
if 'package' in COMMAND_LINE_TARGETS:
import subprocess

# Examples
examples = []
Expand All @@ -356,6 +369,9 @@ if 'package' in COMMAND_LINE_TARGETS:
if isinstance(examples, bytes): examples = examples.decode()
examples = list(map(lambda x: [x, x], examples.split()))




# Machines
machines = []
cmd = 'git ls-files machines/'
Expand All @@ -377,13 +393,42 @@ if 'package' in COMMAND_LINE_TARGETS:

install_files = []
if env.get('qt_deps'):
qt_pkgs = ', libqt5core5a, libqt5gui5, libqt5opengl5, libqt5websockets5'

# debian distros keep renaming the qt packages
qt_lookup = {'noble': ['libqt5core5t64', # Ubuntu 24.04
'libqt5gui5t64',
'libqt5opengl5t64',
'libqt5websockets5'],
'jammy': ['libqt5core5a', # Ubuntu 22.04
'libqt5gui5',
'libqt5opengl5',
'libqt5websockets5']}
# use exact versions for the other distros
qt_lookup['plucky'] = qt_lookup['noble']
qt_lookup['trixie'] = qt_lookup['noble']
qt_lookup['bookworm'] = qt_lookup['jammy']
qt_lookup['buster'] = qt_lookup['jammy']

if distro_code in qt_lookup:
qt_pkgs = qt_lookup[distro_code]
else:
# produce a generic requirements list using the OR requirement, i.e.
# i.e. `['libqt5core5a|libqt5core5t64', ...]`
# note that this logic requires `qt_lookup` values to all have the same
# length and correspond with each other, and if one package is dropped
# a `None` placeholder must be added to the list to keep the correspondence
qt_values = list(qt_lookup.values())
qt_pkgs = ['|'.join(set(v[i] for v in qt_values).difference({None}))
for i in range(len(qt_values[0]))]



if env['PLATFORM'] == 'win32':
import shutil
try:
shutil.rmtree('build/win32')
except: pass
except:
pass

cmd = [env['QTDIR'] + '\\bin\\windeployqt.exe', '--dir',
'build\\win32', '--no-system-d3d-compiler', '--no-opengl-sw',
Expand All @@ -397,7 +442,40 @@ if 'package' in COMMAND_LINE_TARGETS:
env['VCREDIST'] = name
install_files.append('build\\win32\\' + name)

else: qt_pkgs = ''
else:
qt_pkgs = []


if env['with_tpl']:
# this should provide v8
tpl_pkgs = ['libnode-dev']
else:
tpl_pkgs = []

# SSL packages for various distros
# these also keep changing names
ssl_lookup = {'noble': 'libssl3t64',
'plucky': 'libssl3t64',
'jammy': 'libssl3',
'trixie': 'libssl3t64',
'bookworm': 'libssl3',
'buster': 'libssl1.1'}
if distro_code in ssl_lookup:
ssl_pkg = ssl_lookup[distro_code]
else:
# set as an OR of all the unique possible packages
ssl_pkg = '|'.join(set(ssl_lookup.values()))

# base deps that work across all distros and don't need any logic
deb_depends = ['debconf', 'libc6', 'libglu1', 'libglu1-mesa']

# append the platform-dependant packages
deb_depends.append(ssl_pkg)
deb_depends.extend(qt_pkgs)
deb_depends.extend(tpl_pkgs)

# flatten into a comma delimited string
deb_depends = ','.join(deb_depends)

pkg = env.Packager(
'CAMotics',
Expand All @@ -408,7 +486,7 @@ if 'package' in COMMAND_LINE_TARGETS:
license = 'COPYING',
bug_url = 'https://github.com/CauldronDevelopmentLLC/CAMotics/issues/',
summary = 'Open-Source Simulation & Computer Aided Machining',
description = description,
description = description + '\n\n' + "Package compiled on distro `%s`" % distro_code,
prefix = '/usr',
icons = ('osx/camotics.icns', 'images/camotics.png'),
mime = [['mime.xml', 'camotics.xml']],
Expand All @@ -428,16 +506,13 @@ if 'package' in COMMAND_LINE_TARGETS:

deb_directory = 'debian',
deb_section = 'miscellaneous',
deb_depends =
'debconf | debconf-2.0, libc6, libglu1, ' +
'libv8-3.14.5 | libv8-dev | libnode-dev, ' +
'libglu1-mesa, libssl1.1' + qt_pkgs,
deb_depends = deb_depends,
deb_priority = 'optional',
deb_replaces = 'openscam',

rpm_license = 'GPLv2+',
rpm_group = 'Applications/Engineering',
rpm_requires = 'expat' + qt_pkgs,
rpm_requires = 'expat' + ','.join(qt_pkgs),
rpm_obsoletes = 'openscam',

app_id = 'org.camotics.CAMotics',
Expand Down
1 change: 1 addition & 0 deletions debian/camotics.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/share/doc/camotics/README.md
1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

16 changes: 16 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: camotics
Maintainer: Joseph Coffland <[email protected]>
Section: science
Priority: optional
Standards-Version: 4.7.0
Homepage: https://camotics.org/
Build-Depends: debhelper-compat (= 13), scons, libcbang0-dev

Package: camotics
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: 3-axis numerical control machining simulator
CAMotics is an Open-Source software which can simulate 3-axis NC
machining. It is a fast, flexible and user-friendly simulation
software for the DIY and Open-Source community. CAMotics works on
Linux, OS-X and Windows.
31 changes: 31 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

# link to libatomic on armel and mipsel
ifneq (,$(filter $(DEB_HOST_ARCH), armel mipsel))
export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
endif

include /usr/share/dpkg/default.mk # provides DEB_VERSION

SCONS_OPTIONS = cycles=0 mode=release sharedlib=1 -j8 werror=0 clang=1

%:
dh $@

override_dh_auto_clean:
scons -c
find . -name __pycache__|xargs rm -rf
rm -rf .sconf_temp config.log
rm -rf .sconsign.dblite

override_dh_auto_build:
scons $(SCONS_OPTIONS) --jobs=$(NUMJOBS) --no-cache

override_dh_usrlocal:
true

override_dh_auto_install:
PREFIX=/usr scons prefix=debian/camotics/usr $(SCONS_OPTIONS) install
Loading