6

This is my first question and I'm still pretty new so please forgive me if I've missed or botched something, or if this is an obvious solution.

I'm using CentOS 5.8 (yes I know it's ancient) and trying to test some squid configurations

From the Squid wiki:

NP: Squid must be built with the --enable-http-violations configure option before building.

I've done some searching to try to determine where I can find which configuration options were specified at package build, but short of reading through all of the CentOS documentation I can't seem to locate where I can find these configuration options.

I know this question may be similar to this one, but in this case the specific squid package may have been custom built, and I'm not sure I have access to the source without jumping through some hoops.

Is there a way I can list the configuration flags with yum or rpm without extracting the spec file?

  • I'm confused---has the package been installed with yum from the official repositories or no? What does yum list installed | grep squid say? – drs Jun 6 '14 at 20:12
  • There's no universal way to get such information from the RPM package. Some software packages have a way to tell you about their compile time configurations, others don't. But if you have access to the build system, you might be able to access the build log. – Pavel Šimerda Jun 6 '14 at 21:52
  • @PavelŠimerda - That's not correct, you can get this info from RPM. – slm Jun 6 '14 at 23:39
  • @sim There's no such information in the RPM and there's no way it could get there except if the whole spec file was included but even then you only know the requested configure flags which is not allways enough. – Pavel Šimerda Jun 7 '14 at 7:43
  • @PavelŠimerda - see updates to A. – slm Jun 7 '14 at 12:11
1

The question is about using RPM metadata to retrieve information about package specific compile time options. The information you're looking for isn't present in the RPM metadata. Either you need to have more than just an RPM (ideally a package build log or some of the files from the build directory), or you need to use a package specific way.

I don't know the location of build information for CentOS, for Fedora it would be:

http://koji.fedoraproject.org/

For squid, the package specific way is fairly easy:

# squid -v
Squid Cache: Version 3.4.5
configure options:  '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--exec_prefix=/usr' '--libexecdir=/usr/lib64/squid' '--localstatedir=/var' '--datadir=/usr/share/squid' '--sysconfdir=/etc/squid' '--with-logdir=$(localstatedir)/log/squid' '--with-pidfile=$(localstatedir)/run/squid.pid' '--disable-dependency-tracking' '--enable-eui' '--enable-follow-x-forwarded-for' '--enable-auth' '--enable-auth-basic=DB,LDAP,MSNT,MSNT-multi-domain,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB,getpwnam' '--enable-auth-ntlm=smb_lm,fake' '--enable-auth-digest=file,LDAP,eDirectory' '--enable-auth-negotiate=kerberos' '--enable-external-acl-helpers=LDAP_group,time_quota,session,unix_group,wbinfo_group' '--enable-storeid-rewrite-helpers=file' '--enable-cache-digests' '--enable-cachemgr-hostname=localhost' '--enable-delay-pools' '--enable-epoll' '--enable-icap-client' '--enable-ident-lookups' '--enable-linux-netfilter' '--enable-removal-policies=heap,lru' '--enable-snmp' '--enable-ssl' '--enable-ssl-crtd' '--enable-storeio=aufs,diskd,ufs' '--enable-wccpv2' '--enable-esi' '--enable-ecap' '--with-aio' '--with-default-user=squid' '--with-dl' '--with-openssl' '--with-pthreads' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -fpie' 'LDFLAGS=-Wl,-z,relro  -pie -Wl,-z,relro -Wl,-z,now' 'CXXFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -fpie' 'PKG_CONFIG_PATH=%{_PKG_CONFIG_PATH}:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

(the above output has been made using a Fedora rawhide version of squid)

For other packages, there may or may not be a command to show build time configuration. For downloading, extracting and examining the SRPM to guess compiled in features from the .spec file, see the end of the other answer.

| improve this answer | |
  • I cant believe I didn't think of squid -v. This answers my question for this specific case, thanks everybody else for all of your help. – bendobot Jun 8 '14 at 17:54
6

The closest thing you can do is to query the %{OPTFLAGS} variable so get a rough idea of the compiler flags that were used for a given RPM.

$ rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" <package>

To get the actual compiler options, however, your best bet would be to download the source RPM (SRPM) file and consult the .spec file that was used to construct it. This is the only true source where you'll find the actual compiler options that were used to build a given set of RPMs.

1. Consulting %{OPTFLAGS}

$ rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" firefox
firefox: -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic

How it works

You can query RPM and specify the format of the results you want the query command to return. In this case we're returning the --queryformat="%{NAME}: %{OPTFLAGS}\n which returns the name of the package along with the value for that packages %{OPTFLAGS}.

You can get a list of potential query tags like so:

$ rpm --querytags

Example

$ rpm --querytags | grep OPTFLAGS
OPTFLAGS

The tag %{OPTFLAGS} is defined as follows:

While the optflags entry doesn't play a part in determining the build or install platform, it does play a role in multi-platform package building. The optflags entry is used to define a standard set of options that can be used during the build process, specifically during compilation.

If RPM was running on an Intel 80386-compatible architecture, the optflags value would be set to -O2 -m486 -fno-strength-reduce. If, however, RPM was running on a Sun SPARC-based system, optflags would be set to -O2.

This entry sets the RPM_OPT_FLAGS environment variable, which can be used in the %prep, %build, and %install scripts.

2. Consulting SRPM

To do this you can download a given SRPM like so:

$ sudo yumdownloader --source <package name>

You can then extract the .spec file:

$ mkdir somedir; cd somedir
$ rpm2cpio ../firefox-29.0.1-1.fc19.src.rpm | cpio -ivd

The .spec file can then be consulted:

$ ls -l | grep spec
-rw-r--r--. 1 saml saml     31913 Jun  7 08:03 firefox.spec

NOTE: Even consulting the .spec file will likely be inconclusive in revealing the compiler options used, since the RPM spec macro %build can be quite cryptic in what they're actually doing, so even this approach will likely not show the compiler options.

References

| improve this answer | |
  • OPTFLAGS only include the distribution's globally used optimization flags given to the compiler. This has nothing to do with the configure script and it doesn't show anything else. The example (--enable-http-violations) in the original question shows that this is not what OP asked for. – Pavel Šimerda Jun 7 '14 at 7:45
  • 2
    @PavelŠimerda - thanks for the feedback. Revamped the A to reflect the limited capabilities of %{OPTFLAGS} and also added a section on consulting the SRPM instead. Even this won't give what the OP wants but is likely the closest methods you'll find. – slm Jun 7 '14 at 12:11
  • @sim: There's improvement, that must be said. But the answer still isn't very useful and is centered around concepts that have no relation to the point of the question. I would start a new answer myself but I could only answer the question for Fedora and EPEL, possibly also for OpenSUSE, but I was unable to quickly find the relevant information for CentOS. I will start a squid-specific answer, though. – Pavel Šimerda Jun 8 '14 at 15:46
  • @PavelŠimerda - using CentOS would make no diff. The methods would be the same regardless. I'll leave the A since it's relevant at showing that there isn't a method for getting the compiler options out of the RPMs and shows how you'd have to look to the .spec file for this info, if it wasn't avail. through a -v switch from the executable. It basically compl. your A. I'll disagree that it does center around the concepts of the Q. It clearly is asking for compiler options that were used to build an RPM and there aren't any. I'm showing the approaches that are avail. & why they don't work. – slm Jun 8 '14 at 19:17
  • 1
    @FaheemMitha: Certainly not on RPM's side. Packages use ./configure scripts that configure the source dynamically according to the system you're building in. There's no common way to enforce a specific configuration that would be part of the sources, and there's no common way to retrieve the configuration that could then be included in the final RPM. Different packages use different build time configuration tools in different ways. That's the real world. – Pavel Šimerda Jun 11 '14 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.