package.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import shutil
  5. import subprocess
  6. def postInstall(fromVersion, fromRelease, toVersion, toRelease):
  7. # Migration 2008->2009
  8. # Use the timezone script to determine the timezone and write
  9. # it into /etc/timezone if it doesn't exist.
  10. # e.g. tz will be 'Europe/Istanbul'
  11. tz = os.popen("/usr/bin/timezone").read().strip()
  12. if tz == "Not found":
  13. if os.path.exists("/etc/timezone"):
  14. tz = open("/etc/timezone").read()
  15. else:
  16. tz = "Europe/Istanbul"
  17. # This file is used by CRDA to set regulatory domain for WLAN interfaces
  18. if tz and not os.path.exists("/etc/timezone"):
  19. open("/etc/timezone", "w").write("%s" % tz)
  20. # Don't use symlink for /etc/localtime. Replace existing
  21. # symlinks by the corresponding tz file using zic.
  22. if tz and os.path.exists(os.path.join("/usr/share/zoneinfo", tz)):
  23. ret = subprocess.call(["/usr/sbin/zic", "-l", tz])
  24. """
  25. if tz and os.path.islink("/etc/localtime"):
  26. tzfile = os.path.join("/usr/share/zoneinfo", tz)
  27. if os.path.exists(tzfile):
  28. try:
  29. os.unlink("/etc/localtime")
  30. shutil.copyfile(tzfile, "/etc/localtime")
  31. except:
  32. pass
  33. """