add Debian packaging and repository infrastructure
Some checks failed
Build and Publish Debian Package / build-deb (push) Failing after 1m33s
Build Deb-Mock Package / build (push) Successful in 1m22s
Test Deb-Mock Build / test (push) Failing after 50s

This commit is contained in:
robojerk 2025-08-03 23:38:25 +00:00
parent b88f1af666
commit 16bfc027bf
12 changed files with 639 additions and 4 deletions

108
scripts/setup-debian-repo.sh Executable file
View file

@ -0,0 +1,108 @@
#!/bin/bash
set -e
# Setup script for Deb-Mock Debian Repository
# This script sets up a Debian repository on the Forgejo server
REPO_DIR="/var/www/debian-repo"
REPO_USER="www-data"
REPO_GROUP="www-data"
echo "Setting up Deb-Mock Debian Repository..."
# Create repository directory
sudo mkdir -p "$REPO_DIR"
sudo chown "$REPO_USER:$REPO_GROUP" "$REPO_DIR"
# Install required packages
sudo apt update
sudo apt install -y reprepro nginx apache2-utils
# Create repository structure
sudo -u "$REPO_USER" mkdir -p "$REPO_DIR/conf"
sudo -u "$REPO_USER" mkdir -p "$REPO_DIR/dists"
sudo -u "$REPO_USER" mkdir -p "$REPO_DIR/pool"
# Create repository configuration
sudo -u "$REPO_USER" cat > "$REPO_DIR/conf/distributions" << 'EOF'
Origin: Deb-Mock Repository
Label: Deb-Mock
Codename: unstable
Architectures: amd64 arm64 i386 all source
Components: main
Description: Deb-Mock Debian Package Repository
SignWith: default
EOF
# Create options file
sudo -u "$REPO_USER" cat > "$REPO_DIR/conf/options" << 'EOF'
verbose
basedir .
EOF
# Create incoming directory for package uploads
sudo -u "$REPO_USER" mkdir -p "$REPO_DIR/incoming"
# Set up nginx configuration
sudo cat > /etc/nginx/sites-available/debian-repo << 'EOF'
server {
listen 80;
server_name debian.raines.xyz;
root /var/www/debian-repo;
index index.html;
location / {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
location ~ /\. {
deny all;
}
}
EOF
# Enable the site
sudo ln -sf /etc/nginx/sites-available/debian-repo /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# Create GPG key for repository signing (if not exists)
if ! gpg --list-keys deb-mock@raines.xyz >/dev/null 2>&1; then
echo "Creating GPG key for repository signing..."
cat > /tmp/gpg-batch << 'EOF'
%echo Generating GPG key for Deb-Mock repository
Key-Type: RSA
Key-Length: 4096
Name-Real: Deb-Mock Repository
Name-Email: deb-mock@raines.xyz
Expire-Date: 0
%commit
%echo GPG key generation complete
EOF
gpg --batch --generate-key /tmp/gpg-batch
rm /tmp/gpg-batch
fi
# Export public key
gpg --armor --export deb-mock@raines.xyz > "$REPO_DIR/deb-mock.gpg.key"
# Set proper permissions
sudo chown -R "$REPO_USER:$REPO_GROUP" "$REPO_DIR"
sudo chmod -R 755 "$REPO_DIR"
echo "Deb-Mock Debian Repository setup complete!"
echo ""
echo "Repository URL: http://debian.raines.xyz"
echo "Public key: http://debian.raines.xyz/deb-mock.gpg.key"
echo ""
echo "To add this repository to a Debian system:"
echo "wget -O - http://debian.raines.xyz/deb-mock.gpg.key | sudo apt-key add -"
echo "echo 'deb http://debian.raines.xyz unstable main' | sudo tee /etc/apt/sources.list.d/deb-mock.list"
echo "sudo apt update"
echo ""
echo "To add a package to the repository:"
echo "reprepro -b $REPO_DIR includedeb unstable /path/to/package.deb"

47
scripts/upload-to-repo.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
set -e
# Upload script for Deb-Mock Debian Repository
# This script uploads built packages to the repository
REPO_DIR="/var/www/debian-repo"
PACKAGE_DIR="."
echo "Uploading Deb-Mock packages to repository..."
# Check if we're in the right directory
if [ ! -f "debian/control" ]; then
echo "Error: Not in deb-mock source directory"
exit 1
fi
# Build the package if not already built
if [ ! -f "../deb-mock_*.deb" ]; then
echo "Building Debian package..."
dpkg-buildpackage -us -uc -b
fi
# Find the built package
PACKAGE_FILE=$(ls ../deb-mock_*.deb | head -1)
if [ ! -f "$PACKAGE_FILE" ]; then
echo "Error: No deb-mock package found"
exit 1
fi
echo "Found package: $PACKAGE_FILE"
# Upload to repository
echo "Adding package to repository..."
sudo reprepro -b "$REPO_DIR" includedeb unstable "$PACKAGE_FILE"
# Update repository
echo "Updating repository..."
sudo reprepro -b "$REPO_DIR" export unstable
# List repository contents
echo "Repository contents:"
sudo reprepro -b "$REPO_DIR" list unstable
echo "Package uploaded successfully!"
echo "Repository URL: http://debian.raines.xyz"