Skip to content

Commit

Permalink
Add Ubuntu/Debian package build script
Browse files Browse the repository at this point in the history
  • Loading branch information
perk11 committed May 16, 2023
1 parent faf0c48 commit 38984cf
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runwhenidle
package-build/
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ install: release
install -m 755 $(TARGET_EXEC) $(DESTDIR)$(PREFIX)/bin/

clean:
rm -f runwhenidle
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 11 additions & 0 deletions distro-packages/ubuntu22.04/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 20 additions & 0 deletions distro-packages/ubuntu22.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions distro-packages/ubuntu22.04/build.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 38984cf

Please sign in to comment.