From 19733e4bf1b1846bb172ac0f1777bd8236d4756b Mon Sep 17 00:00:00 2001 From: Juan Canham Date: Mon, 7 Jul 2025 19:28:23 -0700 Subject: [PATCH] move systemd files to /usr & use fpm instead of post-install scripts for debs --- .gitignore | 1 + README.md | 2 +- build-src/after_install.sh | 4 ++-- build-src/after_install_deb.sh | 8 ++++++++ build-src/after_purge.sh | 2 ++ build-src/electron-builder.ts | 23 +++++++++-------------- build-src/package-files.txt | 9 ++++++++- package.json | 10 +++++++--- src/dist-data/tuxedo-control-center | 1 + 9 files changed, 39 insertions(+), 21 deletions(-) create mode 100755 build-src/after_install_deb.sh create mode 100644 build-src/after_purge.sh create mode 120000 src/dist-data/tuxedo-control-center diff --git a/.gitignore b/.gitignore index 142cd0c9..dbe80ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /tmp /out-tsc /usr +/etc # Only exists if Bazel was run /bazel-out diff --git a/README.md b/README.md index 20b8f316..43f1748e 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ tuxedo-control-center 3. Install service file that points to development build path (or use installed service from packaged version) Manual instructions: - 1. Copy `tccd.service` and `tccd-sleep.service` (from src/dist-data) to `/etc/systemd/system/` + 1. Copy `tccd.service` and `tccd-sleep.service` (from src/dist-data) to `/usr/local/lib/systemd/system/` 2. Edit the `tccd.service` (exec start/stop) to point to `/dist/tuxedo-control-center/data/service/tccd`. 3. Copy `com.tuxedocomputers.tccd.conf` to `/usr/share/dbus-1/system.d/` 4. Start service `systemctl start tccd`. (And enable for autostart `systemctl enable tccd tccd-sleep`) diff --git a/build-src/after_install.sh b/build-src/after_install.sh index a81fe1b0..d92305f5 100755 --- a/build-src/after_install.sh +++ b/build-src/after_install.sh @@ -18,8 +18,8 @@ cp ${DIST_DATA}/com.tuxedocomputers.tccd.conf /usr/share/dbus-1/system.d/com.tux cp ${DIST_DATA}/com.tuxedocomputers.tomte.policy /usr/share/polkit-1/actions/com.tuxedocomputers.tomte.policy || true # Copy and enable services -cp ${DIST_DATA}/tccd.service /etc/systemd/system/tccd.service || true -cp ${DIST_DATA}/tccd-sleep.service /etc/systemd/system/tccd-sleep.service || true +cp ${DIST_DATA}/tccd.service /usr/lib/systemd/system/tccd.service || true +cp ${DIST_DATA}/tccd-sleep.service /usr/lib/systemd/system/tccd-sleep.service || true systemctl daemon-reload systemctl enable tccd tccd-sleep systemctl restart tccd diff --git a/build-src/after_install_deb.sh b/build-src/after_install_deb.sh new file mode 100755 index 00000000..659f33ef --- /dev/null +++ b/build-src/after_install_deb.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# In case TFC service is active, deactivate +systemctl stop tuxedofancontrol > /dev/null 2>&1 || true +systemctl disable tuxedofancontrol > /dev/null 2>&1 || true + +# SUID chrome-sandbox for Electron 5+ +chmod 4755 '/opt/tuxedo-control-center/chrome-sandbox' || true diff --git a/build-src/after_purge.sh b/build-src/after_purge.sh new file mode 100644 index 00000000..d542f0b4 --- /dev/null +++ b/build-src/after_purge.sh @@ -0,0 +1,2 @@ +#!/bin/bash +rm -rf /etc/tcc/ || true \ No newline at end of file diff --git a/build-src/electron-builder.ts b/build-src/electron-builder.ts index 7ea6df31..cd78ffca 100644 --- a/build-src/electron-builder.ts +++ b/build-src/electron-builder.ts @@ -51,23 +51,15 @@ async function buildDeb(filenameAddition: string): Promise { }, files: [ - distSrc + '/**/*' + distSrc + '/**/*', ], extraResources: [ distSrc + '/data/service/tccd', distSrc + '/data/service/TuxedoIOAPI.node', distSrc + '/data/CHANGELOG.md', - distSrc + '/data/dist-data/tccd.service', - distSrc + '/data/dist-data/tccd-sleep.service', distSrc + '/data/dist-data/tuxedo-control-center_256.svg', - distSrc + '/data/dist-data/tuxedo-control-center.desktop', - distSrc + '/data/dist-data/tuxedo-control-center-tray.desktop', - distSrc + '/data/dist-data/com.tuxedocomputers.tccd.policy', - distSrc + '/data/dist-data/com.tuxedocomputers.tccd.conf', distSrc + '/data/camera/cameractrls.py', - distSrc + '/data/dist-data/99-webcam.rules', - distSrc + '/data/dist-data/com.tuxedocomputers.tomte.policy', - distSrc + '/data/camera/v4l2_kernel_names.json' + distSrc + '/data/camera/v4l2_kernel_names.json', ], linux: { target: [ @@ -79,12 +71,16 @@ async function buildDeb(filenameAddition: string): Promise { deb: { depends: ['tuxedo-drivers (>= 4.0.0) | tuxedo-keyboard (>= 3.1.2)', 'libayatana-appindicator3-1'], category: 'System', - afterInstall: "./build-src/after_install.sh", - afterRemove: "./build-src/after_remove.sh", + afterInstall: "./build-src/after_install_deb.sh", fpm: [ '--conflicts=tuxedofancontrol', '--replaces=tuxedofancontrol', - '--inputs=build-src/package-files.txt' + '--inputs=build-src/package-files.txt', + '--deb-systemd=src/dist-data/tccd.service', + '--deb-systemd=src/dist-data/tccd-sleep.service', + '--deb-systemd-restart-after-upgrade', + '--deb-after-purge=build-src/after_purge.sh', + '--deb-upstream-changelog=CHANGELOG.md' ] } }; @@ -140,7 +136,6 @@ async function buildRpm(filenameAddition: string): Promise { }, rpm: { depends: ['(tuxedo-drivers >= 4.0.0 or tuxedo-keyboard >= 3.1.2)', '(libayatana-appindicator3-1 or libappindicator or libappindicator3-1)'], - afterInstall: './build-src/dummy.sh', afterRemove: './build-src/after_remove.sh', fpm: [ '--replaces=tuxedofancontrol <= 0.1.9', diff --git a/build-src/package-files.txt b/build-src/package-files.txt index c880e7c3..df0eeea0 100644 --- a/build-src/package-files.txt +++ b/build-src/package-files.txt @@ -1 +1,8 @@ -usr/share/metainfo/com.tuxedocomputers.tcc.metainfo.xml \ No newline at end of file +usr/share/metainfo/com.tuxedocomputers.tcc.metainfo.xml +usr/share/polkit-1/actions/com.tuxedocomputers.tccd.policy +usr/share/polkit-1/actions/com.tuxedocomputers.tomte.policy +usr/share/dbus-1/system.d/com.tuxedocomputers.tccd.conf +usr/lib/udev/rules.d/99-tuxedo-webcam.rules +usr/share/applications/tuxedo-control-center.desktop +etc/skel/.config/autostart/tuxedo-control-center-tray.desktop +usr/bin/tuxedo-control-center \ No newline at end of file diff --git a/package.json b/package.json index 39c1d542..8d8c4158 100644 --- a/package.json +++ b/package.json @@ -26,18 +26,22 @@ "build-service": "tsc -p ./src/service-app && cp ./src/package.json ./dist/tuxedo-control-center/service-app/package.json && run-s bundle-service", "bundle-service": "cp ./build/Release/TuxedoIOAPI.node ./dist/tuxedo-control-center/service-app/native-lib && pkg --target node14-linux-x64 --output ./dist/tuxedo-control-center/data/service/tccd ./dist/tuxedo-control-center/service-app/package.json", "build-native": "node-gyp configure && node-gyp rebuild", - "copy-files": "run-s copy-package-json copy-dist-files copy-cameractls copy-udev-rule", + "copy-files": "run-s copy-package-json copy-dist-files copy-desktop-files copy-policy-files copy-dbus-file copy-cameractls copy-udev-rule copy-symlink-files", "copy-package-json": "cp ./src/package.json ./dist/tuxedo-control-center/package.json", + "copy-policy-files": " mkdir -p ./usr/share/polkit-1/actions/ && cp ./src/dist-data/com.tuxedocomputers.tccd.policy ./src/dist-data/com.tuxedocomputers.tomte.policy ./usr/share/polkit-1/actions/", + "copy-dbus-file": " mkdir -p ./usr/share/dbus-1/system.d/ && cp ./src/dist-data/com.tuxedocomputers.tccd.conf ./usr/share/dbus-1/system.d/", "copy-dist-files": "cp -r ./src/dist-data ./dist/tuxedo-control-center/data && mkdir -p ./usr/share/metainfo && cp ./src/dist-data/com.tuxedocomputers.tcc.metainfo.xml ./usr/share/metainfo", + "copy-symlink-files": "mkdir -p ./usr/bin/ && cp -P ./src/dist-data/tuxedo-control-center ./usr/bin/", + "copy-desktop-files": " mkdir -p ./usr/share/applications/ ./etc/skel/.config/autostart && cp ./src/dist-data/tuxedo-control-center.desktop ./usr/share/applications/ && cp ./src/dist-data/tuxedo-control-center-tray.desktop ./etc/skel/.config/autostart", "copy-changelog": "cp CHANGELOG.md ./src/ng-app/assets/", "copy-cameractls": "mkdir -p ./dist/tuxedo-control-center/data/camera && cp ./src/cameractrls/cameractrls.py ./src/cameractrls/v4l2_kernel_names.json ./dist/tuxedo-control-center/data/camera", - "copy-udev-rule": "cp ./src/udev/99-webcam.rules ./dist/tuxedo-control-center/data/dist-data", + "copy-udev-rule": "mkdir -p ./usr/lib/udev/rules.d/ && cp ./src/udev/99-webcam.rules ./usr/lib/udev/rules.d/99-tuxedo-webcam.rules", "electron-builder": "USE_HARD_LINKS=false TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ./build-src/electron-builder.ts", "pack": "run-s build && npm run electron-builder", "build-release": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ./build-src/build-release.ts", "check-release": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ./build-src/check-release.ts", "pack-prod": "run-s build-prod && npm run electron-builder", - "clean": "rm -rf ./dist; rm -rf ./build; rm -rf ./usr", + "clean": "rm -rf ./dist; rm -rf ./build; rm -rf ./usr; rm -rf ./etc", "tests": "npm run test-common && npm run test-service-app && npm run test-appstream", "test-common": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node node_modules/jasmine/bin/jasmine --config=./src/common/jasmine.json", "test-service-app": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node node_modules/jasmine/bin/jasmine --config=./src/service-app/jasmine.json", diff --git a/src/dist-data/tuxedo-control-center b/src/dist-data/tuxedo-control-center new file mode 120000 index 00000000..0ac5d366 --- /dev/null +++ b/src/dist-data/tuxedo-control-center @@ -0,0 +1 @@ +/opt/tuxedo-control-center/tuxedo-control-center \ No newline at end of file