# Maintainer: Your Name pkgname=wine-dcc pkgver=1.0 pkgrel=1 pkgdesc="A Wine-based package for running DCC applications with a pre-configured Wine prefix." arch=('x86_64') url="https://example.com/dcc" license=('unknown') # 修正 depends 语法,并添加 wine 依赖 depends=('xdg-utils') source=( "wine-dcc.tar.gz" ) sha256sums=('c8b873e46a6cb210abf3c4b9296d413d51abce0ac238cdf50d81d2ba84bbc299') install="${pkgname}.install" prepare() { # makepkg 已经自动将 wine-dcc.tar.gz 的内容解压到 $srcdir/ # 根据用户反馈,解压出来的文件没有顶层目录,直接位于 $srcdir 下。 # 为了方便后续的复制操作,我们创建一个临时子目录,并将所有应用内容移动进去。 local _temp_app_dir="${srcdir}/_app_contents" mkdir -p "${_temp_app_dir}" echo "Moving application contents from $srcdir to $_temp_app_dir..." # 移动所有属于应用程序的文件和目录 # 确保这些文件在 $srcdir 中存在,否则 mv 命令会报错 mv "${srcdir}/DCC2.desktop" "${_temp_app_dir}/" || true mv "${srcdir}/DCC2.jpg" "${_temp_app_dir}/" || true mv "${srcdir}/DCC.desktop" "${_temp_app_dir}/" || true mv "${srcdir}/DCC.jpg" "${_temp_app_dir}/" || true mv "${srcdir}/DCCs2.exe" "${_temp_app_dir}/" || true mv "${srcdir}/.wine" "${_temp_app_dir}/" || true mv "${srcdir}/wine" "${_temp_app_dir}/" || true # 假设 'wine' 是一个目录,其下有 bin/wine msg "Application contents prepared in $_temp_app_dir." } build() { # 对于预编译的Wine应用程序包,通常没有编译步骤 msg "No build step required for pre-compiled Wine application." } package() { set -x # 启用调试输出 local _app_base_dir="/opt/${pkgname}" # 应用程序的根目录,例如 /opt/wine-dcc/ local _wine_bin_path="${_app_base_dir}/wine/bin" # Wine可执行文件所在的bin目录 local _app_source_dir="${srcdir}/_app_contents" # 应用程序内容的来源目录 local _template_wine_prefix="${_app_base_dir}/.wine" # 系统级的Wine前缀模板 # 1. 创建目标目录 install -d "${pkgdir}${_app_base_dir}" install -d "${pkgdir}/usr/bin" install -d "${pkgdir}/usr/share/applications" install -d "${pkgdir}/usr/share/pixmaps" # 用于存放图标 install -d "${pkgdir}/etc/profile.d" # 用于存放环境变量脚本 # 2. 复制 _app_contents 目录下的所有内容到 /opt/wine-dcc/ echo "Copying wine-dcc contents from $_app_source_dir to ${pkgdir}${_app_base_dir}..." cp -a "${_app_source_dir}/." "${pkgdir}${_app_base_dir}/" # 3. 设置 /opt/wine-dcc/ 下的可执行文件权限 # 确保自定义的 'wine' 可执行文件和 Windows exe 具有执行权限 find "${pkgdir}${_wine_bin_path}" -type f -exec chmod 755 {} \; || true # 确保 wine/bin 下的所有文件可执行 chmod 755 "${pkgdir}${_app_base_dir}/DCCs2.exe" # 确保 Windows exe 可执行 # 4. 复制图标文件到 /usr/share/pixmaps/ echo "Copying icons to ${pkgdir}/usr/share/pixmaps/..." install -m644 "${_app_source_dir}/DCC.jpg" "${pkgdir}/usr/share/pixmaps/" install -m644 "${_app_source_dir}/DCC2.jpg" "${pkgdir}/usr/share/pixmaps/" # 5. 创建 /usr/bin 下的启动器脚本 echo "Creating launcher scripts in ${pkgdir}/usr/bin/..." # DCC 启动器 install -D -m755 /dev/null "${pkgdir}/usr/bin/dcc" cat > "${pkgdir}/usr/bin/dcc" <<'EOF' #!/bin/bash # Define the path for the user's Wine prefix in their home directory USER_WINEPREFIX="${HOME}/.wine-dcc" TEMPLATE_WINEPREFIX="/opt/wine-dcc/.wine" APP_BASE_DIR="/opt/wine-dcc" CUSTOM_WINE_BINARY="${APP_BASE_DIR}/wine/bin/wine" WINDOWS_EXE="DCCs2.exe" # Check if the user's Wine prefix exists. If not, copy the template. if [ ! -d "${USER_WINEPREFIX}" ]; then echo "Initializing Wine prefix for user ${USER} at ${USER_WINEPREFIX}..." mkdir -p "$(dirname "${USER_WINEPREFIX}")" # Ensure parent directory exists cp -a "${TEMPLATE_WINEPREFIX}" "${USER_WINEPREFIX}" # Ensure the copied prefix is owned by the current user (cp -a to home dir usually handles this) # chown -R "${USER}":"${USER}" "${USER_WINEPREFIX}" # Usually not needed if copying to HOME echo "Wine prefix initialized." fi # Set WINEPREFIX to the user's specific prefix export WINEPREFIX="${USER_WINEPREFIX}" # Change directory to the application's installation path (where DCCs2.exe resides) cd "${APP_BASE_DIR}" || { echo "Error: Cannot change directory to ${APP_BASE_DIR}"; exit 1; } # Execute the custom Wine binary from its bin directory with the Windows executable exec "${CUSTOM_WINE_BINARY}" "${WINDOWS_EXE}" EOF # DCC2 启动器 install -D -m755 /dev/null "${pkgdir}/usr/bin/dcc2" cat > "${pkgdir}/usr/bin/dcc2" <<'EOF' #!/bin/bash # Define the path for the user's Wine prefix in their home directory USER_WINEPREFIX="${HOME}/.wine-dcc" TEMPLATE_WINEPREFIX="/opt/wine-dcc/.wine" APP_BASE_DIR="/opt/wine-dcc" CUSTOM_WINE_BINARY="${APP_BASE_DIR}/wine/bin/wine" WINDOWS_EXE_PATH="/opt/wine-dcc/.wine/drive_c/Program Files (x86)/Projector User Supportware/Digital Cinema Communicator v2/DigitalCinemaCommunicator2.exe" # Full path to the second EXE # Check if the user's Wine prefix exists. If not, copy the template. if [ ! -d "${USER_WINEPREFIX}" ]; then echo "Initializing Wine prefix for user ${USER} at ${USER_WINEPREFIX}..." mkdir -p "$(dirname "${USER_WINEPREFIX}")" # Ensure parent directory exists cp -a "${TEMPLATE_WINEPREFIX}" "${USER_WINEPREFIX}" # chown -R "${USER}":"${USER}" "${USER_WINEPREFIX}" # Usually not needed if copying to HOME echo "Wine prefix initialized." fi # Set WINEPREFIX to the user's specific prefix export WINEPREFIX="${USER_WINEPREFIX}" # Change directory to the application's installation path (important for Wine's working directory) cd "${APP_BASE_DIR}" || { echo "Error: Cannot change directory to ${APP_BASE_DIR}"; exit 1; } # Execute the custom Wine binary from its bin directory with the full path to the Windows executable exec "${CUSTOM_WINE_BINARY}" "${WINDOWS_EXE_PATH}" EOF # 6. 复制并修改 .desktop 文件 echo "Installing and modifying .desktop files in ${pkgdir}/usr/share/applications/..." # DCC.desktop install -m644 "${_app_source_dir}/DCC.desktop" "${pkgdir}/usr/share/applications/dcc.desktop" sed -i "s|^Exec=.*|Exec=/usr/bin/dcc|g" "${pkgdir}/usr/share/applications/dcc.desktop" sed -i "s|^Icon=.*|Icon=DCC.jpg|g" "${pkgdir}/usr/share/applications/dcc.desktop" sed -i "/^\[Desktop Entry\]/aName=DCC Application" "${pkgdir}/usr/share/applications/dcc.desktop" || true # DCC2.desktop install -m644 "${_app_source_dir}/DCC2.desktop" "${pkgdir}/usr/share/applications/dcc2.desktop" sed -i "s|^Exec=.*|Exec=/usr/bin/dcc2|g" "${pkgdir}/usr/share/applications/dcc2.desktop" sed -i "s|^Icon=.*|Icon=DCC2.jpg|g" "${pkgdir}/usr/share/applications/dcc2.desktop" sed -i "/^\[Desktop Entry\]/aName=DCC2 Application" "${pkgdir}/usr/share/applications/dcc2.desktop" || true # 7. 创建 PATH 环境变量配置脚本 wine-dcc.sh # 将 /opt/wine-dcc/wine/bin 添加到 PATH echo "Creating PATH configuration script ${pkgdir}/etc/profile.d/wine-dcc.sh..." echo "export PATH=\"${_wine_bin_path}:\$PATH\"" > "${pkgdir}/etc/profile.d/wine-dcc.sh" chmod 0644 "${pkgdir}/etc/profile.d/wine-dcc.sh" echo "Package creation complete." }