Bug 20133

Summary: urpmi upgrade 5 > 6 loses grub2 background
Product: Mageia Reporter: Barry Jackson <zen25000>
Component: RPM PackagesAssignee: Mageia Bug Squad <bugsquad>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: marja11, thierry.vignaud, zen25000
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: grub2 CVE:
Status comment:
Attachments: Current scriptlet in my test build used for upgrade

Description Barry Jackson 2017-01-17 13:41:48 CET
Description of problem:

If an upgrade from mageia5 to 6 is done by switching mirrors and using --auto-update then neither grub2-install nor install.sh are run.

As a result unicode.pf2 font file is not copied into /boot/grub2/fonts (as it is grub2-install's job to do this).

Without unicode.pf2 grub2 menu will be in text mode only.

IIUC the upgrade applet DOES call install.sh so for most users this is not an issue, however for others who use urpmi rather than the applet then this will be disconcerting.

Is an errata adequate advising to run sudo /boot/grub2/install.sh in this case or is another fix needed? 

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
Samuel Verschelde 2017-01-17 15:46:35 CET

Keywords: (none) => FOR_ERRATA6

Marja Van Waes 2017-01-17 17:15:07 CET

CC: (none) => marja11
Assignee: bugsquad => mageiatools

Comment 1 Thierry Vignaud 2017-01-17 18:11:26 CET
That's not a tool bug but a packaging issue.

Like grub & lilo, grub2 tries to update the bootloader on update.
See rpm -q --scripts grub2-common.

The issue is that only grub-install updates unicode.pf2, not update-grub2 which is run from the scriptlet

Note that unlike grub & lilo, grub2 doesn't actually update its bootloader, it only regenerate the boot menu. We historically update the bootloader in the grub & lilo case b/c we had cases where an updated systemd wouldn't reboot after an upgrade b/c of mismatch between the old stage1 and the new stage2, ... (you can add stage1.5 for grub).
That can probably be an issue for grub2 too, even if we'ven't hit it yet.

I think grub2-common should also run /boot/grub2/install.sh like grub runs /boot/grub/install.sh

CC: (none) => thierry.vignaud, zen25000
Assignee: mageiatools => bugsquad
Source RPM: (none) => grub2

Comment 2 Thierry Vignaud 2017-01-17 18:16:48 CET
We should also probably simplify grub's post install as we generate a /boot/grub/install.sh for 17 years...
Comment 3 Thierry Vignaud 2017-01-17 18:28:29 CET
Just simplified grub legacy's logic which was added in 2005 in order to upgrade Connectiva to Mandriva...
Comment 4 Barry Jackson 2017-01-17 20:04:12 CET
(In reply to Thierry Vignaud from comment #1)
> That's not a tool bug but a packaging issue.
> 
> Like grub & lilo, grub2 tries to update the bootloader on update.
> See rpm -q --scripts grub2-common.
> 
> The issue is that only grub-install updates unicode.pf2, not update-grub2
> which is run from the scriptlet

That's wrong. The scriptlet runs /boot/grub2/install.sh

-------------------
   if [ -f /boot/grub2/updtrans ] && [ -f /boot/grub2/install.sh -a -x /usr/sbin/detectloader ] && [ "$DURING_INSTALL" != "1" ] ; then
                LOADER=$(/usr/sbin/detectloader)
                [ "$LOADER" = "GRUB2" ] && /boot/grub2/install.sh ||:
                rm -f /boot/grub2/updtrans
   fi
-------------------

[baz@jackodesktop ~]$ cat /boot/grub2/install.sh
grub2-install --bootloader-id=tmp --no-nvram

> 
> Note that unlike grub & lilo, grub2 doesn't actually update its bootloader,

Yes it does, in the above scriptlet.

Ah, the issue here is that grub2 in Mga5 does not create $updtrans during the update so the conditional fails and install.sh is not run.

Maybe we should add an additional test in %posttrans for /boot/grub2/fonts/unicode.pf2 and if it's missing run install.sh.

That should fix this upgrade issue from 5 > 6.

WDYT?
Comment 5 Thierry Vignaud 2017-01-17 20:20:19 CET
That's too late, new files from new pkgs are already there by that time.
You can add a trigger in that case.
Comment 6 Barry Jackson 2017-01-17 20:53:43 CET
(In reply to Thierry Vignaud from comment #5)
> That's too late, new files from new pkgs are already there by that time.

Why is that a problem?
Running install.sh will run grub2-install which will copy the font file where it is needed

> You can add a trigger in that case.
Hmm... I remember having to remove all those ;)

I have just built a test grub2 with this added in %posttrans:

##############
# Run install.sh if unifont.pf2 is missing (unifont.pf2 is installed by grub2-install which is run by install.sh)
   if [ -f /boot/grub2/install.sh -a -x /usr/sbin/detectloader ] && [ "$DURING_INSTALL" != "1" ]; then
		LOADER=$(/usr/sbin/detectloader)
		[ "$LOADER" = "GRUB2" ] && [ ! -f /boot/grub2/fonts/unicode.pf2 ] && /boot/grub2/install.sh ||:
   fi
##############

I don't see why this would not work.
Comment 7 Thierry Vignaud 2017-01-17 21:24:19 CET
Ah I understood you mean it was a new file in the new pkg so I though you wanted to test the package didn't exist in the package - I didn't understand you wanted to test in the /boot tree

The thing is with your change, we won't run install.sh anymore between updates as long as unicode.pf2 has been already installed, that would be a regression...
Comment 8 Barry Jackson 2017-01-17 21:36:54 CET
(In reply to Thierry Vignaud from comment #7)
> Ah I understood you mean it was a new file in the new pkg so I though you
> wanted to test the package didn't exist in the package - I didn't understand
> you wanted to test in the /boot tree
> 
> The thing is with your change, we won't run install.sh anymore between
> updates as long as unicode.pf2 has been already installed, that would be a
> regression...

Yes we would, this test is in addition to the current one, after it.
The first test is still as in comment #4 which first checks for $updtrans

The new test catches the upgrade from Mga5 which does not have updtrans and would otherwise not run install.sh.

Checking for the font file is actually quite a good check to know whether update -grub has been run or not.
Comment 9 Barry Jackson 2017-01-17 22:06:21 CET
However it failed to install unicode.pf2

During the upgrade I saw grub2-install was run after the transaction and it reported no error, however on reboot the background was missing as was unicode.pf2.

I see no other errors in grub2 installation.

Running install.sh from the running system again reports no error but DOES copy unifont.pf2 over correctly.

I am baffled as to why it fails to copy it when run in %posttrans.
Comment 10 Barry Jackson 2017-01-17 22:10:57 CET
Created attachment 8870 [details]
Current scriptlet in my test build used for upgrade
Comment 11 Barry Jackson 2017-01-17 22:38:21 CET
unicode.pf2 IS in grub2-common, however since grub2-mageia-theme is no longer Suggested/Required by grub2{,-efi} then the theme is not in the same transaction and is installed later on upgrade.

I think this may be the problem.

You removed the Recommends as part of grub2 tools integration.
http://svnweb.mageia.org/packages?view=revision&revision=953531

Is there another way to force grub2-*theme* packages to be included in the transaction? (Assuming this really is the issue)
Comment 12 Barry Jackson 2017-01-17 23:52:55 CET
Update:
I tested an upgrade with the theme package Recommended but stupidly left it unversioned so it was still outside the transaction.

However I did monitor the grub2/fonts folder during the upgrade and unicode.pf2 was copied over during update of grub2 BUT it was removed on update of the theme package later, so I now need to investigate why. :\
Comment 13 Barry Jackson 2017-01-18 01:46:41 CET
I give up, at least for tonight.

If grub2-mageia-theme is excluded from the upgrade then obviously the theme is not updated, however the font file is in place and the Mga5 theme still works fine in the updated Mga6.

If the new Mga6 grub2-mageia-theme is then installed, it somehow removes unicode.pf2 from /boot/grub2/fonts/ and I have no idea why or how.

I will sleep on it.

Any ideas?
Comment 14 Barry Jackson 2017-01-18 13:26:26 CET
OK found it. Amazing what some sleep does ;)

unicode.pf2 was in grub2-mageia-theme package in Mga5 and was written directly to it's final location - it is now in grub2-common and written to %_datadir from where it is copied to the final location by grub2-install, so it will be removed by the outgoing theme package.

Thinking more clearly now, the change to %posttrans common should not be needed as this can be fixed with a one-time %triggerpostun mageia-theme to re-run install.sh during upgrade from Mga5 -> 6 only,

Testing this now.
Comment 15 Thierry Vignaud 2017-01-18 13:45:32 CET
A trigger is what I advertised you yesterday :-)
Comment 16 Barry Jackson 2017-01-18 14:07:39 CET
(In reply to Thierry Vignaud from comment #15)
> A trigger is what I advertised you yesterday :-)

Yes but I was not fully understanding the reason behind the issue then.
I have slept since :)

Tested and working fine  -  fix pushed so closing.

Keywords: FOR_ERRATA6 => (none)
Status: NEW => RESOLVED
Resolution: (none) => FIXED