Пример #1
0
 def testListProfiles_wms(self):
     xtarget = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     self.assertEqual(tuple(xtarget.list_profiles_ng('wms')),
                      (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(tuple(xtarget.list_profiles_ng('wms', filter=True)),
                      (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(tuple(xtarget.list_profiles_ng('wms', version=True)),
                      (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng('wms', version=True, filter=True)),
         (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(tuple(xtarget.list_profiles_ng('wms', multi=False)),
                      (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng('wms', filter=True, multi=False)),
         (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng('wms', version=True, multi=False)),
         (('base-targets/wms-1.3.15.0', True), ))
     self.assertEqual(
         tuple(
             xtarget.list_profiles_ng('wms',
                                      version=True,
                                      filter=True,
                                      multi=False)),
         (('base-targets/wms-1.3.15.0', True), ))
Пример #2
0
 def testSync(self):
     xtarget = b.XTargetBuilder(config=PATH + '/xtarget.cfg',
                                sync=True,
                                stdout=sys.stdout,
                                stderr=sys.stderr)
     xtarget.sync()
     self.assertEqual(
         os.system('diff -r --exclude=.git %s %s' %
                   (NEW_PORT_DIR, GIT_DIR)), 0)
Пример #3
0
 def testCreateTarget(self):
     targets = self.path + TMP_TARGETS
     self.assertEqual(os.listdir(targets), [])
     xt = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     try:
         xt.create('pouet')
         self.fail('An exception should have been raised')
     except b.XTargetError, e:
         if not str(e).startswith('Can\'t find any correct'):
             raise e
Пример #4
0
 def testSetTarget(self):
     os.makedirs(self.path + TMP_TARGETS + '/test_target')
     xt = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     try:
         # Try to set a target somewhere else than /usr/targets
         xt.set(self.path + TMP_TARGETS + '/test_target')
         self.assertEqual(xt.get_current(),
                          self.path + TMP_TARGETS + '/test_target')
     except b.XTargetError, e:
         self.fail(str(e))
Пример #5
0
 def testListProfiles_no_atom(self):
     xtarget = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     self.assertEqual(tuple(xtarget.list_profiles_ng()),
                      (('base-targets/test-prebuilt', True),
                       ('base-targets/wms', True),
                       ('base-targets/wms-sdk', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng(filter=True)),
                      (('base-targets/test-prebuilt', True),
                       ('base-targets/wms', True),
                       ('base-targets/wms-sdk', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng(version=True)),
                      (('base-targets/test-prebuilt-1.0', True),
                       ('base-targets/wms-1.3.15.0', True),
                       ('base-targets/wms-sdk-1.3.15.0', True),
                       ('base-targets/wms-sdk-1.3.15.1', True),
                       ('base-targets/wms-sdk-1.3.15.2', True),
                       ('base-targets/wms-sdk-1.3.15.3', True)))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng(version=True, filter=True)),
         (('base-targets/test-prebuilt-1.0', True),
          ('base-targets/wms-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.1', False),
          ('base-targets/wms-sdk-1.3.15.2', False),
          ('base-targets/wms-sdk-1.3.15.3', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng(multi=False)),
                      (('base-targets/test-prebuilt', True),
                       ('base-targets/wms', True),
                       ('base-targets/wms-sdk', True)))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng(filter=True, multi=False)),
         (('base-targets/test-prebuilt', True), ('base-targets/wms', True),
          ('base-targets/wms-sdk', True)))
     self.assertEqual(
         tuple(xtarget.list_profiles_ng(version=True, multi=False)),
         (('base-targets/test-prebuilt-1.0', True),
          ('base-targets/wms-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.1', True),
          ('base-targets/wms-sdk-1.3.15.2', True),
          ('base-targets/wms-sdk-1.3.15.3', True)))
     self.assertEqual(
         tuple(
             xtarget.list_profiles_ng(version=True,
                                      filter=True,
                                      multi=False)),
         (('base-targets/test-prebuilt-1.0', True),
          ('base-targets/wms-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.0', True),
          ('base-targets/wms-sdk-1.3.15.1', False),
          ('base-targets/wms-sdk-1.3.15.2', False),
          ('base-targets/wms-sdk-1.3.15.3', True)))
     del xtarget
Пример #6
0
 def testListProfilesWithOV(self):
     '''Using main repository + one additional from overlay config
                with one additional package.'''
     # Adding overlay config file to xtarget.cfg and populate it with values.
     self.assertEqual(
         os.system('echo ov_config = %s >> %s' %
                   (self.path + '/xtarget_ov.config',
                    self.path + '/xtarget.cfg')), 0)
     cfg = open(self.path + '/xtarget_ov.config', 'w')
     cfg.write('PORTDIR_OVERLAY="%s"\n' % (self.path + '/one'))
     cfg.write('PORTAGE_ONE_PROTO="git"\n')
     cfg.write('PORTAGE_ONE_URI="%s"\n' % self.path +
               '/git_one')  # it will not be used
     cfg.write('PORTAGE_ONE_BRANCH="master"\n')
     cfg.close()
     # Adding only one package base-targets/wms and one ebuild with '.8' at the end
     os.makedirs(self.path + '/one/base-targets/wms')
     self.assertEqual(
         os.system(
             'cp %s %s' %
             (self.path +
              '/ov_targets/base-targets/wms/wms-1.3.15.0.ebuild',
              self.path + '/one/base-targets/wms/wms-1.3.15.8.ebuild')), 0)
     self.assertEqual(
         os.system(
             'echo "EBUILD wms-1.3.15.8.ebuild '
             '1140 RMD160 f81bc8c550963f031e3b6b24fbe0559105a10d8e '
             'SHA1 fc3810880495bdaa69cbd12098ca43400719cd9c '
             'SHA256 54f9cc292e720e88ca6bc22a00d2142da48e38d00f107e9f5942a7be0ac01bd8" >> %s'
             % self.path + '/one/base-targets/wms/Manifest'), 0)
     xtarget = b.XTargetBuilder(config=self.path + '/xtarget.cfg',
                                sync=True,
                                stdout=sys.stdout,
                                stderr=sys.stderr)
     self.assertEqual(tuple(xtarget.list_profiles_ng('wms')),
                      (('base-targets/wms-1.3.15.0', True),
                       ('base-targets/wms-1.3.15.8', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng('>=wms-sdk-1.3.15.2')),
                      (('base-targets/wms-sdk-1.3.15.2', True),
                       ('base-targets/wms-sdk-1.3.15.3', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng()),
                      (('base-targets/test-prebuilt', True),
                       ('base-targets/wms', True),
                       ('base-targets/wms-sdk', True)))
     self.assertEqual(tuple(xtarget.list_profiles_ng(version=True)),
                      (('base-targets/test-prebuilt-1.0', True),
                       ('base-targets/wms-1.3.15.0', True),
                       ('base-targets/wms-1.3.15.8', True),
                       ('base-targets/wms-sdk-1.3.15.0', True),
                       ('base-targets/wms-sdk-1.3.15.1', True),
                       ('base-targets/wms-sdk-1.3.15.2', True),
                       ('base-targets/wms-sdk-1.3.15.3', True)))
Пример #7
0
 def test_bug5391(self):
     """#5391: xtarget uses the wrong prebuilt tar.gz packages"""
     name = "bug5931"
     tgt_path = self.path + TMP_TARGETS + '/%s/root' % name
     self.initEnv()
     self.__cleanTmpTargets()
     env_backup = os.environ.copy()
     os.environ['USE'] = 'prebuilt'
     xt = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     xt.create('=base-targets/test-prebuilt-1.0', 'mdboxa', dir=name)
     self.failUnless(os.path.exists(tgt_path + '/mdboxa'),
                     'mdboxa file is missing')
     xt.delete(name)
     xt.create('=base-targets/test-prebuilt-1.0', 'vmware', dir=name)
     self.failUnless(os.path.exists(tgt_path + '/vmware'),
                     'vmware file is missing')
     xt.delete(name)
     os.environ = env_backup.copy()
     shutil.rmtree(self.path + TMP_TARGETS)
Пример #8
0
 def testSyncWithOV(self):
     '''Syncing main repository + one additional from overlay config.'''
     # Adding overlay config file to xtarget.cfg and populate it with values.
     self.assertEqual(
         os.system('echo ov_config = %s >> %s' %
                   (PATH + '/xtarget_ov.config', PATH + '/xtarget.cfg')), 0)
     cfg = open(PATH + '/xtarget_ov.config', 'w')
     cfg.write('PORTDIR_OVERLAY="%s"\n' % (PATH + '/one'))
     cfg.write('PORTAGE_ONE_PROTO="git"\n')
     cfg.write('PORTAGE_ONE_URI="%s"\n' % GIT_DIR)
     cfg.write('PORTAGE_ONE_BRANCH="master"\n')
     cfg.close()
     xtarget = b.XTargetBuilder(config=PATH + '/xtarget.cfg',
                                sync=True,
                                stdout=sys.stdout,
                                stderr=sys.stderr)
     xtarget.sync()
     self.assertEqual(
         os.system('diff -r --exclude=.git %s %s' %
                   (NEW_PORT_DIR, GIT_DIR)), 0)
     self.assertEqual(
         os.system('diff -r --exclude=.git %s %s' %
                   (PATH + '/one', GIT_DIR)), 0)
Пример #9
0
 def testListTargets(self):
     xtarget = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
     xtarget.create('=base-targets/wms-1.3.15.0', 'mdboxa')
     xtarget.create('=base-targets/wms-sdk-1.3.15.0', 'mdboxa')
     self.assertEqual(
         xtarget.list_targets(),
         [('wms-1.3.15.0', 'base-targets/wms-1.3.15.0', 'mdboxa', {
             u'redist': u'1',
             u'prebuilt': u'0'
         }),
          ('wms-sdk-1.3.15.0', 'base-targets/wms-sdk-1.3.15.0', 'mdboxa', {
              'redist': '1',
              'prebuilt': '0'
          })])
     xtarget.delete('wms-1.3.15.0')
     self.assertEqual(
         xtarget.list_targets(),
         [('wms-sdk-1.3.15.0', 'base-targets/wms-sdk-1.3.15.0', 'mdboxa', {
             'redist': '1',
             'prebuilt': '0'
         })])
     xtarget.delete('wms-sdk-1.3.15.0')
     self.assertEqual(xtarget.list_targets(), [])
Пример #10
0
    def testListProfilesWithOV_wms_ambiguous(self):
        # Adding overlay config file to xtarget.cfg and populate it with values.
        self.assertEqual(
            os.system('echo ov_config = %s >> %s' %
                      (self.path + '/xtarget_ov.config',
                       self.path + '/xtarget.cfg')), 0)
        cfg = open(self.path + '/xtarget_ov.config', 'w')
        cfg.write('PORTDIR_OVERLAY="%s"\n' % (self.path + '/one'))
        cfg.write('PORTAGE_ONE_PROTO="git"\n')
        cfg.write('PORTAGE_ONE_URI="%s"\n' % self.path +
                  '/git_one')  # it will not be used
        cfg.write('PORTAGE_ONE_BRANCH="master"\n')
        cfg.close()
        # Adding only one package esab-targets/wms and one ebuild with '.8' at the end
        os.makedirs(self.path + '/one/esab-targets/wms')
        self.assertEqual(
            os.system(
                'cp %s %s' %
                (self.path +
                 '/ov_targets/base-targets/wms/wms-1.3.15.0.ebuild',
                 self.path + '/one/esab-targets/wms/wms-1.3.15.8.ebuild')), 0)
        self.assertEqual(
            os.system(
                'echo "EBUILD wms-1.3.15.8.ebuild '
                '1140 RMD160 f81bc8c550963f031e3b6b24fbe0559105a10d8e '
                'SHA1 fc3810880495bdaa69cbd12098ca43400719cd9c '
                'SHA256 54f9cc292e720e88ca6bc22a00d2142da48e38d00f107e9f5942a7be0ac01bd8" >> %s'
                % self.path + '/one/esab-targets/wms/Manifest'), 0)
        xtarget = b.XTargetBuilder(config=self.path + '/xtarget.cfg',
                                   sync=True,
                                   stdout=sys.stdout,
                                   stderr=sys.stderr)
        self.assertEqual(tuple(xtarget.list_profiles_ng('wms')),
                         (('base-targets/wms-1.3.15.0', True),
                          ('esab-targets/wms-1.3.15.8', True)))
        self.assertEqual(tuple(xtarget.list_profiles_ng('>=wms-sdk-1.3.15.2')),
                         (('base-targets/wms-sdk-1.3.15.2', True),
                          ('base-targets/wms-sdk-1.3.15.3', True)))
        self.assertEqual(tuple(xtarget.list_profiles_ng()),
                         (('base-targets/test-prebuilt', True),
                          ('base-targets/wms', True),
                          ('base-targets/wms-sdk', True),
                          ('esab-targets/wms', True)))
        self.assertEqual(tuple(xtarget.list_profiles_ng(version=True)),
                         (('base-targets/test-prebuilt-1.0', True),
                          ('base-targets/wms-1.3.15.0', True),
                          ('base-targets/wms-sdk-1.3.15.0', True),
                          ('base-targets/wms-sdk-1.3.15.1', True),
                          ('base-targets/wms-sdk-1.3.15.2', True),
                          ('base-targets/wms-sdk-1.3.15.3', True),
                          ('esab-targets/wms-1.3.15.8', True)))

        # XTargetError: The short target ebuild: wms is ambiguous.
        # Please specify one the following fully-qualified target ebuild instead:
        # base-targets/wms esab-targets/wms
        self.assertRaises(b.XTargetError, tuple,
                          xtarget.list_profiles_ng('wms', multi=False))

        self.assertEqual(
            tuple(xtarget.list_profiles_ng('>=wms-sdk-1.3.15.2', multi=False)),
            (('base-targets/wms-sdk-1.3.15.2', True),
             ('base-targets/wms-sdk-1.3.15.3', True)))
        self.assertEqual(tuple(xtarget.list_profiles_ng(multi=False)),
                         (('base-targets/test-prebuilt', True),
                          ('base-targets/wms', True),
                          ('base-targets/wms-sdk', True),
                          ('esab-targets/wms', True)))
        self.assertEqual(
            tuple(xtarget.list_profiles_ng(version=True, multi=False)),
            (('base-targets/test-prebuilt-1.0', True),
             ('base-targets/wms-1.3.15.0', True),
             ('base-targets/wms-sdk-1.3.15.0', True),
             ('base-targets/wms-sdk-1.3.15.1', True),
             ('base-targets/wms-sdk-1.3.15.2', True),
             ('base-targets/wms-sdk-1.3.15.3', True),
             ('esab-targets/wms-1.3.15.8', True)))
Пример #11
0
            self.fail('An exception should have been raised')
        except b.XTargetError, e:
            if not str(e).startswith('One of the following archit'):
                raise e

        self.assertEqual(os.listdir(targets), [])

        xt.create('wms', 'mdboxa')
        self.assertEqual(os.listdir(targets), ['wms-1.3.15.0'])
        xt.create('wms-sdk')
        self.assertEqual(set(os.listdir(targets)),
                         set(['wms-sdk-1.3.15.3', 'wms-1.3.15.0']))
        xt.create('=base-targets/wms-1.3.15.0', 'mdboxa')
        self.assertEqual(set(os.listdir(targets)),
                         set(['wms-sdk-1.3.15.3', 'wms-1.3.15.0']))
        xt = b.XTargetBuilder(arch='~mdboxa',
                              config=self.path + '/xtarget.cfg')
        xt.create('=base-targets/wms-sdk-1.3.15.2', '~mdboxa')
        self.assertEqual(
            set(os.listdir(targets)),
            set(['wms-sdk-1.3.15.3', 'wms-sdk-1.3.15.2', 'wms-1.3.15.0']))

    def testSetTarget(self):
        os.makedirs(self.path + TMP_TARGETS + '/test_target')
        xt = b.XTargetBuilder(config=self.path + '/xtarget.cfg')
        try:
            # Try to set a target somewhere else than /usr/targets
            xt.set(self.path + TMP_TARGETS + '/test_target')
            self.assertEqual(xt.get_current(),
                             self.path + TMP_TARGETS + '/test_target')
        except b.XTargetError, e:
            self.fail(str(e))