Ejemplo n.º 1
0
def main(argv=None):
    """
    Entry point
    """

    args = parse_args_or_exit(argv)

    tmpdir = tempfile.mkdtemp(prefix="px-mock-")
    config = clone_mock_config(args.configdir, tmpdir)

    try:
        if args.init:
            mock(args, config, "--init")

        else:
            config_in_path = os.path.join(args.configdir, args.root + ".cfg")
            config_out_path = os.path.join(config, args.root + ".cfg")
            insert_loopback_repo(
                config_in_path,
                config_out_path,
                tmpdir,
                args.loopback_config_extra)
            with rpm_macros(dict(args.define)):
                rpmdir = os.path.abspath(rpm.expandMacro("%_rpmdir"))
                createrepo(rpmdir, tmpdir, args.quiet)
            mock(args, config, "--rebuild", *args.srpms)

    except subprocess.CalledProcessError as cpe:
        sys.exit(cpe.returncode)

    finally:
        if args.keeptmp:
            print("Working directory retained at %s" % tmpdir)
        else:
            shutil.rmtree(tmpdir)
Ejemplo n.º 2
0
Archivo: mock.py Proyecto: srowe/planex
def main(argv=None):
    """
    Entry point
    """

    args = parse_args_or_exit(argv)

    tmpdir = tempfile.mkdtemp(prefix="px-mock-")
    config = clone_mock_config(args.configdir, tmpdir)

    try:
        if args.init:
            mock(args, config, "--init")

        else:
            config_in_path = os.path.join(args.configdir, args.root + ".cfg")
            config_out_path = os.path.join(config, args.root + ".cfg")
            insert_loopback_repo(
                config_in_path,
                config_out_path,
                tmpdir,
                args.loopback_config_extra)
            with rpm_macros(dict(args.define)):
                rpmdir = os.path.abspath(rpm.expandMacro("%_rpmdir"))
                createrepo(rpmdir, tmpdir, args.quiet)
            mock(args, config, "--rebuild", *args.srpms)

    except subprocess.CalledProcessError as cpe:
        sys.exit(cpe.returncode)

    finally:
        if args.keeptmp:
            print("Working directory retained at %s" % tmpdir)
        else:
            shutil.rmtree(tmpdir)
Ejemplo n.º 3
0
 def rpm_name_from_header(hdr):
     """
     Return the name of the binary package file which
     will be built from hdr
     """
     with rpm_macros(self.macros, nevra(hdr)):
         rpmname = hdr.sprintf(rpm.expandMacro("%{_build_name_fmt}"))
         return rpm.expandMacro(os.path.join('%_rpmdir', rpmname))
Ejemplo n.º 4
0
Archivo: spec.py Proyecto: srowe/planex
 def rpm_name_from_header(hdr):
     """
     Return the name of the binary package file which
     will be built from hdr
     """
     with rpm_macros(self.macros, nevra(hdr)):
         rpmname = hdr.sprintf(rpm.expandMacro("%{_build_name_fmt}"))
         return rpm.expandMacro(os.path.join('%_rpmdir', rpmname))
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
Archivo: spec.py Proyecto: srowe/planex
    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)
Ejemplo n.º 7
0
 def __init__(self, spec, url, defined_by, prefix, commitish):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(GitPatchqueue, self).__init__(spec, url, defined_by, prefix)
         self._prefix = rpm.expandMacro(prefix)
         self._commitish = rpm.expandMacro(commitish)
Ejemplo n.º 8
0
 def __init__(self, spec, url, defined_by):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         self._spec = spec
         self._url = rpm.expandMacro(url)
         self._defined_by = defined_by
Ejemplo n.º 9
0
 def __init__(self, spec, url, defined_by, prefix):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(Archive, self).__init__(spec, url, defined_by)
         self._prefix = rpm.expandMacro(prefix)
     self._names = None
Ejemplo n.º 10
0
 def __init__(self, spec, url, defined_by, prefix, commitish):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(GitBlob, self).__init__(spec, url, defined_by)
         self._prefix = rpm.expandMacro(prefix) if prefix is not None \
             else rpm.expandMacro("%{name}-%{version}")
         self._commitish = rpm.expandMacro(commitish)
Ejemplo n.º 11
0
 def __init__(self, spec, url, defined_by, prefix):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(Patchqueue, self).__init__(spec, url, defined_by, prefix)
     self._series = None
Ejemplo n.º 12
0
 def __init__(self, spec, url, defined_by, prefix, commitish):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(GitPatchqueue, self).__init__(spec, url, defined_by, prefix)
         self._prefix = rpm.expandMacro(prefix)
         self._commitish = rpm.expandMacro(commitish)
Ejemplo n.º 13
0
 def __init__(self, spec, url, defined_by, prefix):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(Patchqueue, self).__init__(spec, url, defined_by, prefix)
     self._series = None
Ejemplo n.º 14
0
 def __init__(self, spec, url, defined_by):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         self._spec = spec
         self._url = rpm.expandMacro(url)
         self._defined_by = defined_by
Ejemplo n.º 15
0
 def __init__(self, spec, url, defined_by, prefix):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(Archive, self).__init__(spec, url, defined_by)
         self._prefix = rpm.expandMacro(prefix)
     self._names = None
Ejemplo n.º 16
0
 def __init__(self, spec, url, defined_by, prefix, commitish):
     with rpm_macros(spec.macros, nevra(spec.spec.sourceHeader)):
         super(GitBlob, self).__init__(spec, url, defined_by)
         self._prefix = rpm.expandMacro(prefix) if prefix is not None \
             else rpm.expandMacro("%{name}-%{version}")
         self._commitish = rpm.expandMacro(commitish)