From 8a08f87d43995f1f66cf08fab664f94974bccfcb Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 2 Jun 2021 08:32:39 +0200 Subject: [PATCH] copr-dist-git: fix failing Thunderbird import Fixes: https://pagure.io/copr/copr/issue/1700 --- .../files/patches/git-python-pr-1254.patch | 44 +++++++++++++++++++ roles/copr/dist_git/tasks/main.yml | 5 +++ 2 files changed, 49 insertions(+) create mode 100644 roles/copr/dist_git/files/patches/git-python-pr-1254.patch diff --git a/roles/copr/dist_git/files/patches/git-python-pr-1254.patch b/roles/copr/dist_git/files/patches/git-python-pr-1254.patch new file mode 100644 index 0000000000..d65b90ca7f --- /dev/null +++ b/roles/copr/dist_git/files/patches/git-python-pr-1254.patch @@ -0,0 +1,44 @@ +commit 1a04c15b1f77f908b1dd3983a27ee49c41b3a3e5 +Author: Todd Zullinger +AuthorDate: Mon May 24 17:34:42 2021 -0400 +Commit: Todd Zullinger +CommitDate: Tue May 25 11:42:07 2021 -0400 + + improve index mode for files with executable bit + + The fix for #430 in bebc4f56 (Use correct mode for executable files, + 2016-05-19) is incomplete. It fails (in most cases) when files have + modes which are not exactly 0644 or 0755. + + Git only cares whether the executable bit is set (or not). Ensure the + mode we set for the index is either 100644 or 100755 based on whether + the executable bit is set for the file owner. Do this similarly to how + upstream git does it in cache.h¹. + + Add a test covering various file modes to help catch regressions. + + Fixes #1253 + + ¹ https://github.com/git/git/blob/v2.31.1/cache.h#L247 + +diff --git a/git/index/fun.py b/git/index/fun.py +index f40928c3..1012f480 100644 +--- a/git/index/fun.py ++++ b/git/index/fun.py +@@ -11,6 +11,7 @@ from stat import ( + S_ISDIR, + S_IFMT, + S_IFREG, ++ S_IXUSR, + ) + import subprocess + +@@ -115,7 +116,7 @@ def stat_mode_to_index_mode(mode): + return S_IFLNK + if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules + return S_IFGITLINK +- return S_IFREG | 0o644 | (mode & 0o111) # blobs with or without executable bit ++ return S_IFREG | (mode & S_IXUSR and 0o755 or 0o644) # blobs with or without executable bit + + + def write_cache(entries: Sequence[Union[BaseIndexEntry, 'IndexEntry']], stream: IO[bytes], diff --git a/roles/copr/dist_git/tasks/main.yml b/roles/copr/dist_git/tasks/main.yml index 216e5334a0..03f7fab7dd 100644 --- a/roles/copr/dist_git/tasks/main.yml +++ b/roles/copr/dist_git/tasks/main.yml @@ -28,6 +28,11 @@ - dist-git-selinux - copr-dist-git +- name: Patch GitPython to import Thunderbird (issue 1700) + patch: src=patches/prunerepo-dataloss.patch + dest=/usr/lib/python3.9/site-packages/git/index/fun.py + tags: patches + - name: switch selinux to enforcing selinux: policy=targeted state=enforcing