1

We have an issue with a Debian package that would have to be addressed upstream. (So it's not Debian specific.) I've managed to patch the C source, build my custom package version, and fix the issue.

But how do I set up a continuous process to have my patch done automatically when there's a new version of the package, e.g., a security update? (I can't wait for an official "solution" as my users already throw eggs at me. ;D )

Is there a tool one can use? Or do I have to build such a thing myself?

We already have a custom APT repository, but it has only been used for internal software up to now.

I identify these steps I would have to make:

  1. Recognize when there is a new version of the package in the official Debian repository. (Cronjob?)
  2. Download the source package.
  3. Apply my patch.
  4. Alter the CONTROL file of the deb package to make my patched version "newer" than the original package (necessary? or just make my custom APT repository have a higher priority than the original Debian repository, so in case of equal version my custom package "wins"??)
  5. Build the package.
  6. scp it to the custom repository web server.
  7. Send a notification email that I have to regenerate the indexes and sign them (GPG).

Concerning step (4): How do I increase any arbitrary upstream version string by a "micro" revision so that my version is newer than the original one? Just append ".1"?

Do you have such a process set up already, so I wouldn't have to reinvent the wheel?

3
  • 2
    For step 4, the safest way is to use dch --local with a suffix of your choice (dch --local mrsnrub for example). Commented Sep 28 at 18:50
  • @StephenKitt Thank you! I wasn't aware of that tool! Commented Sep 28 at 20:05
  • 1
    Have you considered submitting the patch to the Debian maintainer? They could (as I understand it, at least) incorporate your patch - assuming it's something of value to more than just you - while it's considered for upstream inclusion/fixing Commented Sep 29 at 18:25

1 Answer 1

2

As a starter/trigger:

#!/bin/sh

package=apt

apt-get update -yyq >/dev/null 2>&1

if ! apt-cache policy "$package" |
    awk '
        $1=="Installed:"{i=$2}
        $1=="Candidate:"{n=$2;last}
        END{if (i!=n) exit 0; else exit 1}'
then
    exit 0 # no new version, bail out early
fi



# here the rest of the script

# patch
# scp
# ...

This can be the beginning of a script to run as a cronjob.

2
  • This assumes that the target package is installed, which might not be the case — it would probably be more useful to compare package versions between repositories (which is also possible with apt-cache policy). You also don’t need to go through output strings in res, awk can exit with a specific exit code and thus be used directly in an if construct. Commented Sep 28 at 19:16
  • 1
    Post edited accordingly to use exit() instead of string comparison. Commented Sep 28 at 19:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.