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.
This commit is contained in:
Ben Hutchings 2018-08-10 13:55:25 +01:00
parent 27f02c775b
commit 4aa097dc5e
2 changed files with 24 additions and 0 deletions

22
debian/bin/genorig.py vendored
View File

@ -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:

2
debian/changelog vendored
View File

@ -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 <ukleinek@debian.org> Sat, 21 Jul 2018 16:52:01 +0200