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.

148 lines
6.5 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2010-2016 Mir Calculate. 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.cl_template import TemplatesError
  19. from calculate.lib.utils.binhosts import BinhostError
  20. from calculate.lib.utils.files import FilesError
  21. from calculate.update.update import UpdateError
  22. from calculate.lib.utils.git import GitError
  23. _ = lambda x: x
  24. setLocalTranslate('cl_update3', sys.modules[__name__])
  25. __ = getLazyLocalTranslate(_)
  26. class ClUpdateProfileAction(Action):
  27. """
  28. Действие обновление конфигурационных файлов
  29. """
  30. # ошибки, которые отображаются без подробностей
  31. native_error = (FilesError,
  32. TemplatesError, BinhostError,
  33. UpdateError, GitError)
  34. successMessage = __("The profile was successfully updated")
  35. failedMessage = __("Failed to update the profile")
  36. interruptMessage = __("Profile update manually interrupted")
  37. # список задач для действия
  38. tasks = [
  39. {'name': 'migrate_repository',
  40. 'method': 'Update.migrateCacheRepository('
  41. 'cl_update_profile_url,cl_update_profile_branch,'
  42. 'cl_update_profile_storage)',
  43. 'message': __("Repository transfer"),
  44. 'condition': lambda Get: not (
  45. Get('cl_update_profile_storage').is_local(
  46. Get('cl_update_profile_url'),
  47. Get('cl_update_profile_branch')))
  48. },
  49. {'name': 'reconfigure_vars1',
  50. 'method': 'Update.invalidateVariables("cl_update_profile_storage")',
  51. 'depend': Tasks.has('migrate_repository')
  52. },
  53. {'name': 'check_datavars',
  54. 'error': _("Profile not found in master"),
  55. 'condition': lambda Get: not Get('update.cl_update_profile_datavars')
  56. },
  57. {'name': 'drop_binhosts',
  58. 'method': 'Update.drop_binhosts(update.cl_update_profile_datavars)'
  59. },
  60. {'name': 'reconfigure_vars',
  61. 'method': 'Update.reconfigureProfileVars(cl_update_profile_datavars,'
  62. 'cl_chroot_path)'
  63. },
  64. {'name': 'reps_synchronization',
  65. 'group': __("Repositories synchronization"),
  66. 'tasks': [
  67. {'name': 'sync_reps',
  68. 'foreach': 'cl_update_profile_sync_rep',
  69. 'message': __("Syncing the {eachvar:capitalize} repository"),
  70. 'method': 'Update.syncRepositories(eachvar)',
  71. },
  72. {'name': 'sync_reps:regen_cache',
  73. 'foreach': 'cl_update_sync_overlay_rep',
  74. 'message': __("Updating the {eachvar:capitalize} repository cache"),
  75. 'essential': False,
  76. 'method': 'Update.regenCache(eachvar)',
  77. 'condition': (
  78. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  79. Get('cl_update_metadata_force') != 'skip' or
  80. Get('cl_update_metadata_force') == 'force'))
  81. },
  82. {'name': 'emerge_metadata',
  83. 'message': __("Metadata transfer"),
  84. 'method': 'Update.emergeMetadata()',
  85. 'condition': (
  86. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  87. Get('cl_update_metadata_force') != 'skip' or
  88. Get('cl_update_metadata_force') == 'force'))
  89. },
  90. {'name': 'eix_update',
  91. 'message': __("Updating the eix cache for "
  92. "{cl_update_eix_repositories}"),
  93. 'method': 'Update.eixUpdate(cl_repository_name)',
  94. 'condition': (
  95. lambda Get: (Get('cl_update_outdate_set') == 'on' and
  96. Get('cl_update_eixupdate_force') != 'skip' or
  97. Get('cl_update_eixupdate_force') == 'force'))
  98. },
  99. # сообщение удачного завершения при обновлении репозиториев
  100. {'name': 'success_syncrep',
  101. 'message': __("Synchronization finished"),
  102. 'depend': (Tasks.success() & Tasks.has_any("sync_reps",
  103. "sync_other_reps",
  104. "emerge_metadata",
  105. "eix_update")),
  106. }
  107. ]
  108. },
  109. {'name': 'reps_synchronization',
  110. 'group': __("Setting up the profile"),
  111. 'tasks': [
  112. {'name': 'set_profile',
  113. 'message': __("Switching to profile {cl_update_profile_system}"),
  114. 'method': 'Update.setProfile(cl_update_profile_system)'
  115. },
  116. {'name': 'rename_custom',
  117. 'method': 'Update.rename_custom_files()',
  118. },
  119. {'name': 'revision',
  120. 'message': __("Fixing the settings"),
  121. 'method': 'Update.applyProfileTemplates(cl_template_clt_set,'
  122. 'True,False,"update_profile")',
  123. 'condition': lambda Get: Get('cl_templates_locate')
  124. },
  125. {'name': 'reconfigure',
  126. 'message': __("The system is being configured"),
  127. 'method': 'Update.applyProfileTemplates(cl_template_clt_set,'
  128. 'True,False,"merge")',
  129. 'condition': lambda Get: (
  130. Get('cl_update_templates_locate') and
  131. Get('cl_update_skip_setup_set') == 'off')
  132. },
  133. {'name': 'dispatch_conf',
  134. 'message': __("Updating configuration files"),
  135. 'method': 'Update.dispatchConf()',
  136. 'condition': lambda Get: Get('cl_dispatch_conf') != 'skip'
  137. },
  138. ]
  139. }
  140. ]