Exemple #1
0
    def register_package_header (self, package_hdr, branch_dict):
        if self.verbose:
            logging.info ('reading package header: %s\n'
                          % package_hdr.__repr__ ())

        str = open (package_hdr).read ()
        header_name = os.path.basename (package_hdr)
        d = dict (pickle.loads (str))
        name = d['basename']
        vc_branch = d.get ('vc_branch', '')

        if name in branch_dict:
            branch = branch_dict[name]
            if ':' in branch:
                (remote_branch, branch) = tuple (branch.split (':'))
            if branch != vc_branch:
                logging.error ('package of branch: %(vc_branch)s, expecting: %(branch)s\n' % locals ())
                logging.error ('ignoring header: %(header_name)s\n' % locals ())
                return
        elif d['vc_branch']:
            logging.error ('no branch for package: %(name)s\n' % locals ())
            logging.error ('ignoring header: %(header_name)s\n' % locals ())
            logging.error ('available branch: %(vc_branch)s\n' % locals ())
            return
        
        name = d['split_name']
        if 0:
          ## FIXME ?
          if name in self._package_dict_db:
              if str != self._package_dict_db[name]:
                  logging.info ("package header changed for %s\n" % name)

              return

        self.register_package_dict (d)
Exemple #2
0
 def dependencies (self, name):
     assert type (name) == str
     try:
         return [misc.strip_platform (x)
                 for x in self.dict_dependencies (self._packages[name])]
     except KeyError:
         logging.error ('no such package: %(name)s\n' % locals ())
         return list ()
Exemple #3
0
 def dependencies(self, name):
     assert type(name) == str
     try:
         return [
             misc.strip_platform(x)
             for x in self.dict_dependencies(self._packages[name])
         ]
     except KeyError:
         logging.error('no such package: %(name)s\n' % locals())
         return list()
Exemple #4
0
 def install_package (self, name):
     if self.is_installed (name):
         return
     logging.action ('installing package: %s\n' % name)
     if self.is_installed (name):
         message = 'already have package: ' + name + '\n'
         logging.error (message)
         raise Exception (message)
     d = self._packages[name]
     ball = '%(split_ball)s' % d
     self.install_tarball (ball, name, d['prefix_dir'])
     self._package_dict_db[name] = pickle.dumps (d, protocol=2)
Exemple #5
0
 def install_package(self, name):
     if self.is_installed(name):
         return
     logging.action('installing package: %s\n' % name)
     if self.is_installed(name):
         message = 'already have package: ' + name + '\n'
         logging.error(message)
         raise Exception(message)
     d = self._packages[name]
     ball = '%(split_ball)s' % d
     self.install_tarball(ball, name, d['prefix_dir'])
     self._package_dict_db[name] = pickle.dumps(d, protocol=2)
Exemple #6
0
    def install_tarball(self, ball, name, prefix_dir):
        logging.action('untarring: %(ball)s\n' % locals())

        _z = misc.compression_flag(ball)
        _v = ''  # self.os_interface.verbose_flag ()
        lst = loggedos.read_pipe(logging.default_logger,
                                 'tar -t%(_z)s -f "%(ball)s"' %
                                 locals()).split('\n')
        conflicts = False
        installed_files = self.installed_files()
        installed_files_string = ':'.join([''] + installed_files + [''])
        misc.timing()
        for f in lst:
            if (':' + f + ':' in installed_files_string
                    and not os.path.isdir(os.path.join(self.root, f))):
                package = self._file_package_db[f]
                logging.error('already have file %(f)s: %(package)s\n' %
                              locals())
                conflicts = True
        logging.command('GUP: for f in lst:' + misc.timing() + '\n')
        if conflicts and not self.is_distro:
            raise Exception('Duplicate files found.')
        root = self.root
        loggedos.system(
            logging.default_logger,
            # cd %(root)s to avoid open(2) of cwd, see
            # http://lists.gnu.org/archive/html/lilypond-devel/2009-03/msg00304.html
            'cd %(root)s && tar -C %(root)s -p -x%(_z)s%(_v)s -f %(ball)s' %
            locals())
        for f in lst:
            if f.endswith('.la'):
                self.libtool_la_fixup(root, f)
            if f.endswith('.pc'):
                self.pkgconfig_pc_fixup(root, f, prefix_dir)

        self._package_file_db[name] = '\n'.join(lst)
        for f in lst:
            # ignore directories.
            if not f.endswith('/'):
                self._file_package_db[f] = name

        if os.path.exists('%(root)s/usr/etc/postinstall/%(name)s' % locals()):
            loggedos.system(
                logging.default_logger,
                'PATH=%(root)s/usr/bin:$PATH %(root)s/usr/etc/postinstall/%(name)s && mv %(root)s/usr/etc/postinstall/%(name)s %(root)s/usr/etc/postinstall/%(name)s.done || :'
                % locals())
Exemple #7
0
    def build(self, options=None, skip=[]):
        available = dict(
            inspect.getmembers(self, lambda x: hasattr(x, '__call__')))
        stages = ['download'] + self.stages()
        tainted = False
        for stage in stages:
            if stage not in available or stage in skip:
                continue
            if self.is_done(stage):
                if stage not in ['download']:
                    # optimization: excuse download cache from
                    # tainting the build
                    tainted = True
                continue
            self.runner.stage(self.stage_message(stage))
            if (stage == 'package' and tainted and options
                    and not options.force_package):
                msg = self.expand(
                    '''This compile has previously been interrupted.
To ensure a repeatable build, this will not be packaged.

Run with

    --fresh # or issue
              rm %(stamp_file)s

to force a full package rebuild, or

    --force-package

to skip this check and risk a defective build.
''')
                logging.error(msg)
                self.system('false')
            try:
                (available[stage])()
            except:
                t, v, b = sys.exc_info()
                if t == misc.SystemFailed:
                    # A failed patch will leave system in unpredictable state.
                    if stage == 'patch':
                        self.system('rm %(stamp_file)s')
                raise
            if stage not in ['clean', 'download']:
                self.set_done(stage)
Exemple #8
0
    def build (self, options=None, skip=[]):
        available = dict (inspect.getmembers (self,
                                              lambda x: hasattr (x, '__call__')))
        stages = ['download'] + self.stages ()
        tainted = False
        for stage in stages:
            if stage not in available or stage in skip:
                continue
            if self.is_done (stage):
                if stage not in ['download']:
                    # optimization: excuse download cache from
                    # tainting the build
                    tainted = True
                continue
            self.runner.stage (self.stage_message (stage))
            if (stage == 'package' and tainted
                and options and not options.force_package):
                msg = self.expand ('''This compile has previously been interrupted.
To ensure a repeatable build, this will not be packaged.

Run with

    --fresh # or issue
              rm %(stamp_file)s

to force a full package rebuild, or

    --force-package

to skip this check and risk a defective build.
''')
                logging.error (msg)
                self.system ('false')
            try:
                (available[stage]) ()
            except:
                t, v, b = sys.exc_info ()
                if t == misc.SystemFailed:
                    # A failed patch will leave system in unpredictable state.
                    if stage == 'patch':
                        self.system ('rm %(stamp_file)s')
                raise
            if stage not in ['clean', 'download']:
                self.set_done (stage)
Exemple #9
0
    def install_tarball (self, ball, name, prefix_dir):
        logging.action ('untarring: %(ball)s\n' % locals ())

        _z = misc.compression_flag (ball)
        _v = '' # self.os_interface.verbose_flag ()
        lst = loggedos.read_pipe (logging.default_logger,
                                  'tar -t%(_z)s -f "%(ball)s"'
                                  % locals ()).split ('\n')
        conflicts = False
        installed_files = self.installed_files ()
        installed_files_string = ':'.join ([''] + installed_files + [''])
        misc.timing ()
        for f in lst:
            if (':' + f + ':' in installed_files_string
                and not os.path.isdir (os.path.join (self.root, f))):
                package = self._file_package_db[f]
                logging.error ('already have file %(f)s: %(package)s\n'
                               % locals ())
                conflicts = True
        logging.command ('GUP: for f in lst:' + misc.timing () + '\n')
        if conflicts and not self.is_distro:
            raise Exception ('Duplicate files found.')
        root = self.root
        loggedos.system (logging.default_logger,
                         # cd %(root)s to avoid open(2) of cwd, see
                         # http://lists.gnu.org/archive/html/lilypond-devel/2009-03/msg00304.html
                         'cd %(root)s && tar -C %(root)s -p -x%(_z)s%(_v)s -f %(ball)s'
                         % locals ())
        for f in lst:
            if f.endswith ('.la'):
                self.libtool_la_fixup (root, f)
            if f.endswith ('.pc'):
                self.pkgconfig_pc_fixup (root, f, prefix_dir)

        self._package_file_db[name] = '\n'.join (lst)
        for f in lst:
            # ignore directories.
            if not f.endswith ('/'):
                self._file_package_db[f] = name

        if os.path.exists ('%(root)s/usr/etc/postinstall/%(name)s' % locals ()):
            loggedos.system (logging.default_logger,
                             'PATH=%(root)s/usr/bin:$PATH %(root)s/usr/etc/postinstall/%(name)s && mv %(root)s/usr/etc/postinstall/%(name)s %(root)s/usr/etc/postinstall/%(name)s.done || :' % locals ())
Exemple #10
0
    def register_package_header(self, package_hdr, branch_dict):
        if self.verbose:
            logging.info('reading package header: %s\n' %
                         package_hdr.__repr__())

        str = open(package_hdr).read()
        header_name = os.path.basename(package_hdr)
        d = dict(pickle.loads(str))
        name = d['basename']
        vc_branch = d.get('vc_branch', '')

        if name in branch_dict:
            branch = branch_dict[name]
            if ':' in branch:
                (remote_branch, branch) = tuple(branch.split(':'))
            if branch != vc_branch:
                logging.error(
                    'package of branch: %(vc_branch)s, expecting: %(branch)s\n'
                    % locals())
                logging.error('ignoring header: %(header_name)s\n' % locals())
                return
        elif d['vc_branch']:
            logging.error('no branch for package: %(name)s\n' % locals())
            logging.error('ignoring header: %(header_name)s\n' % locals())
            logging.error('available branch: %(vc_branch)s\n' % locals())
            return

        name = d['split_name']
        if 0:
            ## FIXME ?
            if name in self._package_dict_db:
                if str != self._package_dict_db[name]:
                    logging.info("package header changed for %s\n" % name)

                return

        self.register_package_dict(d)