From: Ian Jackson Date: Thu, 22 Feb 2018 18:11:39 +0000 (+0000) Subject: debian/bin/genorig.py: Defuse `export-subst' X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~106 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2c91d2dea774545b941c054c2d7a5c91df36c8e5;p=xen.git debian/bin/genorig.py: Defuse `export-subst' The Xen upstream tree has .gitattributes which cause `git archive' to change things in .gitarchive-info. This is troublesome because it means that tarballs generated by genorig are not identical to the git trees. Work around this by temporarily creating a .gitattributes which disables export-subst. We move aside any existing .gitattributes, so that this works whether we are in a Debian packaging branch with upstream files in, or an upstream branch, or a bare-packaging branch. Signed-off-by: Ian Jackson --- diff --git a/debian/bin/genorig.py b/debian/bin/genorig.py index 5a0d435f69..8128a33ee1 100755 --- a/debian/bin/genorig.py +++ b/debian/bin/genorig.py @@ -57,9 +57,14 @@ class Main(object): except OSError: pass + ga_exists = os.path.exists('.gitattributes') try: + if ga_exists: + os.rename('.gitattributes','.gitattributes.genorig-saved') + with open('.gitattributes', 'w') as ga: + print('* -export-subst\n', file=ga) with open(out, 'wb') as f: - _cmd = ('git', 'archive', '--prefix', '%s/' % self.orig_dir, treeish) + _cmd = ('git', 'archive', '--worktree-attributes', '--prefix', '%s/' % self.orig_dir, treeish) p1 = subprocess.Popen(_cmd, stdout=subprocess.PIPE, cwd=self.repo) subprocess.check_call(('xz', ), stdin=p1.stdout, stdout=f) if p1.wait(): @@ -68,6 +73,13 @@ class Main(object): os.unlink(out) raise + try: + if ga_exists: + os.rename('.gitattributes.genorig-saved','.gitattributes') + else: + os.unlink('.gitattributes') + except Exception: pass + try: os.symlink(os.path.join('orig', self.orig_tar), os.path.join('..', self.orig_tar)) except OSError: