ubuntu / WSL

Ubuntu WSL image build and launcher code.
MIT License
152 stars 46 forks source link

`do-release-upgrade` when systemd is disabled. #493

Open vadimkantorov opened 2 months ago

vadimkantorov commented 2 months ago

cmd /c ver

Microsoft Windows [Version 10.0.22631.4037]

wsl --status

C:\Users\vadim>wsl --status Default Distribution: Ubuntu Default Version: 2

C:\Users\vadim>wsl -l -v NAME STATE VERSION

Did the problem occur during installation?

What happened?

Related issue I created in MS's repo:

What was expected?

On Ubuntu-22.04/WSLv1 sudo do-release-upgrade should succeed and bypass not working snap list, maybe snap list could be stubbed out, or better - the upgrader script should handle this error. On WSLv1 snap/snapd and snap apps are not supported, so they need not any upgrades, and this should be simply skipped in the upgrade process

Steps to reproduce

N/A - explained above (have Ubuntu-22.04 + WSLv1 and launch sudo do-release-upgrade)

Additional information

No response

vadimkantorov commented 2 months ago

In /tmp/ubuntu-release-upgrader-t8sg0mg9/DistUpgrade/DistUpgradeQuirks.py:

     def _test_and_fail_on_tpm_fde(self):
        """
        LP: #2065229
        """
        try:
            snap_list = subprocess.check_output(['snap', 'list'])
            snaps = [s.decode().split()[0] for s in snap_list.splitlines()]
        except FileNotFoundError:
            # snapd not installed?
            return

I think except FileNotFoundError: should be extended to except:

Because DistUpgradeQuirks.py is stored in some temp directory, it was hard to change it inplace, but I succeeded, and then the upgrade process continued as it should

Then after an hour of upgrade I got this error (maybe systemd install failed):

Setting up systemd (255.4-1ubuntu8.4) ...
Installing new version of config file /etc/systemd/journald.conf ...
Installing new version of config file /etc/systemd/logind.conf ...
Installing new version of config file /etc/systemd/networkd.conf ...
Installing new version of config file /etc/systemd/pstore.conf ...
Installing new version of config file /etc/systemd/sleep.conf ...
Installing new version of config file /etc/systemd/system.conf ...
Installing new version of config file /etc/systemd/user.conf ...
/usr/lib/tmpfiles.d/polkitd.conf:2: Failed to resolve group 'polkitd': No such process
/usr/lib/tmpfiles.d/polkitd.conf:3: Failed to resolve group 'polkitd': No such process
Failed to take /etc/passwd lock: Invalid argument
dpkg: error processing package systemd (--configure):
 installed systemd package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 systemd

It appears that some packages add systemd post-installation scripts which then cannot run as WSLv1 has no systemd

ZupoLlask commented 2 months ago

I guess I'm finding another fellow that appreciates WSL1 approach... ;-)

sephiroth-j commented 2 months ago

I use wsl2 but I am getting the same error. 😕

edit: systemd was disabled because /etc/wsl.conf was empty. It worked after enabling systemd support.

jibel commented 2 months ago

Thanks for your report. I filed https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/2080233 upstream to address this issue in Ubuntu release upgrader.

vadimkantorov commented 2 months ago

Another suggestion:

@jibel In the bug filed above two problems appear mixed:

  1. bug in _test_and_fail_on_tpm_fde which crashes on unexpected return code by snap list. after hacking/commenting this out I stumbled on the next problem which is more serious:
  2. bug in apt which tries to run systemd-postinstall scripts whereas systemd is disabled

Btw my distro became broken after this upgrade attempt, and --fix-broken-install did not help as it also tries to run systemd-postinstall scripts and cannot. Maybe a command-line switch for apt which would skip systemd-postinstall scripts would be nice. Luckily, I installed a fresh Ubuntu24.04 distro from Microsoft Store and switched it to WSLv1 successfully. But of course, this upgrade experience is not very nice :(

jibel commented 2 months ago

2. bug in apt which tries to run systemd-postinstall scripts whereas systemd is disabled

Right, I filed https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2080257 against systemd in Ubuntu for the systemd postinst issue.

vadimkantorov commented 2 months ago

I filed https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/2080233 upstream to address this issue in Ubuntu release upgrader.

Could you please add in there investigated details about the DistUpgrade/DistUpgradeQuirks.py being problematic and its function _test_and_fail_on_tpm_fde being too conservative? That method is designed to continue fine if snap is not present, but unfortunately fails to continue if snap exists, but snap list returns a stubbed message / non-zero exit code