FS#47924 - [namcap] [pyalpm] namcap could not parse included configs

Attached to Project: Arch Linux
Opened by Evgeniy Alexeev (arcan1s) - Thursday, 28 January 2016, 13:24 GMT
Last edited by Jelle van der Waa (jelly) - Monday, 03 April 2023, 19:18 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Rémy Oudompheng (remyoudompheng)
Jelle van der Waa (jelly)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

I have the following pacman.conf:

https://gist.github.com/arcan1s/c3bfce51ad0eb7860bdb

Where pacaur.conf contains common pacman settings for several configurations. According to the pacman man page my syntax is correct and include statement may be used not only to include server url (as usually it is used). Moreover I don't have any problems when works with pacman in usual way. But running namcap says:

pycman.config.InvalidSyntax: unable to parse /etc/pacman.conf, statement outside of a section: 'Include = /etc/pacaur.conf'


Additional info:
* nacmap-3.2.6-1
* /etc/pacman.conf: https://gist.github.com/arcan1s/c3bfce51ad0eb7860bdb


Steps to reproduce:
1. Split /etc/pacman.conf to two (or more files).
2. Set Include = /path/to/another/pacman/config at the beginning of /etc/pacman.conf
3. Run namcap, e.g. namcap -h
This task depends upon

Closed by  Jelle van der Waa (jelly)
Monday, 03 April 2023, 19:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/p yalpm/-/commit/90941d054f431f5314d170e20 c3c4a209b8bb2b1
Comment by Michael (MST) - Thursday, 23 June 2016, 18:35 GMT
Is this still an issue with pyalpm-8.0? Looking at the git history [1] I think there were no relevant changes in pycman/config.py since this was opened, but I can not reproduce it.
For example running 'namcap -h' using the following pacman.conf works just fine. (original /etc/pacman.conf copied to /etc/pacman.conf.bak and disabled the [community] repo)


Include = /etc/pacman.conf.bak

[community]
Include = /etc/pacman.d/mirrorlist


[1] https://git.archlinux.org/users/remy/pyalpm.git/log/
Comment by Evgeniy Alexeev (arcan1s) - Thursday, 23 June 2016, 19:01 GMT
it is a bit strange, because I'm still able to reproduce the exception. I have just copied the original pacman configuration from package to pacman.conf.bak, created pacman.conf mentioned by you and got the same stacktrace. Namcap is 3.2.7-1 and pyalpm is 0.8-1.

In other hand at the moment I'm not sure is this a bug of namcap or a feature of pacman, because man page describes Include option inside OPTIONS section and it is not mentioned that Include may be used outside of any section.
Comment by Michael (MST) - Thursday, 23 June 2016, 19:35 GMT
Yes it's indeed a bit strange, if I look at the pyalpm sources [1] (lines 86 - 106) I would expect to get the error. So I'm wondering why it works on my machine...

[1] https://git.archlinux.org/users/remy/pyalpm.git/tree/pycman/config.py
Comment by Eli Schwartz (eschwartz) - Monday, 26 February 2018, 04:32 GMT
@arcan1s, since the very first pacman.conf manpage the Include keyword has been documented as:

Include = path::
Include another config file. This file can include repositories or
general configuration options.

I think this indicates clearly that the included file can mix and match [reponame] and [options] content -- so this is definitively something that should work. If it is allowed to redefine the section context, it is by extension allowed to exist outside of a section.

@remy, @jelle,

I can reliably get the following to crash for me:

python -c "import pyalpm; c = pycman.config.PacmanConfig(conf='/etc/pacman.conf')"

However, it only does so when I move my Include'd file (in this case /etc/pacman.d/nocustom.conf which contains all the settings which don't relate to custom repositories) to *above* the first [options] section.

Given that it itself begins with [options] and pacman (as well as pacman-conf) is fine with this, pyalpm should be handling this as well.

Note that as far as pacman is concerned, the Include statements are parsed and inlined into the configuration file, which is then parsed as a unified config file. See for example the generated config file output by `pacman-conf` (or pacconf if you have pacutils but not pacman-git).

So I think that this section over here should be run later on: https://git.archlinux.org/pyalpm.git/tree/pycman/config.py#n105

Or really, this should be run before anything else: https://git.archlinux.org/pyalpm.git/tree/pycman/config.py#n105

Loading...