Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Builder for debian .deb package including running from system #2734

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/build-deb-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Debian Package
# Check status: systemctl status changedetection.io.service
# Get logs: journalctl -u changedetection.io.service
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-deb:
runs-on: ubuntu-latest
name: Build and Package changedetection.io

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install Build Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
devscripts \
dh-virtualenv \
dh-python \
python3-all \
python3-all-dev \
python3.10 \
python3.10-venv \
python3.10-dev \
debhelper-compat

- name: Build the Debian Package
run: |
debuild -us -uc

- name: Upload Debian Package Artifact
uses: actions/upload-artifact@v3
with:
name: changedetection.io-deb-package
path: ../*.deb
4 changes: 4 additions & 0 deletions changedetectionio/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import main

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./debian/changedetection.io.service
13 changes: 13 additions & 0 deletions debian/changedetection.io.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=changedetection.io Service
After=network.target

[Service]
User=changedetio
Group=changedetio
WorkingDirectory=/opt/changedetection.io
ExecStart=/opt/changedetection.io/bin/python -m changedetectionio
Restart=on-failure

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=changedetection.io Service
After=network.target

[Service]
User=changedetio
Group=changedetio
WorkingDirectory=/opt/changedetection.io
ExecStart=/opt/changedetection.io/bin/python -m changedetectionio
Restart=on-failure

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changedetection.io (1.0-1) unstable; urgency=medium

* Initial release.

-- Your Name <[email protected]> Wed, 01 Nov 2023 12:00:00 +0000
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changedetection.io (1.0-1) unstable; urgency=medium

* Initial release.

-- Your Name <[email protected]> Wed, 01 Nov 2023 12:00:00 +0000
14 changes: 14 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Source: changedetection.io
Section: web
Priority: optional
Maintainer: Your Name <[email protected]>
Build-Depends: debhelper-compat (= 13), dh-virtualenv, dh-python, python3-all (>= 3.10), python3-all (<< 3.13), python3.10, python3.10-venv
Standards-Version: 4.6.0
Rules-Requires-Root: no
Homepage: https://github.com/dgtlmoon/changedetection.io

Package: changedetection.io
Architecture: all
Depends: ${misc:Depends}, python3 (>= 3.10), python3 (<< 3.13)
Description: Web page change detection - Python application
A web-based application for monitoring web pages for changes.
1 change: 1 addition & 0 deletions debian/debhelper-build-stamp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
changedetection.io
1 change: 1 addition & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debian/changedetection.io.service lib/systemd/system/
23 changes: 23 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
set -e

# Determine Python version
PYTHON_VERSION=$(ls /usr/bin/python3.1[0-2] | head -n1 | xargs basename)

# Create 'changedetio' user if it doesn't exist
if ! id "changedetio" >/dev/null 2>&1; then
adduser --system --group --no-create-home changedetio
fi

# Set ownership of the installation directory
chown -R changedetio:changedetio /opt/changedetection.io

# Update the systemd service file if necessary
sed -i "s|ExecStart=.*|ExecStart=/opt/changedetection.io/bin/$PYTHON_VERSION -m changedetectionio|" /lib/systemd/system/changedetection.io.service

# Enable and start the service
systemctl daemon-reload
systemctl enable changedetection.io.service
systemctl start changedetection.io.service

exit 0
11 changes: 11 additions & 0 deletions debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

# Remove user on purge
if [ "$1" = "purge" ]; then
deluser --system changedetio
fi

systemctl daemon-reload

exit 0
8 changes: 8 additions & 0 deletions debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

# Stop and disable the service
systemctl stop changedetection.io.service
systemctl disable changedetection.io.service

exit 0
12 changes: 12 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/make -f

%:
dh $@ --with python-virtualenv --buildsystem=pybuild

PYTHON_VERSION := $(shell py3versions -r '>= 3.10 << 3.13' -i)

override_dh_virtualenv:
dh_virtualenv --sourcedirectory=. \
--install-suffix='' \
--requirements=requirements.txt \
--python=/usr/bin/$(PYTHON_VERSION)
Loading