Exemplo n.º 1
0
int rpmtsRebuildDB(rpmts ts)
{
    int rc = -1;
    rpmlock lock = NULL;

    /* Cannot do this on a populated transaction set */
    if (rpmtsNElements(ts) > 0)
	return -1;

    lock = rpmtsAcquireLock(ts);
    if (lock) {
	if (!(ts->vsflags & RPMVSF_NOHDRCHK))
	    rc = rpmdbRebuild(ts->rootDir, ts, headerCheck);
	else
	    rc = rpmdbRebuild(ts->rootDir, NULL, NULL);
	rpmlockFree(lock);
    }
    return rc;
}
Exemplo n.º 2
0
int rpmtsRebuildDB(rpmts ts)
{
    int rc = -1;
    rpmtxn txn = NULL;

    /* Cannot do this on a populated transaction set */
    if (rpmtsNElements(ts) > 0)
	return -1;

    txn = rpmtxnBegin(ts, RPMTXN_WRITE);
    if (txn) {
	if (!(ts->vsflags & RPMVSF_NOHDRCHK))
	    rc = rpmdbRebuild(ts->rootDir, ts, headerCheck);
	else
	    rc = rpmdbRebuild(ts->rootDir, NULL, NULL);
	rpmtxnEnd(txn);
    }
    return rc;
}
Exemplo n.º 3
0
/*
 * Rebuild the package database
 * It should reside in +root+ / var / lib /rpm
 * @param [String] root Root path of the database
 */
static VALUE
db_s_rebuild(int argc, VALUE* argv, VALUE obj)
{
	const char* root = "";
	int ret;

	switch (argc) {
	case 0:
		break;

	case 1:
		if (!NIL_P(argv[0])) {
			if (TYPE(argv[0]) != T_STRING) {
				rb_raise(rb_eTypeError, "illegal argument type");
			}
			root = RSTRING_PTR(argv[0]);
		}
		break;

	default:
		rb_raise(rb_eArgError, "too many arguments(0..1)");
		break;
	}

#if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
	ret = rpmdbRebuild(root);
#elif RPM_VERSION_CODE < RPM_VERSION(5,0,0)
	ret = rpmdbRebuild(root, NULL, NULL);
#else
	ret = rpmdbRebuild(root, NULL);
#endif
	if (ret) {
		rb_raise(rb_eRuntimeError, "can not rebuild database in %s",
				 RSTRING_PTR(rb_str_concat(rb_str_new2(root),
									   rb_str_new2("/var/lib/rpm"))));
	}

	return Qnil;
}