You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
5.4 KiB

  1. #-*- coding: utf-8 -*-
  2. # Copyright 2010-2013 Calculate Ltd. http://www.calculate-linux.org
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import sys
  16. from calculate.core.server.func import Action, Tasks
  17. from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
  18. from calculate.lib.utils.files import FilesError
  19. from calculate.update.update import UpdateError
  20. from calculate.update.package_tools import GitError
  21. setLocalTranslate('cl_update3', sys.modules[__name__])
  22. __ = getLazyLocalTranslate(_)
  23. class ClUpdateProfileAction(Action):
  24. """
  25. Действие обновление конфигурационных файлов
  26. """
  27. # ошибки, которые отображаются без подробностей
  28. native_error = (FilesError, UpdateError, GitError)
  29. successMessage = __("The profile was successfully updated")
  30. failedMessage = __("Failed to update the profile")
  31. interruptMessage = __("Profile update manually interrupted")
  32. # список задач для дейсвия
  33. tasks = [
  34. {'name': 'migrate_repository',
  35. 'method': 'Update.migrateCacheRepository('
  36. 'cl_update_profile_rep,cl_update_profile_branch)',
  37. 'message': __("Repository transfer"),
  38. 'condition': lambda Get: not (
  39. Get('cl_update_profile_storage').is_local(
  40. Get('cl_update_profile_rep'),
  41. Get('cl_update_profile_branch')))
  42. },
  43. {'name': 'reconfigure_vars',
  44. 'method': 'Update.reconfigureProfileVars()'
  45. },
  46. {'name': 'reps_synchronization',
  47. 'group': __("Repositories synchronization"),
  48. 'tasks': [
  49. {'name': 'sync_reps',
  50. 'foreach': 'cl_update_profile_sync_rep',
  51. 'message': __("Syncing the {eachvar:capitalize} repository"),
  52. 'method': 'Update.syncRepositories(eachvar)',
  53. #'condition': lambda Get: Get('cl_update_profile_sync_rep')
  54. },
  55. {'name': 'sync_reps:regen_cache',
  56. 'foreach': 'cl_update_sync_overlay_rep',
  57. 'message': __("Updating the {eachvar:capitalize} repository cache"),
  58. 'essential': False,
  59. 'method': 'Update.regenCache(eachvar)',
  60. 'condition': (
  61. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  62. Get('cl_update_metadata_force') != 'skip' or
  63. Get('cl_update_metadata_force') == 'force'))
  64. },
  65. {'name': 'emerge_metadata',
  66. 'message': __("Metadata transfer"),
  67. 'method': 'Update.emergeMetadata()',
  68. 'condition': (
  69. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  70. Get('cl_update_metadata_force') != 'skip' or
  71. Get('cl_update_metadata_force') == 'force'))
  72. },
  73. {'name': 'eix_update',
  74. 'message': __("Updating the eix cache"),
  75. 'method': 'Update.eixUpdate()',
  76. 'condition': (
  77. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  78. Get('cl_update_eixupdate_force') != 'skip' or
  79. Get('cl_update_eixupdate_force') == 'force'))
  80. },
  81. # сообщение удачного завершения при обновлении репозиториев
  82. {'name': 'success_syncrep',
  83. 'message': __("Synchronization finished"),
  84. 'depend': (Tasks.success() & Tasks.has_any("sync_reps",
  85. "sync_other_reps",
  86. "emerge_metadata",
  87. "eix_update")),
  88. }
  89. ]
  90. },
  91. {'name': 'reps_synchronization',
  92. 'group': __("Setting up the profile"),
  93. 'tasks': [
  94. {'name': 'set_profile',
  95. 'message': __("Switching to profile {cl_update_profile_system}"),
  96. 'method': 'Update.setProfile()'
  97. },
  98. {'name': 'revision',
  99. 'message': __("Fixing the settings"),
  100. 'method': 'Update.applyTemplates(install.cl_source,'
  101. 'cl_template_clt_set,True,None,False)',
  102. 'condition': lambda Get: Get('cl_templates_locate')
  103. },
  104. {'name': 'reconfigure',
  105. 'message': __("The system is being configured"),
  106. 'method': 'Update.applyProfileTemplates(cl_template_clt_set,True,False)',
  107. 'condition': lambda Get: Get('cl_update_templates_locate')
  108. },
  109. {'name': 'dispatch_conf',
  110. 'message': __("Updating configuration files"),
  111. 'method':'Update.dispatchConf()',
  112. 'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
  113. },
  114. ]
  115. }
  116. ]