apt – Multiple Repos for Linux laptops

I’m working on a project to better manage updates on our Linux (Ubuntu) laptops. Currently we already have a working solution for desktops.

For our desktops, they’re configured to point to a local repository on our network for updates and new packages. This is fine since they never leave our internal network.

However, with our laptops we’re exploring the idea of configuring both our local repo and the standard Ubuntu repos. The idea being that users would be able to install software and updates from our local repo while onsite, and use the standard Ubuntu (internet) repos while at home.

In practice, I’ve tested this by adding 2 sources to the /etc/apt/sources.list.d/ directory: 00-local-repo.list and 50-ubuntu-default.list
Since both repos would contain the same packages (and versions of those packages), apt should prefer the local repo if I understand correctly (assuming apt searches the sources directory in alphanumeric order).

The problem is, when the device has no connection to our network, it doesn’t fallback to using the internet repos. It just throws up an error:

$ sudo apt install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfprint-2-tod1 libllvm10
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  ctags vim-doc vim-scripts
The following NEW packages will be installed
  vim
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 1,238 kB of archives.
After this operation, 3,111 kB of additional disk space will be used.
Get:1 http://local-repo.example.com/ubuntu focal/main amd64 vim amd64 2:8.1.2269-1ubuntu5 (1,238 kB)
Err:1 http://local-repo.example.com/ubuntu focal/main amd64 vim amd64 2:8.1.2269-1ubuntu5
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:1e38f267bf4c06e424b166e8d666ffd6ce25c657012892d099651bee18a2c834
   - SHA1:796c962d044f99a81b187211e6ce9a0a44b8d5d1 (weak)
   - MD5Sum:198ccbb07a9fc8ebe67a213eab6a3e96 (weak)
   - Filesize:1237624 (weak)
  Hashes of received file:
   - SHA256:970310343d0d5b0f40363e17367cbd8a3dbeb809149b31850bc790f1df307b13
   - SHA1:38aca684355969d0e9d826831459568296560757 (weak)
   - MD5Sum:63c787e1b487e72a7aee2a4ac9c86f9e (weak)
   - Filesize:1032 (weak)
  Last modification reported: Fri, 21 May 2021 12:43:28 +0000
Fetched 1,032 B in 0s (8,474 B/s)
E: Failed to fetch http://local-repo.example.com/ubuntu/pool/main/v/vim/vim_8.1.2269-1ubuntu5_amd64.deb  Hash Sum mismatch
   Hashes of expected file:
    - SHA256:1e38f267bf4c06e424b166e8d666ffd6ce25c657012892d099651bee18a2c834
    - SHA1:796c962d044f99a81b187211e6ce9a0a44b8d5d1 (weak)
    - MD5Sum:198ccbb07a9fc8ebe67a213eab6a3e96 (weak)
    - Filesize:1237624 (weak)
   Hashes of received file:
    - SHA256:970310343d0d5b0f40363e17367cbd8a3dbeb809149b31850bc790f1df307b13
    - SHA1:38aca684355969d0e9d826831459568296560757 (weak)
    - MD5Sum:63c787e1b487e72a7aee2a4ac9c86f9e (weak)
    - Filesize:1032 (weak)
   Last modification reported: Fri, 21 May 2021 12:43:28 +0000
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

My question is, is it possible to configure both repos and have apt install packages from each depending on which is currently available?