void setupPackageRepo(packageRepoFixture *fixture, gconstpointer testData) {
    (void) testData;
    fixture->dnfContext = dnf_context_new();
    fixture->repos = g_ptr_array_sized_new(2);
    // First repo
    DnfRepo *repo1 = dnf_repo_new(fixture->dnfContext);
    dnf_repo_set_id(repo1, "foo-bar");
    g_ptr_array_add(fixture->repos, repo1);
    // Second repo
    DnfRepo *repo2 = dnf_repo_new(fixture->dnfContext);
    dnf_repo_set_id(repo2, "foo-bar-testing");
    g_ptr_array_add(fixture->repos, repo2);
    fixture->enabledRepoAndProductIds = g_ptr_array_sized_new(fixture->repos->len);
    fixture->activeRepoAndProductIds = g_ptr_array_sized_new(fixture->repos->len);
    fixture->rpmDbSack = dnf_sack_new();
    fixture->installedPackages = getInstalledPackages(fixture->rpmDbSack);
}
static int
sack_init(_SackObject *self, PyObject *args, PyObject *kwds)
{
    g_autoptr(GError) error = NULL;
    PyObject *custom_class = NULL;
    PyObject *custom_val = NULL;
    PycompString cachedir;
    const char *arch = NULL;
    const char *rootdir = NULL;
    PyObject *cachedir_py = NULL;
    PyObject *logfile_py = NULL;
    self->log_out = NULL;
    int make_cache_dir = 0;
    PyObject *debug_object = nullptr;
    gboolean all_arch = FALSE;
    const char *kwlist[] = {"cachedir", "arch", "rootdir", "pkgcls",
                      "pkginitval", "make_cache_dir", "logfile", "logdebug",
                      "all_arch", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OssOOiOO!i", (char**) kwlist,
                                     &cachedir_py, &arch, &rootdir,
                                     &custom_class, &custom_val,
                                     &make_cache_dir, &logfile_py,
                                     &PyBool_Type, &debug_object,
                                     &all_arch))
        return -1;

    bool debug = debug_object != nullptr && PyObject_IsTrue(debug_object);

    if (cachedir_py != NULL) {
        cachedir = PycompString(cachedir_py);
        if (!cachedir.getCString())
            return -1;
    }
    int flags = 0;
    if (make_cache_dir)
        flags |= DNF_SACK_SETUP_FLAG_MAKE_CACHE_DIR;
    self->sack = dnf_sack_new();
    if (all_arch) {
        dnf_sack_set_all_arch(self->sack, all_arch);
    } else {
        if (!dnf_sack_set_arch(self->sack, arch, &error)) {
            PyErr_SetString(HyExc_Arch, "Unrecognized arch for the sack.");
            return -1;
        }
    }
    dnf_sack_set_rootdir(self->sack, rootdir);
    dnf_sack_set_cachedir(self->sack, cachedir.getCString());
    if (logfile_py != NULL) {
        PycompString logfile(logfile_py);
        if (!logfile.getCString())
            return -1;
        if (!set_logfile(logfile.getCString(), self->log_out, debug)) {
            PyErr_Format(PyExc_IOError, "Failed to open log file: %s", logfile.getCString());
            return -1;
        }
    }
    if (!dnf_sack_setup(self->sack, flags, &error)) {
        switch (error->code) {
        case DNF_ERROR_FILE_INVALID:
            PyErr_SetString(PyExc_IOError,
                            "Failed creating working files for the Sack.");
            break;
        case DNF_ERROR_INVALID_ARCHITECTURE:
            PyErr_SetString(HyExc_Arch, "Unrecognized arch for the sack.");
            break;
        default:
            assert(0);
        }
        return -1;
    }

    if (custom_class && custom_class != Py_None) {
        if (!PyType_Check(custom_class)) {
            PyErr_SetString(PyExc_TypeError, "Expected a class object.");
            return -1;
        }
        Py_INCREF(custom_class);
        self->custom_package_class = custom_class;
    }
    if (custom_val && custom_val != Py_None) {
        Py_INCREF(custom_val);
        self->custom_package_val = custom_val;

    }
    return 0;
}
ModulePackageContainer::Impl::Impl() : persistor(new ModulePersistor), moduleSack(dnf_sack_new()) {}
void setupInstalledPackages(installedPackageFixture *fixture, gconstpointer testData) {
    (void)testData;
    fixture->rpmDbSack = dnf_sack_new();
}