jackyf / cupt

high-level package manager for Debian, inspired from APT
36 stars 4 forks source link

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

Open UriHerrera opened 5 years ago

UriHerrera commented 5 years ago

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?.

jackyf commented 5 years ago

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) ?

UriHerrera commented 5 years ago

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";
jackyf commented 5 years ago

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

Will be implemented.

timonegk commented 4 years ago

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.

jackyf commented 4 years ago

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.

Jason-Lee-Quinn commented 2 years ago

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.