poldek: poldek/configure.in, poldek/pm/rpm/install.c, poldek/pm/rp...
mis
mis at pld-linux.org
Sun Dec 17 23:37:10 CET 2006
Author: mis Date: Sun Dec 17 22:37:10 2006 GMT
Module: poldek Tag: HEAD
---- Log message:
- support for rpm 4.4.7 (needs testing)
- code cleanups
---- Files affected:
poldek/poldek:
configure.in (1.125 -> 1.126)
poldek/poldek/pm/rpm:
install.c (1.5 -> 1.6) , misc.c (1.7 -> 1.8) , pm_rpm.h (1.14 -> 1.15) , rpm.c (1.15 -> 1.16) , rpminstall.c (1.18 -> 1.19) , rpmvercmp.c (1.1 -> 1.2)
poldek/poldek/pm:
pm.h (1.16 -> 1.17)
---- Diffs:
================================================================
Index: poldek/poldek/configure.in
diff -u poldek/poldek/configure.in:1.125 poldek/poldek/configure.in:1.126
--- poldek/poldek/configure.in:1.125 Mon Aug 21 13:20:12 2006
+++ poldek/poldek/configure.in Sun Dec 17 23:37:05 2006
@@ -273,7 +273,6 @@
[$DBLIB -lrpmdb]),
[$DBLIB])
-AC_CHECK_FUNCS(rpmMachineScore,,[ AC_MSG_ERROR(["rpmlib not found"])])
AC_CHECK_FUNCS(rpmlog rpmCheckSig rpmVerifySignature)
dnl rpm 4.2?
@@ -297,11 +296,18 @@
[ AC_CHECK_FUNCS(rpmGetRpmlibProvides,,
[AC_MSG_WARN(["poldek will not work fine with rpmlib\(...\) capabilities"])],
[$CONF_IN_LDFLAGS])], [$CONF_IN_LDFLAGS])
-
+dnl rpm 4.4.6
AC_CHECK_FUNCS(rpmdsUname)
AC_CHECK_FUNCS(rpmdsSysinfo)
AC_CHECK_FUNCS(rpmdsGetconf)
AC_CHECK_FUNCS(rpmdsCpuinfo)
+
+dnl rpm 4.4.7
+dnl - killed rpmMachineScore and rpmGetVar
+AC_CHECK_FUNCS(rpmMachineScore)
+AC_CHECK_FUNCS(rpmGetVar)
+dnl - new _rpmvercmp()
+AC_CHECK_FUNCS(_rpmvercmp)
================================================================
Index: poldek/poldek/pm/rpm/install.c
diff -u poldek/poldek/pm/rpm/install.c:1.5 poldek/poldek/pm/rpm/install.c:1.6
--- poldek/poldek/pm/rpm/install.c:1.5 Tue Aug 22 17:05:40 2006
+++ poldek/poldek/pm/rpm/install.c Sun Dec 17 23:37:05 2006
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2000 - 2002 Pawel A. Gajda <mis at k2.net.pl>
+ Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2 as
@@ -87,6 +87,7 @@
}
#ifdef HAVE_RPM_4_1
+
static void *install_cb(const void *h __attribute__((unused)),
const rpmCallbackType op,
const unsigned long amount,
@@ -96,9 +97,12 @@
{
void *r = NULL;
static FD_t fd = NULL;
-
+
switch (op) {
case RPMCALLBACK_INST_OPEN_FILE:
+ if (pkgpath == NULL || *(char*)pkgpath == '\0')
+ return NULL;
+
fd = Fopen(pkgpath, "r.ufdio");
if (fd == NULL || Ferror(fd)) {
logn(LOGERR, "%s: %s", (const char*)pkgpath, Fstrerror(fd));
@@ -126,7 +130,6 @@
break;
case RPMCALLBACK_INST_START:
- msgn(0, _("Installing %s"), n_basenam(pkgpath));
progress(amount, total);
break;
@@ -160,7 +163,6 @@
break;
case RPMCALLBACK_INST_START:
- msgn(0, _("Installing %s"), n_basenam(pkgpath));
progress(amount, total);
break;
@@ -306,16 +308,22 @@
goto l_err;
}
}
-
+
+ msgn(0, _("Installing %s..."), n_basenam(path));
#ifdef HAVE_RPM_4_1
rpmtsSetFlags(ts, transflags);
+# ifdef HAVE_RPMDSUNAME /* seems rpm >= 4.4.6 rely on rpmShowProgress(!?) */
+ rpmtsSetNotifyCallback(ts, rpmShowProgress, NULL);
+# else
rpmtsSetNotifyCallback(ts, install_cb, NULL);
+# endif /* HAVE_RPMDSUNAME (since rpm 4.4.6) */
+
rc = rpmtsRun(ts, NULL, (rpmprobFilterFlags) filterflags);
-#else
+#else /* rpm < 4.1 */
rc = rpmRunTransactions(ts, install_cb,
(void *) ((long)instflags),
NULL, &probs, transflags, filterflags);
-#endif
+#endif /* HAVE_RPM_4_1 */
if (rc != 0) {
if (rc > 0) {
@@ -330,7 +338,7 @@
goto l_err;
} else {
- logn(LOGERR, _("%s: installation failed (hgw why)"), path);
+ logn(LOGERR, _("%s: installation failed (retcode=%d)"), path, rc);
}
}
================================================================
Index: poldek/poldek/pm/rpm/misc.c
diff -u poldek/poldek/pm/rpm/misc.c:1.7 poldek/poldek/pm/rpm/misc.c:1.8
--- poldek/poldek/pm/rpm/misc.c:1.7 Sun Jul 9 23:24:56 2006
+++ poldek/poldek/pm/rpm/misc.c Sun Dec 17 23:37:05 2006
@@ -35,6 +35,7 @@
#include "misc.h"
#include "log.h"
#include "pm/pm.h"
+#include "pm_rpm.h"
#if HAVE_RPMDSRPMLIB /* rpmdsRpmlib() => rpm >= 4.4.3 */
@@ -137,11 +138,12 @@
}
#endif
-tn_array *pm_rpm_rpmlib_caps(void)
+tn_array *pm_rpm_rpmlib_caps(void *pm_rpm)
{
tn_array *caps;
int rc = 0;
-
+
+ pm_rpm = pm_rpm;
caps = capreq_arr_new(0);
#if HAVE_RPMDSRPMLIB /* rpm >= 4.4.3 */
@@ -162,18 +164,11 @@
return caps;
}
-
-const char *pm_rpm_get_arch(void *pm_rpm)
+#ifdef HAVE_RPMMACHINESCORE
+static int machine_score(int tag, const char *val)
{
- pm_rpm = pm_rpm;
- return rpmGetVar(RPM_MACHTABLE_INSTARCH);
-}
-
-int pm_rpm_machine_score(void *pm_rpm, int tag, const char *val)
-{
- int rpmtag = 0;
+ int rpmtag = 0, rc;
- pm_rpm = pm_rpm;
switch (tag) {
case PMMSTAG_ARCH:
rpmtag = RPM_MACHTABLE_INSTARCH;
@@ -187,16 +182,71 @@
n_assert(0);
break;
}
-
+
+ n_assert(rpmtag);
return rpmMachineScore(rpmtag, val);
}
+#else /* killed rpmMachineScore() (since 4.4.7) */
+static int machine_score(int tag, const char *val)
+{
+ int rc = 0;
+
+ switch (tag) {
+ case PMMSTAG_ARCH:
+ rc = pm_rpm_arch_score(val);
+ break;
+
+ case PMMSTAG_OS: {
+ char *host_val = rpmExpand("%{_host_os}", NULL);
+ rc = 9;
+ if (host_val) {
+ if (strcasecmp(host_val, val) == 0)
+ rc = 1; /* exact fit */
+ free(host_val);
+ }
+ break;
+ default:
+ n_assert(0);
+ break;
+ }
+ }
+ return rc;
+}
+#endif /* HAVE_RPMMACHINESCORE */
+
+int pm_rpm_machine_score(void *pm_rpm, int tag, const char *val)
+{
+ pm_rpm = pm_rpm;
+ return machine_score(tag, val);
+}
+
+/* XXX: function used directly in pkg.c */
int pm_rpm_arch_score(const char *arch)
{
+ char *host_arch;
+ int rc;
+
if (arch == NULL)
return 0;
- return rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch);
-}
+#ifdef HAVE_RPMMACHINESCORE
+ rc = rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch);
+#else
+ rc = 9;
+ if (strcasecmp(arch, "noarch") == 0) {
+ rc = 1;
+
+ } else {
+ host_arch = rpmExpand("%{_host_cpu}", NULL);
+ if (host_arch) {
+ if (strcasecmp(host_arch, arch) == 0)
+ rc = 1; /* exact fit */
+ free(host_arch);
+ }
+ }
+ return rc;
+}
+#endif
================================================================
Index: poldek/poldek/pm/rpm/pm_rpm.h
diff -u poldek/poldek/pm/rpm/pm_rpm.h:1.14 poldek/poldek/pm/rpm/pm_rpm.h:1.15
--- poldek/poldek/pm/rpm/pm_rpm.h:1.14 Sun Aug 20 20:14:58 2006
+++ poldek/poldek/pm/rpm/pm_rpm.h Sun Dec 17 23:37:05 2006
@@ -36,7 +36,6 @@
int pm_rpm_conf_get(void *pm_rpm, const char *key, char *value, int vsize);
tn_array *pm_rpm_rpmlib_caps(void *pm_rpm);
-const char *pm_rpm_get_arch(void *pm_rpm);
char *pm_rpm_dbpath(void *pm_rpm, char *path, size_t size);
time_t pm_rpm_dbmtime(void *pm_rpm, const char *dbfull_path);
================================================================
Index: poldek/poldek/pm/rpm/rpm.c
diff -u poldek/poldek/pm/rpm/rpm.c:1.15 poldek/poldek/pm/rpm/rpm.c:1.16
--- poldek/poldek/pm/rpm/rpm.c:1.15 Sun Aug 20 20:14:58 2006
+++ poldek/poldek/pm/rpm/rpm.c Sun Dec 17 23:37:05 2006
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at k2.net.pl>
+ Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2 as
@@ -328,7 +328,7 @@
#if defined HAVE_RPMLOG && !defined ENABLE_STATIC
-/* hack: rpmlib dumps messges to stdout only... (AFAIK) */
+/* XXX hack: rpmlib dumps messges to stdout only... (AFAIK) */
void rpmlog(int prii, const char *fmt, ...)
{
va_list args;
@@ -401,8 +401,11 @@
#endif /* HAVE_RPMLOG */
-
+
+#ifndef HAVE__RPMVERCMP /* _rpmvercmp - new in rpm 4.4.7 */
extern int rpmvercmp(const char *one, const char *two);
+#endif
+
int pm_rpm_vercmp(const char *one, const char *two)
{
return rpmvercmp(one, two);
================================================================
Index: poldek/poldek/pm/rpm/rpminstall.c
diff -u poldek/poldek/pm/rpm/rpminstall.c:1.18 poldek/poldek/pm/rpm/rpminstall.c:1.19
--- poldek/poldek/pm/rpm/rpminstall.c:1.18 Wed Aug 23 00:53:01 2006
+++ poldek/poldek/pm/rpm/rpminstall.c Sun Dec 17 23:37:05 2006
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at k2.net.pl>
+ Copyright (C) 2000 - 2007 Pawel A. Gajda <mis at pld-linux.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2 as
================================================================
Index: poldek/poldek/pm/rpm/rpmvercmp.c
diff -u poldek/poldek/pm/rpm/rpmvercmp.c:1.1 poldek/poldek/pm/rpm/rpmvercmp.c:1.2
--- poldek/poldek/pm/rpm/rpmvercmp.c:1.1 Mon Aug 9 01:03:54 2004
+++ poldek/poldek/pm/rpm/rpmvercmp.c Sun Dec 17 23:37:05 2006
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -5,7 +9,9 @@
#include "i18n.h"
-extern int rpmvercmp(const char * one, const char * two);
+#ifndef HAVE__RPMVERCMP /* _rpmvercmp - new in rpm 4.4.7 */
+extern int rpmvercmp(const char *one, const char *two);
+#endif
int main(int argc, char *argv[])
================================================================
Index: poldek/poldek/pm/pm.h
diff -u poldek/poldek/pm/pm.h:1.16 poldek/poldek/pm/pm.h:1.17
--- poldek/poldek/pm/pm.h:1.16 Sun Aug 20 20:14:58 2006
+++ poldek/poldek/pm/pm.h Sun Dec 17 23:37:05 2006
@@ -201,7 +201,7 @@
PMMSTAG_ARCH = 1,
PMMSTAG_OS = 2
};
-
+/* RET 0 - different arch/os */
int pm_machine_score(struct pm_ctx *ctx,
enum pm_machine_score_tag tag, const char *val);
================================================================
---- CVS-web:
http://cvs.pld-linux.org/poldek/poldek/configure.in?r1=1.125&r2=1.126&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/install.c?r1=1.5&r2=1.6&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/misc.c?r1=1.7&r2=1.8&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/pm_rpm.h?r1=1.14&r2=1.15&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpm.c?r1=1.15&r2=1.16&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpminstall.c?r1=1.18&r2=1.19&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpmvercmp.c?r1=1.1&r2=1.2&f=u
http://cvs.pld-linux.org/poldek/poldek/pm/pm.h?r1=1.16&r2=1.17&f=u
More information about the pld-cvs-commit
mailing list