gentree-writable-outputs.patch (3405B)
1 --- /nix/store/swnksqfa53bv4c5n376zpw8zmzs47f4b-backports3/gentree.py 1970-01-01 01:00:01.000000000 +0100 2 +++ ./gentree.py 2020-09-18 21:55:30.100918501 +0100 3 @@ -2,6 +2,6 @@ 4 # 5 # Generate the output tree into a specified directory. 6 # 7 - 8 import argparse, sys, os, errno, shutil, re, subprocess 9 +import stat 10 import tarfile, gzip, time 11 @@ -127,6 +127,10 @@ 12 if e.errno != errno.ENOENT: 13 raise 14 15 +def makeWritable(filename): 16 + os.chmod(filename, 17 + os.stat(filename).st_mode | 0700) 18 + 19 20 def copytree(src, dst, symlinks=False, ignore=None): 21 """ 22 @@ -141,6 +145,7 @@ 23 24 if not os.path.isdir(dst): 25 os.makedirs(dst) 26 + makeWritable(dst) 27 errors = [] 28 for name in names: 29 if name in ignored_names: 30 @@ -154,7 +161,8 @@ 31 elif os.path.isdir(srcname): 32 copytree(srcname, dstname, symlinks, ignore) 33 else: 34 - shutil.copy2(srcname, dstname) 35 + shutil.copy(srcname, dstname) 36 + makeWritable(dstname) 37 except (IOError, os.error) as why: 38 errors.append((srcname, dstname, str(why))) 39 # catch the Error from the recursive copytree so that we can 40 @@ -163,6 +172,7 @@ 41 errors.extend(err.args[0]) 42 try: 43 shutil.copystat(src, dst) 44 + makeWritable(dst) 45 except WindowsError: 46 # can't copy file access times on Windows 47 pass 48 @@ -187,6 +197,7 @@ 49 for srcitem, tgtitem in copy_list: 50 if tgtitem == '': 51 copytree(srcpath, outdir, ignore=shutil.ignore_patterns('*~')) 52 + makeWritable(outdir) 53 elif tgtitem[-1] == '/': 54 def copy_ignore(dir, entries): 55 r = [] 56 @@ -199,14 +210,17 @@ 57 ignore=copy_ignore) 58 else: 59 try: 60 - os.makedirs(os.path.join(outdir, os.path.dirname(tgtitem))) 61 + n = os.path.join(outdir, os.path.dirname(tgtitem)) 62 + os.makedirs(n, 0755) 63 + makeWritable(n) 64 except OSError as e: 65 # ignore dirs we might have created just now 66 if e.errno != errno.EEXIST: 67 raise 68 - shutil.copy(os.path.join(srcpath, srcitem), 69 - os.path.join(outdir, tgtitem)) 70 - 71 + outpath = os.path.join(outdir, tgtitem) 72 + if os.path.exists(outpath): os.remove(outpath) 73 + shutil.copy(os.path.join(srcpath, srcitem), outpath) 74 + makeWritable(outpath) 75 76 def copy_git_files(srcpath, copy_list, rev, outdir): 77 """ 78 @@ -886,7 +904,10 @@ 79 git_debug_snapshot(args, 'Add driver sources') 80 81 disable_list = add_automatic_backports(args) 82 - if git_tracked_version: 83 + if os.environ['BACKPORTS_VERSION']: 84 + backports_version = os.environ['BACKPORTS_VERSION'] 85 + kernel_version = os.environ['KERNEL_VERSION'] 86 + elif git_tracked_version: 87 backports_version = "(see git)" 88 kernel_version = "(see git)" 89 else: 90 @@ -1037,6 +1030,7 @@ def process(kerneldir, copy_list_file, git_revision=None, 91 break 92 if copy_defconfig: 93 shutil.copy(dfsrc, os.path.join(bpid.target_dir, 'defconfigs', dfbase)) 94 + makeWritable(os.path.join(bpid.target_dir, 'defconfigs', dfbase)) 95 96 git_debug_snapshot(args, "add (useful) defconfig files") 97