Re: gensrclist call to rpm

Panu Matilainen <[email protected]> Thu, 5 Aug 2004 09:05:29 +0300 (EEST)
Newsgroups gmane.linux.conectiva.apt-rpm
Message-ID <[email protected]>
On Wed, 4 Aug 2004, Aamer Akhter wrote:
> 
> I agree. The environment I'm building for does not have a predictable
> place for rpmrc. This is partly due to the fact that I'm using atp-rpm
> not for os distribution, but only as an add-on to an existing os
> (solaris and linux). The other thing is that, almost always the
> 'distribution' (again it's not an os, it's an environment build ontop
> of solaris and linux) will be installed in a network mount.
> 
> So the short of it is that the location of rpmrc is not predictable at
> compile time. Another option is to build a local rpm everytime an
> install is done. This is probably not going to work well, as on
> solaris there isn't a common environment (even gcc, isn't there
> sometimes).

Ouch, sounds like a serious maintenance nightmare :-/ Not knowing the 
environment it's hard to make suggestions but wouldn't it be easier to 
build rpm with --sysconfdif=/etc (or such) so that no matter where the rpm 
executable lives, rpmrc can always be found in a predicable place, even if 
that means copying (or symlinking) rpmrc into place on each host? 

The attached patch adds a new configuration setting RPM::RCFile so you can
use 'apt-get -o RPM::RCFile="/where/ever/rpmrc" install foo' BUT this
doesn't fix the gen*list case, since although you could set RPM::RCFile in
apt.conf I guess that's not in any predictable place either(?) and
gen*list programs don't allow passing in arbitrary config options.
Anyway I suppose something like this patch should perhaps be included in 
apt nevertheless.

> 
> I suppose a good way of handling this would be to patch the rpm source
> so that it looks for rpmrc based on an environment variable (that much
> we (our org) can agree on). Of course this would be patch local to our
> org though.
> 
> It looks like the patch would be in rpmReadConfigFiles(). I guess I
> need to brush up my C to get that done ;-)

Something like this perhaps ... patch is against rpm 4.3.1 but probably 
applies to 4.1 as well. Mind you it's completely untested :)

--- rpm-4.3.1/lib/rpmrc.c.env   2004-08-05 08:55:12.633345431 +0300
+++ rpm-4.3.1/lib/rpmrc.c       2004-08-05 09:00:01.438388819 +0300
@@ -1735,8 +1735,12 @@
        defaultsInitialized = 1;
     }
  
-    if (rcfiles == NULL)
-       rcfiles = defrcfiles;
+    if (rcfiles == NULL) {
+       if (getenv("RPM_RPMRC") == NULL)
+               rcfiles = defrcfiles;
+       else
+               rcfiles = getenv("RPM_RPMRC");
+    }
  
     /* Read each file in rcfiles. */
     rc = 0;

	- Panu -

_______________________________________________
apt-rpm mailing list
[email protected]
http://distro2.conectiva.com.br/mailman/listinfo/apt-rpm
apt-0.5.15cnc6-rcfile.patch (text/plain, 1.2 KB)
--- apt-0.5.15cnc6/apt-pkg/rpm/rpmpm.cc.rcfile	2004-08-05 08:25:17.580433568 +0300
+++ apt-0.5.15cnc6/apt-pkg/rpm/rpmpm.cc	2004-08-05 08:33:05.353083491 +0300
@@ -746,7 +746,12 @@
    bool Interactive = _config->FindB("RPM::Interactive",true);
    int debug = _config->FindB("Debug::pkgRPMPM", false);
    string Dir = _config->Find("RPM::RootDir");
-   rpmReadConfigFiles(NULL, NULL);
+   string RC = _config->Find("RPM::RCFile");
+   const char * RCFile = NULL;
+   
+   if (! RC.empty())
+      RCFile = RC.c_str();
+   rpmReadConfigFiles(RCFile, NULL);
 
    int probFilter = 0;
    int notifyFlags = 0;
--- apt-0.5.15cnc6/apt-pkg/rpm/rpmhandler.cc.rcfile	2004-08-05 08:25:25.630706564 +0300
+++ apt-0.5.15cnc6/apt-pkg/rpm/rpmhandler.cc	2004-08-05 08:32:39.486632555 +0300
@@ -353,8 +353,12 @@
    RpmIter = NULL;
 #endif
    string Dir = _config->Find("RPM::RootDir");
+   string RC = _config->Find("RPM::RCFile");
+   const char * RCFile = NULL;
    
-   rpmReadConfigFiles(NULL, NULL);
+   if (! RC.empty())
+      RCFile = RC.c_str();
+   rpmReadConfigFiles(RCFile, NULL);
    ID = DataPath(false);
 
    RPMPackageData::Singleton()->InitMinArchScore();