name: Build Debian Package on: push: branches: [ main, develop ] pull_request: branches: [ main ] release: types: [ published ] jobs: build-deb: runs-on: ubuntu-24.04 steps: - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y \ build-essential \ devscripts \ debhelper \ dh-make \ fakeroot \ lintian \ ostree \ libostree-dev \ git \ curl \ wget - name: Build apt-layer binary run: | make clean make ls -la bin/ - name: Create Debian package structure run: | # Create package directory mkdir -p apt-layer-1.0.0 cd apt-layer-1.0.0 # Copy binary and create directory structure mkdir -p usr/local/bin mkdir -p usr/local/share/apt-layer mkdir -p usr/local/share/doc/apt-layer mkdir -p usr/local/share/man/man1 mkdir -p etc/apt-layer # Copy binary cp ../../bin/apt-layer usr/local/bin/ chmod +x usr/local/bin/apt-layer # Copy documentation cp ../../README.md usr/local/share/doc/apt-layer/ cp ../../README-C.md usr/local/share/doc/apt-layer/ cp ../../LICENSE usr/local/share/doc/apt-layer/ # Create man page cat > usr/local/share/man/man1/apt-layer.1 << 'EOF' .TH APT-LAYER 1 "2024" "apt-layer" "User Commands" .SH NAME apt-layer \- Create OSTree layers using apt packages .SH SYNOPSIS .B apt-layer [\fIOPTIONS\fR] \fIBASE-BRANCH\fR \fINEW-BRANCH\fR [\fIPACKAGES\fR...] .SH DESCRIPTION apt-layer is a tool for creating OSTree layers using apt packages, inspired by rpm-ostree. .SH OPTIONS .TP .B \-\-help Show help message .TP .B \-\-version Show version information .TP .B \-\-list List available branches .TP .B \-\-info \fIBRANCH\fR Show information about a branch .TP .B \-\-container Use container-based layer creation .TP .B \-\-oci-export \fIBRANCH\fR \fIIMAGE-NAME\fR Export branch as OCI image .SH EXAMPLES .TP Create a gaming layer: .B apt-layer particleos/base/trixie particleos/gaming/trixie steam wine .TP Create container-based layer: .B apt-layer \-\-container particleos/base/trixie particleos/gaming/trixie steam wine .SH AUTHOR Written for ParticleOS project .SH BUGS Report bugs to the ParticleOS project EOF # Create configuration file cat > etc/apt-layer/config << 'EOF' # apt-layer configuration OSTREE_REPO=/var/lib/apt-layer/ostree-repo BUILD_DIR=/var/lib/apt-layer/build CONTAINER_RUNTIME=podman LOG_LEVEL=info EOF # Create postinst script cat > DEBIAN/postinst << 'EOF' #!/bin/bash set -e # Create directories mkdir -p /var/lib/apt-layer/ostree-repo mkdir -p /var/lib/apt-layer/build mkdir -p /var/lib/apt-layer/cache # Set permissions chown -R root:root /var/lib/apt-layer chmod 755 /var/lib/apt-layer chmod 755 /var/lib/apt-layer/ostree-repo chmod 755 /var/lib/apt-layer/build chmod 755 /var/lib/apt-layer/cache # Update man database if command -v mandb >/dev/null 2>&1; then mandb -q fi echo "apt-layer installed successfully" echo "Configuration: /etc/apt-layer/config" echo "Data directory: /var/lib/apt-layer" EOF # Create prerm script cat > DEBIAN/prerm << 'EOF' #!/bin/bash set -e echo "Removing apt-layer..." EOF # Create postrm script cat > DEBIAN/postrm << 'EOF' #!/bin/bash set -e if [ "$1" = "purge" ]; then echo "Purging apt-layer data..." rm -rf /var/lib/apt-layer rm -rf /etc/apt-layer fi EOF # Set permissions chmod 755 DEBIAN/postinst chmod 755 DEBIAN/prerm chmod 755 DEBIAN/postrm # Create control file cat > DEBIAN/control << 'EOF' Package: apt-layer Version: 1.0.0 Section: admin Priority: optional Architecture: amd64 Depends: ostree, podman | docker.io, build-essential Recommends: git, curl, wget Maintainer: ParticleOS Team Description: Create OSTree layers using apt packages apt-layer is a tool for creating OSTree layers using apt packages, inspired by rpm-ostree and designed for Ubuntu/Debian-based immutable systems like ParticleOS. . Features: * Layer creation with apt packages * Container-based isolation * OCI export functionality * Layer management and rollback * Recipe support for declarative layers EOF # Create changelog cat > DEBIAN/changelog << 'EOF' apt-layer (1.0.0) unstable; urgency=medium * Initial release * C implementation of apt-layer * OSTree layer creation * Container-based builds * OCI export functionality -- ParticleOS Team $(date -R) EOF # Create copyright cat > DEBIAN/copyright << 'EOF' Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: apt-layer Source: https://github.com/particleos/apt-layer Files: * Copyright: 2024 ParticleOS Team License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. EOF # Create conffiles echo "/etc/apt-layer/config" > DEBIAN/conffiles # Create md5sums find usr etc -type f -exec md5sum {} \; > DEBIAN/md5sums - name: Build Debian package run: | cd apt-layer-1.0.0 # Build the package dpkg-buildpackage -b -us -uc -rfakeroot # Check the package lintian ../apt-layer_1.0.0_amd64.deb || true - name: Upload package artifact uses: actions/upload-artifact@v4 with: name: apt-layer-deb path: apt-layer_1.0.0_amd64.deb retention-days: 30 - name: Create release asset (on release) if: github.event_name == 'release' run: | cp apt-layer_1.0.0_amd64.deb apt-layer_${{ github.event.release.tag_name }}_amd64.deb - name: Upload to release (on release) if: github.event_name == 'release' uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: ./apt-layer_${{ github.event.release.tag_name }}_amd64.deb asset_name: apt-layer_${{ github.event.release.tag_name }}_amd64.deb asset_content_type: application/vnd.debian.binary-package