Example #1
0
    def __init__(self, argv, configuration):
        usage = '''%prog [global options] publish [options]

    Run command to publish package for the selected publication directory.'''
        parser = OptionParser(usage=usage)
        parser.add_option('--only-if-default',
                          dest='in_config',
                          action='store_true',
                          default=False,
                          help='only perform this step if it is a default '
                          'step, or specified in the "default_steps" option '
                          'of bv_maker.cfg config file. Default steps are '
                          'normally "sources" for source sections, '
                          '"configure build" for build sections.')
        parser.add_option(
            '-m',
            '--make_options',
            default=None,
            help='options passed to make (ex: "-j8") during test '
            'reference generation. '
            'Same as the configuration option make_options but '
            'specified at runtime. The commandline option here '
            'overrides the bv_maker.cfg options.')
        parser.add_option('--package-date',
                          dest='package_date',
                          default=None,
                          help='sets the date of the pack to install. '
                          'This is only useful if a %(date)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        parser.add_option('--package-time',
                          dest='package_time',
                          default=None,
                          help='sets the time of the pack to install. '
                          'This is only useful if a %(time)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        parser.add_option('--package-version',
                          dest='package_version',
                          default=None,
                          help='sets the version of the pack to install. '
                          'This is only useful if a %(version)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        (options, args) = parser.parse_args(argv)
        if args:
            raise ValueError('Invalid option: %s' % args[0])

        super(PublishPackCommand, self).__init__(argv, configuration)

        date = installer_format_date(installer_parse_date(options.package_date)) \
               if options.package_date else global_installer_datetime()['date']
        time = installer_format_time(installer_parse_time(options.package_time)) \
               if options.package_time else global_installer_datetime()['time']
        self.python_vars = {'date': date, 'time': time}
        if options.package_version:
            self.python_vars.update({'version': options.package_version})

        self.options = options
        self.args = args
Example #2
0
    def __init__(self, argv, configuration):
        usage = '''%prog [global options] pack [options]

    Make installer package for the selected build directory.'''
        parser = OptionParser(usage=usage)
        parser.add_option('--only-if-default',
                          dest='in_config',
                          action='store_true',
                          default=False,
                          help='only perform this step if it is a default '
                          'step, or specified in the "default_steps" option '
                          'of bv_maker.cfg config file. Default steps are '
                          'normally "sources" for source sections, '
                          '"configure build" for build sections.')
        (options, args) = parser.parse_args(argv)
        if args:
            raise ValueError('Invalid option: %s' % args[0])

        super(PackCommand, self).__init__(argv, configuration)
        self.python_vars = dict(global_installer_datetime())
        self.options = options
        self.args = args
Example #3
0
 def cleanup_package_dir(self):
     #directory = self.replace_vars(self.directory)
     directory = os.path.join(self.directory, self.package_repository_subdir)
     dirs = [directory, directory + '_tmp']
     pack_options = self.packaging_options
     if '--skip-repos' not in pack_options \
             and '--skip-existing' not in pack_options:
         for d in dirs:
             if os.path.isdir(d):
                 shutil.rmtree(d)
     if os.path.isdir(directory):
         report_file = os.path.join(directory, 'tests_report.txt')
         if os.path.exists(report_file):
             os.unlink(report_file)
     # erase older repositories
     if '%(date)s' in os.path.join(self._directory,
                                   self._package_repository_subdir):
         real_vars = dict(self.installer_variables())
         real_vars.update(global_installer_datetime())
         vars = dict(real_vars) # copy vars
         vars['date'] = '*'
         my_dir = environmentPathVariablesSubstitution(
             os.path.join(self._directory,
                          self._package_repository_subdir),
             env=self.get_environ()) % real_vars
         dir_pattern = environmentPathVariablesSubstitution(
             self._directory, env=self.get_environ()) % vars
         older_dirs = [d for d in glob.glob(dir_pattern) if d != my_dir]
         older_tmp_dirs = [d for d in glob.glob(dir_pattern + '_tmp')
                           if d != my_dir + '_tmp']
         # check in older repos if they were OK
         repos_to_remove = set()
         for d in older_dirs:
             report_file = os.path.join(d, 'tests_report.txt')
             if os.path.exists(report_file):
                 with open(report_file) as f:
                     report = f.readlines()
                 if report[-1].strip() != 'Tests_result: OK':
                     repos_to_remove.add(d)
                     print('removing older failed repos:', d)
         older_dirs = [d for d in older_dirs if d not in repos_to_remove]
         to_remove = set()
         for d in older_tmp_dirs:
             if not d[:-4] in older_dirs:
                 print('temp repos', d, 'has no real repos')
                 self.rm_with_empty_dirs_nofail(d)
                 to_remove.add(d)
         older_tmp_dirs = sorted([d for d in older_tmp_dirs
                                  if d not in to_remove])
         older_dirs = sorted(older_dirs)
         keep_n_older_repos = int(self.keep_n_older_repos)
         if len(older_dirs) > keep_n_older_repos:
             repos_to_remove.update(
                 older_dirs[:len(older_dirs) - keep_n_older_repos])
         # remove older repos and installs
         vars['date'] = '%(date)s' # keep date pattern as is
         pattern = environmentPathVariablesSubstitution(
             self._directory, env=self.get_environ()) % vars
         pattern = re.escape(pattern)
         # this replace restores the pattern '%(date)s' modified
         # by re.escape()
         pattern = pattern.replace(re.escape('%(date)s'), '%(date)s')
         pattern = re.compile(pattern % {'date': '(.+)'})
         for d in repos_to_remove:
             print('removing:', d)
             self.rm_with_empty_dirs_nofail(d)
             if d + '_tmp' in older_tmp_dirs:
                 print('removing:', d + '_tmp')
                 self.rm_with_empty_dirs_nofail(d + '_tmp')
             infos_file = os.path.join(os.path.dirname(d),
                                       'packages_infos.html')
             if os.path.exists(infos_file):
                 self.rm_with_empty_dirs_nofail(infos_file)
             m = pattern.match(d)
             r_date = m.group(1)
             vars['date'] = r_date
             # find associated installer
             if self.installer_filename:
                 installer = environmentPathVariablesSubstitution(
                     self._installer_filename,
                     env=self.get_environ()) % vars
                 if os.path.exists(installer):
                     print('removing:', installer)
                     self.rm_with_empty_dirs_nofail(installer)
                 if os.path.exists(installer + '.md5'):
                     self.rm_with_empty_dirs_nofail(installer + '.md5')
                 # check for lock file leaved after installer crash
                 lockfile = glob.glob(os.path.join(
                     os.path.dirname(installer), 'lock*.lock'))
                 for lock in lockfile:
                     self.rm_with_empty_dirs_nofail(lock)
                 # on Mac, remove .dmg files and .app directory
                 if sys.platform == 'darwin':
                     if os.path.exists(installer + '.dmg'):
                         self.rm_with_empty_dirs_nofail(installer + '.dmg')
                     if os.path.exists(installer + '.dmg.md5'):
                         self.rm_with_empty_dirs_nofail(
                             installer + '.dmg.md5')
                     if os.path.exists(installer + '.app'):
                         self.rm_with_empty_dirs_nofail(installer + '.app')
             # find associated install
             if self.test_install_dir:
                 install_dir = environmentPathVariablesSubstitution(
                     self._test_install_dir,
                     env=self.get_environ()) % vars
                 if os.path.exists(install_dir):
                     print('removing', install_dir)
                     self.rm_with_empty_dirs_nofail(install_dir)
                 # and tmp dir
                 tmp_dir = os.path.join(os.path.dirname(install_dir), 'tmp')
                 # remove it if empty
                 if os.path.isdir(tmp_dir) \
                         and len(os.listdir(tmp_dir)) == 0:
                     print('removing:', tmp_dir)
                     self.rm_with_empty_dirs_nofail(tmp_dir)
Example #4
0
    def __init__(self, argv, configuration):
        usage = '''%prog [global options] install_pack [options]

    Install a binary package for the selected build directory.'''
        parser = OptionParser(usage=usage)
        parser.add_option('--only-if-default',
                          dest='in_config',
                          action='store_true',
                          default=False,
                          help='only perform this step if it is a default '
                          'step, or specified in the "default_steps" option '
                          'of bv_maker.cfg config file. Default steps are '
                          'normally "sources" for source sections, '
                          '"configure build" for build sections.')
        parser.add_option('--package-date',
                          dest='package_date',
                          default=None,
                          help='sets the date of the pack to install. '
                          'This is only useful if a %(date)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        parser.add_option('--package-time',
                          dest='package_time',
                          default=None,
                          help='sets the time of the pack to install. '
                          'This is only useful if a %(time)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        parser.add_option('--package-version',
                          dest='package_version',
                          default=None,
                          help='sets the version of the pack to install. '
                          'This is only useful if a %(version)s pattern '
                          'has been used in the package directory sections '
                          'of bv_maker.cfg.')
        parser.add_option(
            '--prefix',
            dest='prefix',
            default=None,
            help='sets the prefix directory to install the pack.')
        parser.add_option('--local', dest='local',
                          action='store_true',
                          default=False,
                          help='True if the installation must be done ' \
                               'locally. Default is False.')
        parser.add_option('--offline', dest='offline',
                          action='store_true',
                          default=False,
                          help='True if the installation must be done using ' \
                               'offline installer. Default is False.')
        parser.add_option('--debug', dest='debug',
                          action='store_true',
                          default=False,
                          help='True if the installation must be done in debug ' \
                               'mode (i.e. generated files must not be deleted). ' \
                               'Default is False.')
        (options, args) = parser.parse_args(argv)
        if args:
            raise ValueError('Invalid option: %s' % args[0])

        super(InstallPackCommand, self).__init__(argv, configuration)

        date = installer_format_date(installer_parse_date(options.package_date)) \
               if options.package_date else global_installer_datetime()['date']
        time = installer_format_time(installer_parse_time(options.package_time)) \
               if options.package_time else global_installer_datetime()['time']
        self.python_vars = {'date': date, 'time': time}
        if options.package_version:
            self.python_vars.update({'version': options.package_version})

        self.options = options
        self.args = args