Docker container for the Unifi controller application
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/python3
  2. import fileinput
  3. import re
  4. import subprocess
  5. import sys
  6. from os import close, remove, path
  7. from shutil import move
  8. from tempfile import mkstemp
  9. assert path.isdir('.git'), "No git dir found"
  10. def replace(file_path, pattern, subst):
  11. # From http://stackoverflow.com/a/39110
  12. fh, abs_path = mkstemp()
  13. with open(abs_path, 'w') as new_file:
  14. with open(file_path) as old_file:
  15. for line in old_file:
  16. new_file.write(re.sub(pattern, subst, line))
  17. close(fh)
  18. remove(file_path)
  19. move(abs_path, file_path)
  20. def call(args):
  21. print('>>> %s' % ' '.join(args))
  22. return subprocess.call(args)
  23. call(['git', 'fetch'])
  24. updated = False
  25. for line in fileinput.input():
  26. branch, version, changelog, url = line.strip().split(' ')
  27. branch = 'master' if branch == 'latest' else branch
  28. call(['git', 'branch', branch, 'master']) # Will fail if the branch exists
  29. call(['git', 'checkout', branch])
  30. call(['git', 'reset', '--hard', 'origin/%s' % branch]) # May fail as well
  31. replace('Dockerfile', r'^ARG url=.*', 'ARG url=%s' % url)
  32. c = call(['git', 'commit', '-am', 'Auto update to version %s.\n\nChangelog: %s' % (version, changelog)])
  33. if c == 0:
  34. call(['git', 'push', 'origin', branch])
  35. updated = True
  36. call(['git', 'checkout', 'master'])
  37. sys.exit(0 if updated else 1)