summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Pereiaslov <perk11@perk11.info>2023-05-16 00:17:29 -0500
committerKonstantin Pereiaslov <perk11@perk11.info>2023-05-16 00:19:17 -0500
commit38984cfedc7e9c98f1865428edf57a265c2f4e1f (patch)
tree8e8be4d1b35201a956b0ce3f2337e13ca7abef4e
parentfaf0c48e42891da2a4b03fc34198fea1336a4140 (diff)
Add Ubuntu/Debian package build script0.1.0
-rw-r--r--.gitignore2
-rw-r--r--Makefile10
-rw-r--r--README.md8
-rw-r--r--distro-packages/ubuntu22.04/DEBIAN/control11
-rw-r--r--distro-packages/ubuntu22.04/Dockerfile20
-rwxr-xr-xdistro-packages/ubuntu22.04/build.sh17
6 files changed, 67 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..02fdd3f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+runwhenidle
+package-build/
diff --git a/Makefile b/Makefile
index 7132f45..7494f14 100644
--- a/Makefile
+++ b/Makefile
@@ -21,4 +21,12 @@ install: release
install -m 755 $(TARGET_EXEC) $(DESTDIR)$(PREFIX)/bin/
clean:
- rm -f runwhenidle \ No newline at end of file
+ rm -f runwhenidle
+
+debian-package:
+ docker build --build-arg HOST_UID=`id -u` --tag runwhenidle-ubuntu2204-build distro-packages/ubuntu22.04
+ docker run --user build -v .:/opt/src/runwhenidle runwhenidle-ubuntu2204-build /opt/src/runwhenidle/distro-packages/ubuntu22.04/build.sh
+
+clean-debian-package:
+ rm -rf package-build
+ docker rmi -f runwhenidle-ubuntu2204-build
diff --git a/README.md b/README.md
index 568bbb2..66721a0 100644
--- a/README.md
+++ b/README.md
@@ -40,3 +40,11 @@ Output debug information to stderr.
runwhenidle --timeout=300 -q "cat /dev/zero"
Run the `cat /dev/zero` command and pause it while user is active. `-q` option makes sure runwhenidle doesn't output anything other than the output of `cat /dev/zero`.
+
+
+### Building Ubuntu/Debian package:
+Make sure you have docker installed and run:
+
+ make debian-package
+
+The .deb file will be generated in `package-build/` directory. \ No newline at end of file
diff --git a/distro-packages/ubuntu22.04/DEBIAN/control b/distro-packages/ubuntu22.04/DEBIAN/control
new file mode 100644
index 0000000..5c841e8
--- /dev/null
+++ b/distro-packages/ubuntu22.04/DEBIAN/control
@@ -0,0 +1,11 @@
+Package: runwhenidle
+Version: $VERSION
+Architecture: amd64
+Depends: libc6 (>= 2.34), libx11-6, libxss1
+Maintainer: Konstantin Pereiaslov <perk11@perk11.info>
+Description: runwhenidle runs a computationally or IO-intensive program when user is not in front of the computer, pausing it once the user is back, resuming once the user left, often without requiring adaptation from the program being ran.
+ runwhenidle runs a command given to it, pauses it if the user is active by sending SIGTSTP to the command,
+ when the user activity stops, runwhenidle resumes the command by sending it SIGCONT signal.
+ It then checks once per second if user activity has resumed, and once it is, pauses the command again.
+ runwhenidle uses XScreenSaverQueryInfo() to check when last user activity happened therefore a running X server is required.
+ Wayland is not currently supported.
diff --git a/distro-packages/ubuntu22.04/Dockerfile b/distro-packages/ubuntu22.04/Dockerfile
new file mode 100644
index 0000000..c40bb2b
--- /dev/null
+++ b/distro-packages/ubuntu22.04/Dockerfile
@@ -0,0 +1,20 @@
+FROM ubuntu:22.04
+
+ARG DEBIAN_FRONTEND=noninteractive
+ARG HOST_UID
+
+
+RUN set -ex \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends \
+ build-essential \
+ fakeroot \
+ dpkg-dev \
+ libxss-dev \
+ git \
+ && apt-get clean \
+ && rm -rf /tmp/* /var/tmp/*
+
+RUN useradd build -u $HOST_UID \
+ && mkdir -p /home/build \
+ && chown build:build /home/build \ No newline at end of file
diff --git a/distro-packages/ubuntu22.04/build.sh b/distro-packages/ubuntu22.04/build.sh
new file mode 100755
index 0000000..754461e
--- /dev/null
+++ b/distro-packages/ubuntu22.04/build.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -e
+
+cd /opt/src/runwhenidle
+VERSION=`git describe --tags 2>/dev/null || (echo -n "0.0-dev-" && git rev-parse HEAD)`
+ARCH=`dpkg --print-architecture`
+BUILD_DIR="package-build/runwhenidle_${VERSION}_${ARCH}"
+TARGET_DIRECTORY='/usr/bin'
+
+make clean release
+rm -r $BUILD_DIR 2>/dev/null || true
+mkdir -p $BUILD_DIR/$TARGET_DIRECTORY
+cp runwhenidle $BUILD_DIR/$TARGET_DIRECTORY/
+cp -r distro-packages/ubuntu22.04/DEBIAN $BUILD_DIR/
+
+sed -i "s/\$VERSION/$VERSION/g" $BUILD_DIR/DEBIAN/control
+dpkg-deb --build --root-owner-group $BUILD_DIR \ No newline at end of file