Bug#1055753: debci: --config option is broken
On Fri, Nov 10, 2023 at 06:18:33PM +0100, Christian Kastner wrote: > Hi Antonio, > > On 2023-11-10 18:10, Antonio Terceiro wrote: > > Some shared options are defined in lib/environment.sh, I think that's > > why it currently loads lib/environment.sh before processing the command > > line options. > > > > OTH your analysis is correct, as this causes the --config option to be > > useless. A solution to this would be to break the common options into > > their own file, include that in the scripts, call getopt, process > > --config before anything else, then load lib/environment.sh for default > > values, and only then process the rest of the options. > > unless I'm misreading something badly, both default values *and* option > processing are in lib/environment.sh -- it's just that getopt is called > somewhat after some defaults have been set, like config_dir, arch, etc. > > My gut says moving getopt to the top of lib/environment.sh would fix > this, but its current position seemed like a deliberate choice, so I > assumed I was missing something. The currenty situation is more a product of oversight than of design. I'm wiling to review any solution you come up with. signature.asc Description: PGP signature
Bug#1055753: debci: --config option is broken
Hi Antonio, On 2023-11-10 18:10, Antonio Terceiro wrote: > Some shared options are defined in lib/environment.sh, I think that's > why it currently loads lib/environment.sh before processing the command > line options. > > OTH your analysis is correct, as this causes the --config option to be > useless. A solution to this would be to break the common options into > their own file, include that in the scripts, call getopt, process > --config before anything else, then load lib/environment.sh for default > values, and only then process the rest of the options. unless I'm misreading something badly, both default values *and* option processing are in lib/environment.sh -- it's just that getopt is called somewhat after some defaults have been set, like config_dir, arch, etc. My gut says moving getopt to the top of lib/environment.sh would fix this, but its current position seemed like a deliberate choice, so I assumed I was missing something. Best, Christian
Bug#1055753: debci: --config option is broken
On Fri, Nov 10, 2023 at 04:42:10PM +0100, Christian Kastner wrote: > Package: debci > Version: 3.7 > Severity: normal > > The --config option to the debci subcommands does not work: > > $ mkdir /tmp/foo > $ echo 'debci_arch="i386"' > /tmp/foo/debci.conf > > $ debci config --config /tmp/foo config_dir > config_dir=/tmp/foo > > $ debci config --config /tmp/foo arch > arch=amd64 > > I believe that this is because it is processed too late. > > It is first processed at the top lib/environment.sh, where it is used to read > the config, and set important variables, like debci_arch above. > > Only after this has happened, its getopt(1) called. And I believe that all > that > --config does at that point, is to update debci_config_dir. > > > In fact, I believe all of the option parsing should be moved to the very top, > as least some other options are also broken this way: > > $ echo 'debci_arch_list="arm64 i386"' >> /tmp/foo/debci.conf > $ debci config --config /tmp/foo --arch=i386 arch > arch=i386 > $ debci config --config /tmp/foo --arch=i386 arch_list > arch_list=amd64 > > > I didn't want to file an MR outright, as I don't know the background behind > the > current solution, and there might be a good reason for it. Some shared options are defined in lib/environment.sh, I think that's why it currently loads lib/environment.sh before processing the command line options. OTH your analysis is correct, as this causes the --config option to be useless. A solution to this would be to break the common options into their own file, include that in the scripts, call getopt, process --config before anything else, then load lib/environment.sh for default values, and only then process the rest of the options. signature.asc Description: PGP signature
Bug#1055753: debci: --config option is broken
Package: debci Version: 3.7 Severity: normal The --config option to the debci subcommands does not work: $ mkdir /tmp/foo $ echo 'debci_arch="i386"' > /tmp/foo/debci.conf $ debci config --config /tmp/foo config_dir config_dir=/tmp/foo $ debci config --config /tmp/foo arch arch=amd64 I believe that this is because it is processed too late. It is first processed at the top lib/environment.sh, where it is used to read the config, and set important variables, like debci_arch above. Only after this has happened, its getopt(1) called. And I believe that all that --config does at that point, is to update debci_config_dir. In fact, I believe all of the option parsing should be moved to the very top, as least some other options are also broken this way: $ echo 'debci_arch_list="arm64 i386"' >> /tmp/foo/debci.conf $ debci config --config /tmp/foo --arch=i386 arch arch=i386 $ debci config --config /tmp/foo --arch=i386 arch_list arch_list=amd64 I didn't want to file an MR outright, as I don't know the background behind the current solution, and there might be a good reason for it. Best, Christian