Workaround to Failure to download extra files ttf-mscorefonts-installer

Workaround tested and working on Ubuntu 17.10.

Problem

When attempting to run:

sudo apt-get install ttf-mscorefonts-installer

The following output appeared:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ttf-mscorefonts-installer
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.
Need to get 0 B/27.6 kB of archives.
After this operation, 94.2 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package ttf-mscorefonts-installer.
(Reading database ... 281508 files and directories currently installed.)
Preparing to unpack .../ttf-mscorefonts-installer_3.6ubuntu2_all.deb ...
Unpacking ttf-mscorefonts-installer (3.6ubuntu2) ...
Processing triggers for update-notifier-common (3.186) ...
ttf-mscorefonts-installer: processing...
ttf-mscorefonts-installer: downloading http://downloads.sourceforge.net/corefonts/andale32.exe
Err:1 http://downloads.sourceforge.net/corefonts/andale32.exe        
  Redirection from https to 'http://downloads.sourceforge.net/mirrorproblem?failedmirror=jaist.dl.sourceforge.net' is forbidden [IP: 150.65.7.130 443]
E: Failed to fetch https://jaist.dl.sourceforge.net/project/corefonts/the fonts/final/andale32.exe  Redirection from https to 'http://downloads.sourceforge.net/mirrorproblem?failedmirror=jaist.dl.sourceforge.net' is forbidden [IP: 150.65.7.130 443]
E: Download Failed
Setting up ttf-mscorefonts-installer (3.6ubuntu2) ...
Processing triggers for fontconfig (2.11.94-0ubuntu2) ...

If you then repeat the install command, it seems to indicate that it has already been installed but after rebooting, the problem reappears. This time, as a dialog that says:

Failure to download extra data files

The following packages requested additional data downloads after package installation, but the data could not be downloaded or could not be processed.

ttf-mscorefonts-installer

Workaround

Workaround overview

I am careful to call this a workaround rather than a proper solution. Proper solution is one where the patch is applied to the installer itself.

On high level, the workaround steps are:

  1. sudo apt-get purge ttf-mscorefonts-installer to remove the partially installed.
  2. Host a web server locally
  3. Download all Microsoft TrueType core fonts and place it into <root of web server>/corefonts/.
  4. (Temporarily) point the DNS entry of downloads.sourceforge.net to 127.0.0.1.
  5. (Temporarily) configure APT to accept invalid certificate.
  6. Reinstall sudo apt-get install ttf-mscorefonts-installer.

Detailed steps

Cleanup previous installation

Firstly, we need to cleanup the failed installation of that package by running:

sudo apt-get purge ttf-mscorefonts-installer

Host a web server

We need to host a web server. This will be used to host files downloaded from SourceForge. This is further explained in the section below.

I did not explain the details on how to host a web server. There are plenty written by others. Look for “how to setup apache/nginx” or “how to run HTTP server on NodeJS”.

Download the required files manually

The ttf-mscorefonts-installer, as the name says, is just an installer that downloads a dozen font files from SourceForge. Download all of the Microsoft TrueType core fonts via a web browser.

Place the downloaded files into <root of web server>/corefonts/. The corefonts subfolder must be created.

Temporarily change the hosts file

Edit the hosts file located at /etc/hosts. You will need sudo for this.

Example:

sudo nano /etc/hosts

Paste the following entry at the end of file:

127.0.0.1 downloads.sourceforge.net

Note: This assumes your web server is hosted locally otherwise change 127.0.0.1 to point to your IP address.

Temporarily allow APT to accept invalid certificate

Following solution shared by user n.st on StackExchange, create a new file under /etc/apt/apt.conf.d/ with a file name that does not already exist in this folder.

cd /etc/apt/apt.conf.d
sudo touch temporary
sudo nano temporary

Then paste the following:

// Do not verify peer certificate
Acquire::https::Verify-Peer "false";
// Do not verify that certificate name matches server name
Acquire::https::Verify-Host "false";

Reinstall ttf-mscorefonts-installer

Reinstall using:

sudo apt-get install ttf-mscorefonts-installer

The expected output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ttf-mscorefonts-installer
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.
Need to get 0 B/27.6 kB of archives.
After this operation, 94.2 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package ttf-mscorefonts-installer.
(Reading database ... 281508 files and directories currently installed.)
Preparing to unpack .../ttf-mscorefonts-installer_3.6ubuntu2_all.deb ...
Unpacking ttf-mscorefonts-installer (3.6ubuntu2) ...
Processing triggers for update-notifier-common (3.186) ...
ttf-mscorefonts-installer: processing...
ttf-mscorefonts-installer: downloading http://downloads.sourceforge.net/corefonts/andale32.exe
Get:1 http://downloads.sourceforge.net/corefonts/andale32.exe [198 kB]
Fetched 198 kB in 0s (3,152 kB/s)

...

All done, no errors.
All fonts downloaded and installed.
Setting up ttf-mscorefonts-installer (3.6ubuntu2) ...
Processing triggers for fontconfig (2.11.94-0ubuntu2) ...

If you are seeing similar output, the installation has completed successfully.

Undo temporary changes

Do not skip this step. This is very important due to security risk of accepting invalid certificates.

Remove the host entry line that was added into /etc/hosts.

127.0.0.1 downloads.sourceforge.net

Delete the config file that allowed APT to accept invalid certificate:

sudo rm /etc/apt/apt.conf.d/temporary

Finally, delete folder <root of web server>/corefonts.