On Mon, 19 Feb 2018 at 17:13:16 +0700, Matthias Klose wrote:
> I don't like the patch because it looks up things for removal which are
> outside
> the package. I'll update it to only remove what is shipped in the package.
In case you haven't had a chance to do that yet, here's a patch that
you might prefer.
Regards,
smcv
>From 276fad80baf4094f318b2d2a96145ae2518df9bf Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Wed, 14 Feb 2018 11:30:12 +0000
Subject: [PATCH] Clean up empty __pycache__ directories in prerm
Closes: #886124
---
debian/changelog | 7 +++++++
debian/python3-distutils.prerm | 8 ++++++++
debian/python3-lib2to3.prerm | 8 ++++++++
debian/python3-tk.prerm | 8 ++++++++
4 files changed, 31 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index b7635f8..5813a94 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python3-stdlib-extensions (3.6.4-4.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Clean up empty __pycache__ directories in prerm (Closes: #886124)
+
+ -- Simon McVittie <[email protected]> Mon, 26 Feb 2018 09:16:07 +0000
+
python3-stdlib-extensions (3.6.4-4) unstable; urgency=medium
* Update to 20180212 from the 3.6 branch.
diff --git a/debian/python3-distutils.prerm b/debian/python3-distutils.prerm
index bdc8320..0d2691a 100644
--- a/debian/python3-distutils.prerm
+++ b/debian/python3-distutils.prerm
@@ -10,6 +10,14 @@ remove_bytecode()
| awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \
| xargs --max-chars="$max" echo \
| while read files; do rm -f $files; done
+ dpkg -L "$pkg" \
+ | sed -ne 's,^\(/.*/\)[^/]*\.py$,\1__pycache__,p' \
+ | sort -u \
+ | while read dir; do \
+ if [ -d "$dir" ]; then \
+ rmdir --ignore-fail-on-non-empty "$dir"; \
+ fi; \
+ done
}
case "$1" in
diff --git a/debian/python3-lib2to3.prerm b/debian/python3-lib2to3.prerm
index a70657c..30bb55b 100644
--- a/debian/python3-lib2to3.prerm
+++ b/debian/python3-lib2to3.prerm
@@ -10,6 +10,14 @@ remove_bytecode()
| awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \
| xargs --max-chars="$max" echo \
| while read files; do rm -f $files; done
+ dpkg -L "$pkg" \
+ | sed -ne 's,^\(/.*/\)[^/]*\.py$,\1__pycache__,p' \
+ | sort -u \
+ | while read dir; do \
+ if [ -d "$dir" ]; then \
+ rmdir --ignore-fail-on-non-empty "$dir"; \
+ fi; \
+ done
}
case "$1" in
diff --git a/debian/python3-tk.prerm b/debian/python3-tk.prerm
index 92ae334..0960289 100644
--- a/debian/python3-tk.prerm
+++ b/debian/python3-tk.prerm
@@ -10,6 +10,14 @@ remove_bytecode()
| awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \
| xargs --max-chars="$max" echo \
| while read files; do rm -f $files; done
+ dpkg -L "$pkg" \
+ | sed -ne 's,^\(/.*/\)[^/]*\.py$,\1__pycache__,p' \
+ | sort -u \
+ | while read dir; do \
+ if [ -d "$dir" ]; then \
+ rmdir --ignore-fail-on-non-empty "$dir"; \
+ fi; \
+ done
}
case "$1" in
--
2.16.2