From 4aa097dc5ecb9e487bd6df889e3ae7dee1f12f59 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 10 Aug 2018 13:55:25 +0100 Subject: [PATCH] debian/bin/genorig.py: Add support for debian/copyright Files-Excluded field This isn't part of the machine-readable copyright format 1.0, but is an extension supported by mk-origtargz. --- debian/bin/genorig.py | 22 ++++++++++++++++++++++ debian/changelog | 2 ++ 2 files changed, 24 insertions(+) diff --git a/debian/bin/genorig.py b/debian/bin/genorig.py index a35a9236f..36ac95642 100755 --- a/debian/bin/genorig.py +++ b/debian/bin/genorig.py @@ -3,12 +3,15 @@ import sys sys.path.append("debian/lib/python") +import deb822 +import glob import os import os.path import re import shutil import subprocess import time +import warnings from debian_linux.debian import Changelog, VersionLinux from debian_linux.patches import PatchSeries @@ -60,6 +63,7 @@ class Main(object): .st_mtime)) self.debian_patch() + self.exclude_files() os.umask(old_umask) self.tar(orig_date) finally: @@ -129,6 +133,24 @@ class Main(object): series = PatchSeries(name, "debian/patches", fp) series(dir=os.path.join(self.dir, self.orig)) + def exclude_files(self): + self.log("Excluding file patterns specified in debian/copyright\n") + with open("debian/copyright") as f: + header = deb822.Deb822(f) + patterns = header.get("Files-Excluded", '').strip().split() + for pattern in patterns: + matched = False + for name in glob.glob(os.path.join(self.dir, self.orig, pattern)): + try: + shutil.rmtree(name) + except NotADirectoryError: + os.unlink(name) + matched = True + if not matched: + warnings.warn("Exclusion pattern '%s' did not match anything" + % pattern, + RuntimeWarning) + def tar(self, orig_date): out = os.path.join("../orig", self.orig_tar) try: diff --git a/debian/changelog b/debian/changelog index eddb24f7e..5da843086 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,8 @@ linux (4.18~rc7-1~exp1) UNRELEASED; urgency=medium * debian/bin/gencontrol_signed.py: Add certificate fingerprints to template metadata * scripts/kernel-doc: Escape all literal braces in regexes (Closes: #905116) + * debian/bin/genorig.py: Add support for debian/copyright Files-Excluded + field -- Uwe Kleine-König Sat, 21 Jul 2018 16:52:01 +0200