diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 75a0dfb152..b4ec2d81c1 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -126,7 +126,7 @@ jobs: # The install step puts files in build/release/install cd build/release if [ -d "install" ]; then - mv install "${ARTIFACT_NAME}" + cp -a install "${ARTIFACT_NAME}" tar -cJf "${ARTIFACT_NAME}.tar.xz" "${ARTIFACT_NAME}" sha256sum "${ARTIFACT_NAME}.tar.xz" > "${ARTIFACT_NAME}.tar.xz.sha256" echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV @@ -137,11 +137,21 @@ jobs: exit 1 fi + - name: Build .deb package + shell: bash + run: | + # Build .deb package from installed files + VERSION=$(git describe --tags --always) + VERSION="${VERSION#v}" + VERSION="${VERSION//-/.}" + ./package/debian/build-deb.sh build/release/install build/release "$VERSION" + - name: Upload build artifact uses: https://code.forgejo.org/actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} path: | build/release/*.tar.xz + build/release/*.deb build/release/*.sha256 retention-days: 30 diff --git a/package/debian/build-deb.sh b/package/debian/build-deb.sh new file mode 100755 index 0000000000..dfbde769a6 --- /dev/null +++ b/package/debian/build-deb.sh @@ -0,0 +1,131 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +# Build a .deb package from the installed build directory +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +# Parse arguments +INSTALL_DIR="${1:-}" +OUTPUT_DIR="${2:-}" +VERSION="${3:-}" + +if [ -z "$INSTALL_DIR" ] || [ -z "$OUTPUT_DIR" ]; then + echo "Usage: $0 [version]" + echo " install-dir: Directory containing installed build (e.g., build/release/install)" + echo " output-dir: Directory to write the .deb file" + echo " version: Package version (default: from git describe)" + exit 1 +fi + +# Get version from git if not provided +if [ -z "$VERSION" ]; then + VERSION=$(cd "$PROJECT_ROOT" && git describe --tags --always 2>/dev/null || echo "0.1.0") + # Clean up version for debian (replace - with .) + VERSION="${VERSION#v}" # Remove leading 'v' if present + VERSION="${VERSION//-/.}" # Replace - with . +fi + +PACKAGE_NAME="kindred-create" +ARCH="amd64" +DEB_NAME="${PACKAGE_NAME}_${VERSION}_${ARCH}" + +echo "Building .deb package: ${DEB_NAME}.deb" +echo " Source: ${INSTALL_DIR}" +echo " Output: ${OUTPUT_DIR}" +echo " Version: ${VERSION}" + +# Create staging directory +STAGING_DIR=$(mktemp -d) +trap "rm -rf ${STAGING_DIR}" EXIT + +# Create debian package structure +mkdir -p "${STAGING_DIR}/DEBIAN" +mkdir -p "${STAGING_DIR}/opt/${PACKAGE_NAME}" +mkdir -p "${STAGING_DIR}/usr/bin" +mkdir -p "${STAGING_DIR}/usr/share/applications" +mkdir -p "${STAGING_DIR}/usr/share/icons/hicolor/scalable/apps" +mkdir -p "${STAGING_DIR}/usr/share/mime/packages" + +# Copy installed files +echo "Copying installed files..." +cp -a "${INSTALL_DIR}"/* "${STAGING_DIR}/opt/${PACKAGE_NAME}/" + +# Create symlinks in /usr/bin +ln -sf "/opt/${PACKAGE_NAME}/bin/FreeCAD" "${STAGING_DIR}/usr/bin/kindred-create" +ln -sf "/opt/${PACKAGE_NAME}/bin/FreeCADCmd" "${STAGING_DIR}/usr/bin/kindred-create-cmd" + +# Create desktop entry +cat > "${STAGING_DIR}/usr/share/applications/kindred-create.desktop" << 'EOF' +[Desktop Entry] +Name=Kindred Create +Comment=Engineering-focused parametric 3D CAD platform +Exec=/opt/kindred-create/bin/FreeCAD %F +Icon=kindred-create +Terminal=false +Type=Application +Categories=Graphics;Science;Engineering; +MimeType=application/x-extension-fcstd; +StartupWMClass=FreeCAD +EOF + +# Copy icon if available, otherwise create a placeholder reference +if [ -f "${INSTALL_DIR}/share/icons/hicolor/scalable/apps/org.freecad.FreeCAD.svg" ]; then + cp "${INSTALL_DIR}/share/icons/hicolor/scalable/apps/org.freecad.FreeCAD.svg" \ + "${STAGING_DIR}/usr/share/icons/hicolor/scalable/apps/kindred-create.svg" +elif [ -f "${INSTALL_DIR}/share/icons/hicolor/scalable/apps/freecad.svg" ]; then + cp "${INSTALL_DIR}/share/icons/hicolor/scalable/apps/freecad.svg" \ + "${STAGING_DIR}/usr/share/icons/hicolor/scalable/apps/kindred-create.svg" +fi + +# Generate control file with actual version +sed "s/\${VERSION}/${VERSION}/" "${SCRIPT_DIR}/control" > "${STAGING_DIR}/DEBIAN/control" + +# Calculate installed size (in KB) +INSTALLED_SIZE=$(du -sk "${STAGING_DIR}" | cut -f1) +echo "Installed-Size: ${INSTALLED_SIZE}" >> "${STAGING_DIR}/DEBIAN/control" + +# Create postinst script for updating desktop database +cat > "${STAGING_DIR}/DEBIAN/postinst" << 'EOF' +#!/bin/bash +set -e +if [ -x /usr/bin/update-desktop-database ]; then + /usr/bin/update-desktop-database -q /usr/share/applications || true +fi +if [ -x /usr/bin/gtk-update-icon-cache ]; then + /usr/bin/gtk-update-icon-cache -q /usr/share/icons/hicolor || true +fi +EOF +chmod 755 "${STAGING_DIR}/DEBIAN/postinst" + +# Create postrm script +cat > "${STAGING_DIR}/DEBIAN/postrm" << 'EOF' +#!/bin/bash +set -e +if [ -x /usr/bin/update-desktop-database ]; then + /usr/bin/update-desktop-database -q /usr/share/applications || true +fi +if [ -x /usr/bin/gtk-update-icon-cache ]; then + /usr/bin/gtk-update-icon-cache -q /usr/share/icons/hicolor || true +fi +EOF +chmod 755 "${STAGING_DIR}/DEBIAN/postrm" + +# Set proper permissions +find "${STAGING_DIR}" -type d -exec chmod 755 {} \; +find "${STAGING_DIR}/opt" -type f -exec chmod 644 {} \; +find "${STAGING_DIR}/opt/${PACKAGE_NAME}/bin" -type f -exec chmod 755 {} \; +chmod 755 "${STAGING_DIR}/DEBIAN/postinst" +chmod 755 "${STAGING_DIR}/DEBIAN/postrm" + +# Build the .deb package +mkdir -p "${OUTPUT_DIR}" +dpkg-deb --build --root-owner-group "${STAGING_DIR}" "${OUTPUT_DIR}/${DEB_NAME}.deb" + +# Generate checksum +cd "${OUTPUT_DIR}" +sha256sum "${DEB_NAME}.deb" > "${DEB_NAME}.deb.sha256" + +echo "Package created: ${OUTPUT_DIR}/${DEB_NAME}.deb" +ls -lh "${OUTPUT_DIR}/${DEB_NAME}.deb" diff --git a/package/debian/control b/package/debian/control new file mode 100644 index 0000000000..6bde8752a4 --- /dev/null +++ b/package/debian/control @@ -0,0 +1,13 @@ +Package: kindred-create +Version: ${VERSION} +Section: science +Priority: optional +Architecture: amd64 +Maintainer: Kindred Team +Description: Engineering-focused parametric 3D CAD platform + Kindred Create is an engineering-focused parametric 3D CAD platform + built on FreeCAD 1.0+. It provides a streamlined interface for + mechanical engineering and product design with integrated workbenches + for Part Design, Assembly, and Sketcher tools. +Depends: libc6 (>= 2.31), libstdc++6 (>= 10), libgl1, libx11-6, libxcb1 +Homepage: https://gitea.kindred.internal/kindred/create