APT2: config parser testing

If you have an amd64 system, install the apt2 package from “deb http://people.debian.org/~jak/debian/ unstable/” and run the apt2-config command. Make sure that the parser reports no errors, otherwise send me an email or leave a comment here. One known exception is that all values must be quoted in the configuration file, I have no plans to fix this (probably just deprecate unquoted strings in APT instead). The parser is not as strict as cupt’s parser, but it gives you more help if something wents wrong. We also ignore most semicolons for now (they will be turned into warnings or errors later on). It is using GScanner from GLib for parsing the files.

apt2-config replicates the functionality of apt-config. It currently do not read the configuration files in the correct order, so don’t expect “apt2-config dump” to produce exactly the same output as “apt-config dump”. To build APT2 yourself, you need a patch for waf from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548329.


7 thoughts on “APT2: config parser testing

    1. Hi Julian Andres Klode,

      a few suggestions after a quick test:
      * While git log indicates that you want to drop libgee “waf configure” and the following “waf” needs both an installed libgee-dev (and therefore also libgee1) which is not listed as build-dep. (I have not build a deb, so i don’t know if it effects the pkg building – i prefer running tests as user and with the help of LD_LIBRARY_PATH)
      * I don’t know if it is intended but APT::Architecture “(null)”; if no setting is included in the files looks a bit strange.
      * If i would reimplement it, i would ignore backup/swap files like *.~, .*.swp, *.bak und co.
      * It doesn’t like entries like
      Test {
      “Option” “value”;
      (which is maybe a feature, but if i suspect something like Acquire::cdrom::”/cdrom/”::Mount “foo”; will also fail which would be a valid entry)
      * It refuses to parse the config file provided by localepurge:
      /etc/apt/apt.conf.d/99-localepurge:3: error: unexpected character `
      ‘, expected identifier
      (Maybe an end-of-line issue)

      Best regards / Mit freundlichen Grüßen,

      David “DonKult” Kalnischkies

      1. About gee, it has been re-added, although I forgot to re-add it to the build-depends.

        APT::Architecture is currently always “(null)”, as I first need to get waf to write a configuration file (in Vala) for the build and include it.

        About the backup files, yes they should be ignored in the future.

        About the options with quotes: Please, no. They are not supposed to be quoted. That’s why cupt and APT2 fail at parsing them. It would just complicate the parsing. We don’t even support unquoted options, although they are allowed according to the format (though I want to deprecate them in the documentation of the next APT release).

        About the localepurge issue, it uses quotes inside a value and thus fails because they are not escaped. All 3 parsers behave differently here: APT ignores quotes completely, APT2 requires escaped quotes, and cupt accepts unescaped quotes. We should probably just accept APT2’s behaviour everywhere, as this is the standard used in programming languages (and it would be easier for me, as GScanner handles the string quoting stuff).

  1. /etc/apt/apt.conf:6: error: unexpected character `.’, expected string constant – Unfinished option, missing value.

    Which is:
    Acquire::HTTP::Proxy::bugs.debian.org “DIRECT”;

  2. waf 1.5.9+dfsg-2 uploaded with a fix for #548329. It’s a backport from trunk, thanks for your patch anyway! 🙂

Comments are closed.