cupt icon indicating copy to clipboard operation
cupt copied to clipboard

cupt throws errors when APT config. files have comments in them

Open UriHerrera opened this issue 6 years ago • 6 comments

Whenever I use cupt to install a package with it, it gives this error:

E: syntax error: line 1, character 1: expected: clear directive ('#clear') or option name (letters, numbers, slashes, points, dashes, double colons allowed)
E: unable to parse the config file '//etc/apt/apt.conf.d/50apt-file.conf'
W: skipped the configuration file '//etc/apt/apt.conf.d/50apt-file.conf'

After some troubleshooting, I found that unless I removed every comment from that configuration file, it would always display those messages. Is there a particular reason why cupt isn't merely ignoring these comments on those files?.

UriHerrera avatar Jul 16 '19 19:07 UriHerrera

Is there a particular reason why cupt isn't merely ignoring these comments on those files?

Presumably because it does not recognise those as comments. Which, in turn, could be either due to the bug in the code, interpreting the format more strictly than other tools, or the format got extended without libcupt taking notice.

May I ask you to attach the config file in question (/etc/apt/apt.conf.d/50apt-file.conf) ?

jackyf avatar Jul 19 '19 16:07 jackyf

Sure. These are the contents of the file.

## This file is provided by apt-file(1) to download Contents
## files, which is used by apt-file for searching.

Acquire::IndexTargets {
    deb::Contents-deb  {
        MetaKey "$(COMPONENT)/Contents-$(ARCHITECTURE)";
        ShortDescription "Contents-$(ARCHITECTURE)";
        Description "$(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Contents (deb)";

        flatMetaKey "Contents-$(ARCHITECTURE)";
        flatDescription "$(RELEASE) Contents (deb)";
        PDiffs "true";
        KeepCompressed "true";
    };

    # Download Contents for source files if there is a deb-src
    # line
    deb-src::Contents-dsc  {
        MetaKey "$(COMPONENT)/Contents-source";
        ShortDescription "Contents-source";
        Description "$(RELEASE)/$(COMPONENT) source Contents (dsc)";

        flatMetaKey "Contents-source";
        flatDescription "$(RELEASE) Contents (dsc)";
        PDiffs "true";
        KeepCompressed "true";
        DefaultEnabled "false";
    };

    # Configuration for downloading Contents files for
    # debian-installer packages (udebs).
    deb::Contents-udeb  {
        MetaKey "$(COMPONENT)/Contents-udeb-$(ARCHITECTURE)";
        ShortDescription "Contents-udeb-$(ARCHITECTURE)";
        Description "$(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Contents (udeb)";

        flatMetaKey "Contents-udeb-$(ARCHITECTURE)";
        flatDescription "$(RELEASE) Contents (udeb)";
        KeepCompressed "true";
        PDiffs "true";
        DefaultEnabled "false";
    };
    ### FALLBACKS
    deb::Contents-deb-legacy {
        MetaKey "Contents-$(ARCHITECTURE)";
        ShortDescription "Contents-$(ARCHITECTURE)";
        Description "$(RELEASE) $(ARCHITECTURE) Contents (deb)";

        PDiffs "true";
        KeepCompressed "true";
        Fallback-Of "Contents-deb";
        Identifier "Contents-deb";
    };
};
Dir::Etc::apt-file-main "apt-file.conf";
# Default for -I/--index-names (comma-separated)
apt-file::Index-Names "deb";

UriHerrera avatar Jul 20 '19 05:07 UriHerrera

Thank you. It appears that I missed a moment when '#'-syntax was introduced.

Will be implemented.

jackyf avatar Aug 06 '19 17:08 jackyf

Here (https://github.com/jackyf/cupt/blob/master/cpp/lib/src/internal/configparser.cpp#L246), only # followed by whitespace are parsed as comments. I think everything starting with # should be a comment.

timonegk avatar Jan 21 '20 11:01 timonegk

I think everything starting with # should be a comment.

Not that simple, unfortunately. #clear is not a comment although it starts with a #. Still, ## is possible to support.

jackyf avatar Feb 17 '20 13:02 jackyf

The documentation for APT was updated to mention hash-style comments on 25 June 2021 with this edit.

I haven't yet found the changes that allowed hash style comments for APT. Even the updated APT documentation is not very accurate because as you state, some commands begin with a hash; so this apt documentation ought to be re-worded for accuracy.

Anyway, I'm here because I filed bugs against two other packages

https://github.com/nthykier/apt-file/issues/4 https://github.com/ximion/appstream/issues/409

thinking they had incorrect comments in their apt config files. I'm running Debian Bullseye whose apt version doesn't yet document the hash style comment but some of the packages use it (seemingly without issue) but whose cupt version complains about them when a "cupt why" command is issued.

Jason-Lee-Quinn avatar Jun 10 '22 02:06 Jason-Lee-Quinn