-
Notifications
You must be signed in to change notification settings - Fork 24
/
after-patch.py
executable file
·45 lines (39 loc) · 1.41 KB
/
after-patch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2007 Progiciels Bourbeau-Pinard inc.
# François Pinard <pinard@iro.umontreal.ca>, 2008.
"""\
After "patch", "git clone" or "git checkout", file timestamps may be a
bit random, and unless you have all maintainer tools handy, it can put
you in some misery. This script makes all timestamps to be identical.
"""
__metaclass__ = type
import os, sys
class Main:
def main(self, *arguments):
# Decode arguments. Should be none!
import getopt
options, arguments = getopt.getopt(arguments, '')
for option, valeur in options:
pass
assert not arguments
# Use a reference file.
if not os.path.exists('configure.ac'):
sys.exit("You should first cd to the distribution directory.")
timestamp = os.path.getmtime('configure.ac')
# Walk all files, changing their timestamp.
stack = ['.']
while stack:
directory = stack.pop()
for base in os.listdir(directory):
if base == '.git':
continue
name = os.path.join(directory, base)
if os.path.isdir(name):
stack.append(name)
elif os.path.isfile(name):
os.utime(name, (os.path.getatime(name), timestamp))
run = Main()
main = run.main
if __name__ == '__main__':
main(*sys.argv[1:])