diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..6097065 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,74 @@ +# Maintainer: Your Name + +pkgname=tms-bbt +pkgver=1.0 +pkgrel=1 +pkgdesc="SmartTMS application suite for managing cinema devices." +arch=('x86_64') +url="https://your.company.com/smarttms" +license=('Proprietary') + +options=('!strip') + +depends=('python' 'sudo' 'xdg-utils' 'tms-mysql' 'tms-oracle-jdk8') + +source=("${pkgname}.tar.gz") + +sha256sums=('4a87404479f1a6e85fa1fd34f08ae60c350fce240b65b761b03f8db39c08c298') + +install="${pkgname}.install" + +prepare() { + cd "${srcdir}/${pkgname}" + + # 修复 Python shebangs (如果文件存在) + find . -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/env python$|#!/usr/bin/env python3|g' {} + || true + find . -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/python$|#!/usr/bin/python3|g' {} + || true + # 针对 websockify/run 文件 + if [ -f apache-tomcat-7.0.63/webapps/noVNC-master/utils/websockify/run ]; then + sed -i 's|^#!/usr/bin/python$|#!/usr/bin/python3|g' apache-tomcat-7.0.63/webapps/noVNC-master/utils/websockify/run || true + fi +} + +build() { + msg "No build step required for this package." +} + +package() { + # 定义目标目录,保持 /home/smart 路径不变 + local _app_base_dir="/home/smart/.tms3" + local _tomcat_dir="${_app_base_dir}/apache-tomcat-7.0.63" + local _starter_dir="${_app_base_dir}/starter" + + # 1. 创建目标目录 + # 注意:/home/smart 目录本身不会由 RPM 包创建,需要系统管理员确保其存在。 + # 我们按照原始 RPM Spec 的权限设置 777。 + install -d -m777 "${pkgdir}${_app_base_dir}" + install -d -m777 "${pkgdir}${_tomcat_dir}" + install -d -m777 "${pkgdir}${_starter_dir}" + + install -d "${pkgdir}/usr/bin" + install -d -m750 "${pkgdir}/etc/sudoers.d" + install -d "${pkgdir}/usr/lib/systemd/system" # Arch Linux systemd unit 文件标准路径 + install -d "${pkgdir}/usr/share/applications" + + # 2. 复制应用程序文件 + # 进入已解压的 tarball 目录 + cd "${srcdir}/${pkgname}" + + # 复制 Tomcat 和 starter 内容 + cp -r apache-tomcat-7.0.63/* "${pkgdir}${_tomcat_dir}/" + cp -r starter/* "${pkgdir}${_starter_dir}/" + + # 复制 smarttms 可执行文件 + install -m755 smarttms "${pkgdir}/usr/bin/smarttms" + + # 复制 sudoers.d 文件 (从 $srcdir,而非 tarball 内部) + install -m440 "smart" "${pkgdir}/etc/sudoers.d/smart" + + # 复制 systemd 服务文件 (从 $srcdir,而非 tarball 内部) + install -m644 "smarttms.service" "${pkgdir}/usr/lib/systemd/system/smarttms.service" + + # 复制桌面快捷方式 (从 tarball 内部的 starter 目录) + install -m644 starter/tmsrestart.desktop "${pkgdir}/usr/share/applications/tmsrestart.desktop" +} diff --git a/tms-bbt.install b/tms-bbt.install new file mode 100644 index 0000000..32c644f --- /dev/null +++ b/tms-bbt.install @@ -0,0 +1,50 @@ +# post_install: 在软件包安装后执行 +post_install() { + echo "Checking for 'smart' user..." + if ! id -u smart &>/dev/null; then + echo "WARNING: User 'smart' does not exist. Please create the 'smart' user for SmartTMS to function correctly." + echo "You can create it with: sudo useradd -m smart" + fi + + echo "Reloading systemd configuration, enabling and starting smarttms.service..." + systemctl daemon-reload >/dev/null 2>&1 || : + systemctl enable smarttms.service >/dev/null 2>&1 || : + systemctl start smarttms.service >/dev/null 2>&1 || : + + echo "Updating desktop database..." + update-desktop-database /usr/share/applications >/dev/null 2>&1 || : + + echo "SmartTMS application installed to /home/smart/.tms3." + echo "A systemd service 'smarttms.service' has been enabled and started." + echo "A sudoers.d entry for 'smart' user has been added." + echo "Desktop shortcut 'tmsrestart.desktop' is available." + echo "Please ensure the 'smart' user exists and has appropriate permissions for /home/smart/.tms3." +} + +# pre_remove: 在软件包卸载前执行 +pre_remove() { + echo "Stopping and disabling smarttms.service..." + systemctl stop smarttms.service >/dev/null 2>&1 || : + systemctl disable smarttms.service >/dev/null 2>&1 || : +} + +# post_remove: 在软件包卸载后执行 +post_remove() { + echo "Reloading systemd configuration after removal..." + systemctl daemon-reload >/dev/null 2>&1 || : + + echo "Updating desktop database after removal..." + update-desktop-database /usr/share/applications >/dev/null 2>&1 || : + + # 可选:如果 /home/smart/.tms3 目录为空,则删除它。 + # 这与 RPM 的行为一致,RPM 只会删除它跟踪的文件。 + # 如果用户在该目录中创建了文件,RPM 不会删除该目录,此脚本也不会。 + local _app_base_dir="/home/smart/.tms3" + if [ -d "${_app_base_dir}" ] && [ -z "$(ls -A "${_app_base_dir}")" ]; then + rmdir "${_app_base_dir}" >/dev/null 2>&1 || : + fi + + echo "SmartTMS application has been removed." + echo "Note: User 'smart' and its home directory are NOT removed." + echo "Any user-generated data in /home/smart/.tms3 (not tracked by the package) remains." +} diff --git a/tms-bbt.tar.gz b/tms-bbt.tar.gz new file mode 100644 index 0000000..7769f59 Binary files /dev/null and b/tms-bbt.tar.gz differ