Re: Re: New experimental, unofficial apt-rpm release

"Dmitry V. Levin" <[email protected]> Tue, 4 Apr 2006 01:27:36 +0400
Newsgroups gmane.linux.conectiva.apt-rpm
Message-ID <[email protected]>
--===============0976311635==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="WhfpMioaduB5tiZL"
Content-Disposition: inline


--WhfpMioaduB5tiZL
Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy"
Content-Disposition: inline


--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

On Mon, Feb 06, 2006 at 09:44:57PM +0200, Panu Matilainen wrote:
[...]
> Shasums of the new version:
> 60e2d5b9b85cb48b2fe68e4646a6f8c303a8bc7f  apt-0.5.15lorg2-1.src.rpm
> d4693d50c84bf1ac6ca41d645b9b2e43c778e44b  apt-0.5.15lorg2.tar.bz2
>=20
> Nothing too dramatic here but the multilib stuff is cleaned up a bit and
> generalized, you wont see the difference in practise. The more visible
> change is that apt now supports yum-style distro-version-package
> setting, you can set APT::DistroVerPkg=3D"fedora-release" and any
> $(VERSION) references in sources.lists can are replaced with the
> packages version. So you can now use sources.list entries like this:
> "rpm http://ayo.freshrpms.net/ fedora/linux/$(VERSION)/$(ARCH) core"

This code does not compile on rpm-4.0.x, leaks memory and does not work
for user who cannot open rpm database in O_RDWR mode.
Attached patch fixes all these issues.


--=20
ldv

--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="apt-0.5.15lorg2-alt-rpmSystem-DistroVer.patch"
Content-Transfer-Encoding: quoted-printable

diff -upk.orig apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsystem.cc apt-0.5.15lorg=
2/apt-pkg/rpm/rpmsystem.cc
--- apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsystem.cc	2006-02-06 19:11:06 +0000
+++ apt-0.5.15lorg2/apt-pkg/rpm/rpmsystem.cc	2006-04-01 16:14:46 +0000
@@ -248,31 +248,50 @@ signed rpmSystem::Score(Configuration co
 string rpmSystem::DistroVer(Configuration const &Cnf)
 {
    string DistroVerPkg =3D _config->Find("Apt::DistroVerPkg");
-   string DistroVersion =3D "";
+   string DistroVersion;
=20
+   if (DistroVerPkg.empty())
+      return DistroVersion;
=20
-   if (! DistroVerPkg.empty()) {
-      rpmts ts;
-      char *version;
-      int type, count, rc;
-      rpmdbMatchIterator iter;
-
-      ts =3D rpmtsCreate();
-      rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
-      rpmtsSetRootDir(ts, NULL);
-      rc =3D rpmtsOpenDB(ts, O_RDWR);
-
-      Header hdr;
-      iter =3D rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_=
str(), 0);
-      while ((hdr =3D rpmdbNextIterator(iter)) !=3D NULL) {
-         headerGetEntry(hdr, RPMTAG_VERSION, &type, (void **)&version, &co=
unt);
-	 DistroVersion =3D version;
+#if RPM_VERSION >=3D 0x040100
+   rpmts ts;
+   ts =3D rpmtsCreate();
+   rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
+   rpmtsSetRootDir(ts, NULL);
+   if (rpmtsOpenDB(ts, O_RDONLY))
+      return DistroVersion;
+#else
+   rpmdb DB;
+   string RootDir =3D _config->Find("RPM::RootDir");
+   const char *RootDirStr =3D RootDir.empty() ? NULL : RootDir.c_str();
+   if (rpmdbOpen(RootDirStr, &DB, O_RDONLY, 0644))
+      return DistroVersion;
+#endif
+
+   rpmdbMatchIterator iter;
+#if RPM_VERSION >=3D 0x040100
+   iter =3D rpmtsInitIterator(ts, (rpmTag)RPMDBI_LABEL, DistroVerPkg.c_str=
(), 0);
+#else
+   iter =3D rpmdbInitIterator(DB, RPMDBI_LABEL, DistroVerPkg.c_str(), 0);
+#endif
+   Header hdr;
+   while ((hdr =3D rpmdbNextIterator(iter)) !=3D NULL) {
+      void *version;
+      int type, count;
+
+      if (headerGetEntry(hdr, RPMTAG_VERSION, &type, &version, &count)) {
+         DistroVersion =3D (char *)version;
+         headerFreeData(&version, (rpmTagType)type);
          break;
       }
-      rpmdbFreeIterator(iter);
-      rpmtsFree(ts);
    }
-  =20
+   rpmdbFreeIterator(iter);
+#if RPM_VERSION >=3D 0x040100
+   rpmtsFree(ts);
+#else
+   rpmdbClose(DB);
+#endif
+
    return DistroVersion;
 }
=20

--gBBFr7Ir9EOA20Yy--

--WhfpMioaduB5tiZL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD4DBQFEMZNIfKvmrJ41Nh4RAgt3AJixDBlPMOglGUoHKGTP2DQlMesEAKCh5HsX
BNmcNGpk/M0/8kEeHscUfA==
=K2ag
-----END PGP SIGNATURE-----

--WhfpMioaduB5tiZL--

--===============0976311635==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
apt-rpm mailing list
[email protected]
http://distro2.conectiva.com.br/mailman/listinfo/apt-rpm

--===============0976311635==--