summaryrefslogtreecommitdiff
path: root/multiarchimport.py
diff options
context:
space:
mode:
authorJochen Sprickerhof <git@jochen.sprickerhof.de>2024-08-06 09:53:04 +0200
committerHelmut Grohne <helmut@subdivi.de>2025-05-17 07:15:42 +0200
commitdad32e42b9c9ef72e77d6c17930c194f92ff9e11 (patch)
tree0479333b22691e0a0f78a24bfb9462f6d25d7726 /multiarchimport.py
parent9295b2b88cd6f2d56c08a255d164ca1b4f661e35 (diff)
downloaddebian-dedup-dad32e42b9c9ef72e77d6c17930c194f92ff9e11.tar.gz
Ignore auto generated python3- maintainer scripts
Diffstat (limited to 'multiarchimport.py')
-rwxr-xr-xmultiarchimport.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/multiarchimport.py b/multiarchimport.py
index 84eab35..7d43938 100755
--- a/multiarchimport.py
+++ b/multiarchimport.py
@@ -6,6 +6,7 @@ import hashlib
import logging
import multiprocessing
import queue
+import re
import sqlite3
from urllib.request import urlopen
@@ -16,6 +17,61 @@ from dedup.debpkg import DebExtractor
from dedup.hashing import hash_file
from dedup.utils import fetchiter, iterate_packages
+PYTHON_MAINT_CONTENT = (
+ b"""#!/bin/sh
+set -e
+
+# Automatically added by dh_python3
+if command -v py3compile >/dev/null 2>&1; then
+ py3compile
+fi
+if command -v pypy3compile >/dev/null 2>&1; then
+ pypy3compile || true
+fi
+
+# End automatically added section
+""",
+ b"""#!/bin/sh
+set -e
+
+# Automatically added by dh_python3
+if command -v py3clean >/dev/null 2>&1; then
+ py3clean
+else
+ dpkg| sed -En -e '/^(.*)\\/(.+)\\.py$/s,,rm "\\1/__pycache__/\\2".*,e'
+ find /usr/lib/python3/dist-packages/ -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir
+fi
+
+# End automatically added section
+""",
+ b"""#!/bin/sh
+set -e
+
+# Automatically added by dh_python3
+if which py3compile >/dev/null 2>&1; then
+ py3compile
+fi
+if which pypy3compile >/dev/null 2>&1; then
+ pypy3compile || true
+fi
+
+# End automatically added section
+""",
+ b"""#!/bin/sh
+set -e
+
+# Automatically added by dh_python3
+if which py3clean >/dev/null 2>&1; then
+ py3clean
+else
+ dpkg| perl -ne 's,/([^/]*)\\.py$,/__pycache__/\\1.*, or next; unlink $_ or die $! foreach glob($_)'
+ find /usr/lib/python3/dist-packages/ -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir
+fi
+
+# End automatically added section
+"""
+ )
+
def release_architectures(mirror):
with closing(urlopen("%s/dists/testing/Release" % mirror)) as f:
return set(deb822.Release(f)["Architectures"].split())
@@ -88,6 +144,10 @@ class MultiarchExtractor(DebExtractor):
def handle_control_member(self, name, content):
if name in ("preinst", "postinst", "prerm", "postrm"):
+ if b"dh_python3" in content:
+ generic_content = re.sub(b" -(p|L) python3-[a-z0-9+.-]+ ", b"", content)
+ if generic_content in PYTHON_MAINT_CONTENT:
+ return
self.result["hasscripts"] = True
def handle_control_end(self):