Пример #1
0
def add_custom_headers_for_url(netloc, headers):
    """
    Looks up custom headers from rc files and adds to the supplied headers
    """
    custom_headers = Configuration.get(netloc, 'Headers')
    if custom_headers:
        header_parts = json.loads(custom_headers)
        for key in header_parts.keys():
            headers.update({key: header_parts[key]})
Пример #2
0
def add_custom_headers_for_url(netloc, headers):
    """
    Looks up custom headers from rc files and adds to the supplied headers
    """
    custom_headers = Configuration.get(netloc, 'Headers')
    if custom_headers:
        header_parts = json.loads(custom_headers)
        for key in header_parts.keys():
            headers.update({key: header_parts[key]})
Пример #3
0
def find_spec(package):
    """
    From a package name locate the spec file
    """
    spec_search = Configuration.get('spec', 'search-path',
                                    default='SPECS').split(':')
    for subdir in spec_search:
        path = Path(subdir, package+'.spec')
        if path.exists():
            return path
    return None
Пример #4
0
    def repomanager_from_netloc(self):
        """Get the repository manager for this host

        Allow repository manager for any given host name to be looked up
        from a section of the config file for a "server-type" value. If
        nothing is found, default to "bitbucket".

        Valid types are "github", "bitbucket" and "gitweb"
        """
        return Configuration.get(self.url.netloc,
                                 'server-type', 'bitbucket')
Пример #5
0
def find_spec(package):
    """
    From a package name locate the spec file
    """
    spec_search = Configuration.get('spec', 'search-path',
                                    default='SPECS').split(':')
    for subdir in spec_search:
        path = Path(subdir, package+'.spec')
        if path.exists():
            return path
    return None
Пример #6
0
def find_link_pin(package):
    """
    From a package name locate the link or pin file
    """
    pin_search = Configuration.get('pin', 'search-path',
                                   default='SPECS').split(':')
    for suffix in ('.pin', '.lnk'):
        for subdir in pin_search:
            path = Path(subdir, package+suffix)
            if path.exists():
                return path
    return None
Пример #7
0
def find_link_pin(package):
    """
    From a package name locate the link or pin file
    """
    pin_search = Configuration.get('pin', 'search-path',
                                   default='SPECS').split(':')
    for suffix in ('.pin', '.lnk'):
        for subdir in pin_search:
            path = Path(subdir, package+suffix)
            if path.exists():
                return path
    return None
Пример #8
0
    def __init__(self, path, check_package_name=True, defines=None):

        self.macros = dict(defines) if defines else {}
        self._sources = {}
        self._patches = {}
        self._archives = {}
        self._patchqueues = {}
        self._ignore_autosetup = False

        # _topdir defaults to $HOME/rpmbuild
        # If present, it needs to be applied once at the beginning
        if '_topdir' in self.macros:
            rpm.addMacro('_topdir', self.macros['_topdir'])

        # '%dist' in the host (where we build the source package)
        # might not match '%dist' in the chroot (where we build
        # the binary package).   We must override it on the host,
        # otherwise the names of packages in the dependencies won't
        # match the files actually produced by mock.
        if 'dist' not in self.macros:
            self.macros['dist'] = ""

        with rpm_macros(self.macros):
            self.path = path
            with open(path) as spec:
                self.spectext = spec.readlines()
            self.spec = parse_spec_quietly(path)

            if check_package_name:
                file_basename = os.path.basename(path).split(".")[0]
                spec_name = self.name()
                if isinstance(spec_name, bytes):
                    spec_name = spec_name.decode()
                if file_basename != spec_name:
                    raise SpecNameMismatch(
                        "spec file name '%s' does not match package name '%s'"
                        % (path, self.name()))

        for filepath, index, sourcetype in reversed(self.spec.sources):
            if filepath == os.path.basename(filepath):
                source_prefix = Configuration.get('spec',
                                                  'source-prefix',
                                                  default='SOURCES')
                filepath = os.path.join(source_prefix, filepath)
            blob = Blob(self, filepath, path)
            if sourcetype == 1:
                self.add_source(index, blob)
            elif sourcetype == 2:
                self.add_patch(index, blob)
Пример #9
0
    def __init__(self, path, check_package_name=True, defines=None):

        self.macros = dict(defines) if defines else {}
        self._sources = {}
        self._patches = {}
        self._archives = {}
        self._patchqueues = {}
        self._ignore_autosetup = False

        # _topdir defaults to $HOME/rpmbuild
        # If present, it needs to be applied once at the beginning
        if '_topdir' in self.macros:
            rpm.addMacro('_topdir', self.macros['_topdir'])

        # '%dist' in the host (where we build the source package)
        # might not match '%dist' in the chroot (where we build
        # the binary package).   We must override it on the host,
        # otherwise the names of packages in the dependencies won't
        # match the files actually produced by mock.
        if 'dist' not in self.macros:
            self.macros['dist'] = ""

        with rpm_macros(self.macros):
            self.path = path
            with open(path) as spec:
                self.spectext = spec.readlines()
            self.spec = parse_spec_quietly(path)

            if check_package_name:
                file_basename = os.path.basename(path).split(".")[0]
                spec_name = self.name()
                if isinstance(spec_name, bytes):
                    spec_name = spec_name.decode()
                if file_basename != spec_name:
                    raise SpecNameMismatch(
                        "spec file name '%s' does not match package name '%s'"
                        % (path, self.name()))

        for filepath, index, sourcetype in reversed(self.spec.sources):
            if filepath == os.path.basename(filepath):
                source_prefix = Configuration.get('spec', 'source-prefix',
                                                  default='SOURCES')
                filepath = os.path.join(source_prefix, filepath)
            blob = Blob(self, filepath, path)
            if sourcetype == 1:
                self.add_source(index, blob)
            elif sourcetype == 2:
                self.add_patch(index, blob)
Пример #10
0
 def test_defaults(self):
     """Options that are absent have default values"""
     self.assertEqual(Configuration.get('sectionA', 'gamma'), None)
     self.assertEqual(Configuration.get('sectionB', 'delta', 'jkl'), 'jkl')
Пример #11
0
 def test_exists(self):
     """Values for options present are returned"""
     self.assertEqual(Configuration.get('sectionA', 'alpha'), 'abc')
     self.assertEqual(Configuration.get('sectionB', 'alpha'), 'pqr')
Пример #12
0
 def test_defaults(self):
     """Options that are absent have default values"""
     self.assertEqual(Configuration.get('sectionA', 'gamma'), None)
     self.assertEqual(Configuration.get('sectionB', 'delta', 'jkl'), 'jkl')
Пример #13
0
 def test_exists(self):
     """Values for options present are returned"""
     self.assertEqual(Configuration.get('sectionA', 'alpha'), 'abc')
     self.assertEqual(Configuration.get('sectionB', 'alpha'), 'pqr')