add refresh option to publish command (closes: #6727)

authorJulien Jehannet <julien.jehannet@logilab.fr>
changeset761daa65f314
branchdefault
phasepublic
hiddenno
parent revision#69801cc861d5 Added tag 2.1.0 for changeset ff83e7669ed0
child revision#6ae08ac00ee8 release 2.1.2
files modified by this revision
ldi.py
# HG changeset patch
# User Julien Jehannet <julien.jehannet@logilab.fr>
# Date 1227722791 -3600
# Wed Nov 26 19:06:31 2008 +0100
# Node ID 761daa65f314284eea3cbb9ddb430cf067892f5f
# Parent 69801cc861d5cd38cfdd17792b5cb7e874db769e
add refresh option to publish command (closes: #6727)

diff --git a/ldi.py b/ldi.py
@@ -155,11 +155,11 @@
1  class Upload(LdiCommand):
2      """upload a new package to the incoming queue of a repository"""
3      name = "upload"
4      min_args = 2
5      max_args = sys.maxint
6 -    arguments = "repository package.changes [...]"
7 +    arguments = "repository [-r | --remove] package.changes [...]"
8      opt_specs = [ ('-r', '--remove',
9                     {'dest': 'remove',
10                      'action': "store_true",
11                      'default': False,
12                      'help': 'remove debian changes file when uploading',
@@ -225,12 +225,18 @@
13  class Publish(Upload):
14      """process the incoming queue of a repository"""
15      name = "publish"
16      min_args = 1
17      max_args = sys.maxint
18 -    arguments = "repository [package.changes...]"
19 -    opt_specs = []
20 +    arguments = "repository [-r | --refresh] [package.changes...]"
21 +    opt_specs = [ ('-r', '--refresh',
22 +                   {'dest': 'refresh',
23 +                    'action': "store_true",
24 +                    'default': False,
25 +                    'help': 'refresh the repository index files'
26 +                   }),
27 +                ]
28 
29      def _get_incoming_changes(self):
30          repository = self.args[0]
31          changes = []
32          for changes_file in self.args[1:]:
@@ -273,33 +279,34 @@
33          workdir = osp.join(self.get_config_value('destination'),
34                             repository)
35          cwd = os.getcwd()
36          os.chdir(workdir)
37 
38 +        conf_base_dir = self.get_config_value('configurations')
39 +        aptconf = osp.join(conf_base_dir, '%s-apt.conf' % repository)
40 +        distsdir = osp.join(self.get_config_value('destination'),
41 +                            repository, 'dists')
42          try:
43              changes_files = self._get_incoming_changes()
44              for filename in changes_files:
45                  distrib = Changes(filename).changes['Distribution']
46 -                destdir = osp.join(self.get_config_value('destination'),
47 -                                   repository, 'dists', distrib)
48 +                destdir = osp.join(distsdir, distrib)
49                  self.logger.info('publishing packages to %s', destdir)
50                  self._check_signature(filename)
51                  self._run_checkers(filename)
52 
53                  all_files = self._get_all_package_files(filename)
54                  for one_file in all_files:
55                      sht.move(one_file, destdir, self.group, 0664)
56 
57 -                conf_base_dir = self.get_config_value('configurations')
58 -                aptconf = osp.join(conf_base_dir, '%s-apt.conf' % repository)
59 -                apt_ftparchive.clean(destdir)
60 -                # FIXME ajouter la section 'distrib'
61 -                self.logger.info('Running apt-ftparchive generate')
62 -                apt_ftparchive.generate(destdir, aptconf, self.group)
63 -                self.logger.info('Running apt-ftparchive release')
64 -                apt_ftparchive.release(destdir, aptconf, self.group, distrib)
65 -                self._sign_repo(destdir)
66 +                self._apt_refresh(distsdir, aptconf, distrib)
67 +            else:
68 +                self.logger.info('Nothing to process.')
69 +
70 +            if self.options.refresh:
71 +                self.logger.info('Force refreshing %s...' % repository)
72 +                self._apt_refresh(distsdir, aptconf)
73 
74          finally:
75              os.chdir(cwd)
76 
77      def _sign_repo(self, repository):
@@ -308,10 +315,19 @@
78          self.logger.info('Signing release')
79          apt_ftparchive.sign(repository,
80                              self.get_config_value('keyid'),
81                              self.group)
82 
83 +    def _apt_refresh(self, distsdir, aptconf, distrib="*"):
84 +        for destdir in glob.glob(osp.join(distsdir, distrib)):
85 +            apt_ftparchive.clean(destdir)
86 +            self.logger.info('Running apt-ftparchive generate')
87 +            apt_ftparchive.generate(destdir, aptconf, self.group)
88 +            self.logger.info('Running apt-ftparchive release')
89 +            apt_ftparchive.release(destdir, aptconf, self.group,
90 +                                   os.path.basename(destdir))
91 +            self._sign_repo(destdir)
92 
93  class Configure(LdiCommand):
94      """install the program by creating the correct directories with
95      the associated permissions"""
96      name = "configure"