Bug 20551 - Installer no longer respects default rpmsrate level when selecting packages
Summary: Installer no longer respects default rpmsrate level when selecting packages
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Installer (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia tools maintainers
QA Contact:
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2017-03-22 10:11 CET by Martin Whitaker
Modified: 2017-03-24 14:43 CET (History)
2 users (show)

See Also:
Source RPM:
CVE:
Status comment:


Attachments
old install2 test case (5.94 KB, text/plain)
2017-03-23 15:37 CET, Thierry Vignaud
Details
current install2 test case (5.45 KB, text/plain)
2017-03-23 15:37 CET, Thierry Vignaud
Details
new Getopt option install2 test case (5.14 KB, application/x-perl)
2017-03-23 15:37 CET, Thierry Vignaud
Details
old install2 test case (5.95 KB, text/plain)
2017-03-23 15:52 CET, Thierry Vignaud
Details
current install2 test case (5.46 KB, text/plain)
2017-03-23 15:52 CET, Thierry Vignaud
Details
new Getopt option install2 test case (5.15 KB, text/plain)
2017-03-23 15:53 CET, Thierry Vignaud
Details
comparing files generated by test-old & test.pl (2.08 KB, patch)
2017-03-23 15:57 CET, Thierry Vignaud
Details | Diff
comparing files generated by test-old & test-new.pl (1.22 KB, patch)
2017-03-23 15:57 CET, Thierry Vignaud
Details | Diff
prevent autovivification (mga#20551) (3.97 KB, patch)
2017-03-23 16:21 CET, Thierry Vignaud
Details | Diff
prevent autovivification (mga#20551) (4.05 KB, patch)
2017-03-23 16:25 CET, Thierry Vignaud
Details | Diff
ignore case for options (1017 bytes, patch)
2017-03-23 16:31 CET, Thierry Vignaud
Details | Diff
prevent autovivification (mga#20551) (4.12 KB, patch)
2017-03-23 16:31 CET, Thierry Vignaud
Details | Diff

Description Martin Whitaker 2017-03-22 10:11:37 CET
This bug was introduced in commit 560f9ca98 ("simplify by switching to Getopt::Long"). If the compsslistlevel option is not present on the command line, Getopt::Long still adds a compssListLevel key to the $o hash, setting it to an empty string. This then prevents $o->{compssListLevel} being set to the default rpmsrate level in steps_interactive::choosePackages() (because add2hash_ doesn't replace an existing key).

Reading the documentation for Getopt::Long, there is a way to prevent it adding to hashes if an option isn't present, but that might be a bit risky at this stage in mga6 (might introduce other bugs). So maybe something like

--- a/perl-install/install/install2.pm
+++ b/perl-install/install/install2.pm
@@ -580,7 +580,7 @@ sub parse_args {
            'suppl=s'      => \$o->{supplmedia},
            askmedia       => \$o->{askmedia},
            restore        => \$::isRestore,
-           'compsslistlevel=s' => \$o->{compssListLevel},
+           'compsslistlevel=s' => sub { $o->{compssListLevel} = $_[1] if $_[1] > 0 },
        );
 
     ($cfg, $patch);

(not tested).
Comment 1 Thierry Vignaud 2017-03-22 16:06:11 CET
Thx for spotting this.
On the other hand, other variables might be affected.
What would be the Getopt::Long option?

Keywords: (none) => PATCH
CC: (none) => thierry.vignaud

Comment 2 Martin Whitaker 2017-03-23 00:49:01 CET
(In reply to Thierry Vignaud from comment #1)
> What would be the Getopt::Long option?

http://perldoc.perl.org/Getopt/Long.html#Storing-options-values-in-a-hash
Comment 3 Thierry Vignaud 2017-03-23 15:37:26 CET
Created attachment 9135 [details]
old install2 test case
Comment 4 Thierry Vignaud 2017-03-23 15:37:28 CET
Created attachment 9136 [details]
current install2 test case
Comment 5 Thierry Vignaud 2017-03-23 15:37:28 CET
Created attachment 9137 [details]
new Getopt option install2 test case
Comment 6 Thierry Vignaud 2017-03-23 15:52:54 CET
Created attachment 9138 [details]
old install2 test case

v2: actually use args

Attachment 9135 is obsolete: 0 => 1

Comment 7 Thierry Vignaud 2017-03-23 15:52:56 CET
Created attachment 9139 [details]
current install2 test case

v2: actually use args

Attachment 9136 is obsolete: 0 => 1

Comment 8 Thierry Vignaud 2017-03-23 15:53:01 CET
Created attachment 9140 [details]
new Getopt option install2 test case

v2: actually use args

Attachment 9137 is obsolete: 0 => 1

Comment 9 Thierry Vignaud 2017-03-23 15:57:39 CET
Created attachment 9141 [details]
comparing files generated by test-old & test.pl

Indeed we can see a lot of autovivification, using:

perl test-old.pl  --flang fr 
perl test.pl --flang=fr
diff -u o_old.pm o.pm >old_and_current2.diff

Note that with the old code that didn't used Getopt, "LANG=fr_FR.UTF-8" from /proc/cmdline overrides --flang...
Comment 10 Thierry Vignaud 2017-03-23 15:57:44 CET
Created attachment 9142 [details]
comparing files generated by test-old & test-new.pl

There's quite a lot less of autovivification, using:

perl test-old.pl  --flang fr 
perl test-new.pl --flang=fr
diff -u o_old.pm o_new.pm >old_and_new_option_result2.diff
Comment 11 Thierry Vignaud 2017-03-23 15:58:30 CET
I think we can safely uses the Getopt option as we can play with several drakx options using those scripts, in order to make sure there's no unwanted side effects
Comment 12 Thierry Vignaud 2017-03-23 16:15:35 CET
eg:
for i in test-old.pl test-new.pl;do perl ./$i --flang fr --keyboard ru --debug_urpmi --deploops --justdb --text --fdisk --nodmraid --compsslistlevel=4 --useless_thing_accepted ;done; diff -u o_*pm>l

Which nicely that I forgot to do handle the case for the level in test-new.pl:
            'compsslistlevel=s' => \$o->{compssListLevel},

So I think we can safely do the change.
Comment 13 Thierry Vignaud 2017-03-23 16:21:52 CET
Created attachment 9143 [details]
prevent autovivification (mga#20551)

Just moving parse_args() from test-new.pl back into install::install2
Comment 14 Thierry Vignaud 2017-03-23 16:25:26 CET
Created attachment 9144 [details]
prevent autovivification (mga#20551)

also prevent autovivification of 'security'

Attachment 9143 is obsolete: 0 => 1

Comment 15 Thierry Vignaud 2017-03-23 16:31:14 CET
Created attachment 9145 [details]
ignore case for options
Comment 16 Thierry Vignaud 2017-03-23 16:31:55 CET
Created attachment 9146 [details]
prevent autovivification (mga#20551)

v3: actually handles 'compssListLevel' !!!

Attachment 9144 is obsolete: 0 => 1

Comment 17 Thierry Vignaud 2017-03-23 16:34:14 CET
WDYT Martin?

Status: NEW => ASSIGNED

Comment 18 Martin Whitaker 2017-03-24 00:59:40 CET
Looks fairly safe to me. We may have a few more bugs like 20521/20522 to fix up, but I doubt there'll be that many.
Comment 19 Mageia Robot 2017-03-24 14:38:55 CET
commit 73743912c3d2eb61012a9f4273972e3701dc6b55
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Thu Mar 23 16:17:28 2017 +0100

    prevent autovivification (mga#20551)
    
    commit 560f9ca983d743cc42701c24546ac8c2080a13fe introduced a regression
    in that a lot of variables got autovivificated
    This results in a bug for some of them, at least for 'compssListLevel'
    
    The solution is to store options values in a hash (which actually
    simplifies here):
    http://perldoc.perl.org/Getopt/Long.html#Storing-options-values-in-a-hash
    
    Thanks Martin Whitaker for the suggestion
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=73743912c3d2eb61012a9f4273972e3701dc6b55
Comment 20 Thierry Vignaud 2017-03-24 14:43:09 CET
Fixed

Status: ASSIGNED => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.