Feature Request: Central software package cache for WinGet
-
Hi everyone,
First of all, thank you for your great work on the FOG Project!
I recently upgraded our school’s FOG server from 1.5.10 to 1.6.1 and am really impressed by the new features, especially the new FOG Agent and the integrated software management with WinGet. As a school IT administrator managing 138 Windows 11 computers, these improvements make my daily work much easier.
Feature request: Central software package cache
As far as I understand, each client currently downloads its installation packages directly from the internet when using WinGet. It would be very useful to have a central software package cache on the FOG server, similar to the existing agent update cache.
Ideally:
- The FOG server automatically checks for new software versions.
- Each installer is downloaded only once and its integrity is verified.
- Clients download the installers from the local FOG server.
- Existing software management and reporting remain unchanged.
- Outdated cached packages are automatically removed.
- Caching can optionally be enabled per software package.
This would significantly reduce internet bandwidth usage, especially in larger school environments.
Is there already a way to achieve this with FOG 1.6.1? Is such a feature planned, or would you recommend using a separate local WinGet repository?
Thanks again to the entire FOG team for developing and maintaining such a valuable open-source solution. The progress made with FOG 1.6 is really impressive!
Best regards from Germany!
-
@wbg 1.6.1 has no WinGet cache yet. Each Software entry has a Source field. The agent passes it to winget as
--source. So you can point an entry at a local source today, but the client must already have that source registered.Two options now:
- Chocolatey with an internal feed. A folder or a share is a valid Chocolatey source. Set the backend to Chocolatey and put the share path in Source.
- A self-hosted WinGet REST source (for example rewinged), with installer URLs that point at a local web server. Register it on the clients with
winget source add(a snapin works). Then put the source name in Source.
A built-in cache on the FOG server is a reasonable request. We are tracking it here: https://github.com/FOGProject/fogproject/issues/2236
-
@wbg The WinGet cache is built. It is on dev-branch now, and it reaches stable on December 11.
How it works: the FOG server downloads the installer once. It checks each file against the SHA-256 in the WinGet manifest. Hosts then install from the FOG server, not from the internet, and WinGet checks the SHA-256 again before it installs.
To use it:
- Update the server to dev-branch and run the installer. The installer creates the cache folder (
/opt/fog/softwarecache) and adds the PHP modules the cache needs. - Hosts need FOG Agent 0.1.31 or later. It is released, so agents that update from your server get it. An older agent ignores the cache and installs from the internet, as before.
- Edit a WinGet entry and turn on Cache on this server. The edit page shows the cache state.
- Keep the FOG Agent Release Sync service on. It runs the cache, on its normal schedule.
Limits:
- Only packages from the public
wingetsource. The server shares the cached files over plain HTTP with no sign-in, so do not use it for a package that holds a license key. - The server keeps every installer variant that a version lists (x64, ARM, MSI, EXE), because WinGet picks one on each host. The files go in
/opt/fog/softwarecache, and the server stops new downloads when less than 5 GiB is free. To use a bigger disk, mount it at that path and run the installer again. - If a check fails, hosts get the last cached version, with a warning in the Software Status details.
If you test it, please post what you see here, good or bad.
- Update the server to dev-branch and run the installer. The installer creates the cache folder (
-
This post is deleted! -
Hi @Tom-Elliott ,
I switched our FOG server to dev-branch and started testing the new WinGet cache.
Test environment:
- FOG Server 1.6.1.349 (dev-branch)
- FOG Agent 0.1.39
- Ubuntu 22.04.5 LTS
- 93 Windows 11 computers assigned to the 7-Zip software package
- 165 GB of free disk space
The upgrade completed successfully. All 12 FOG services are running, the required PHP extensions are installed, and the cache directories were created correctly.
Issue: Cached installers are immediately removed
I enabled caching for 7-Zip (Latest, Present, default source, architecture x64).
All six installer variants of version 26.06 were downloaded successfully. However, the service immediately removed all six installers and the generated manifest.
The final log entry was:
Software cache: 6 downloaded, 0 failed, 7 removedThe cache directories and the
softwareCachedatabase table are empty afterwards. The General tab also does not display any cache state information.I reproduced this behaviour multiple times.
Possible root cause
After investigating
src/Agent/SoftwareCache.php, I noticed that_record()uses the named PDO parameter:nowtwice in the INSERT statement:
:sha,:path,:state,:msg,:now,:nowHowever,
src/Db/PDODB.phpexplicitly disables prepared statement emulation:
\PDO::ATTR_EMULATE_PREPARES => falseI verified this behaviour with two read-only PHP/PDO queries directly on the FOG server:
- SELECT :now, :now — SQLSTATE[HY093]: Invalid parameter number
- SELECT :now, :cachedAt — OK
My assumption is that the cache database record is not saved successfully. Consequently,
_plan()finds no referenced manifests or installers, and_prune()removes all downloaded files.
Using a separate parameter such as:cachedAtmight resolve the issue.Additional findings
LibreOffice caching currently reports:
TheDocumentFoundation.LibreOffice: has package dependencies; caching is not supported for it yetRegular WinGet software management appears to continue working.
Thank you again for your work on this feature.
-
@wbg Thanks, your diagnosis is right, and the two PDO queries made it quick to confirm.
The cause. The FOG database layer turns prepared statement emulation off, so MySQL refuses a statement that uses the same named placeholder twice. The cache record used
:nowfor both the check time and the cache time. The database layer logs that error and carries on, so the service never saw it. That is why your log says 0 failed. With no row stored, the cleanup found nothing that needed the files and removed all six installers plus the manifest. That is the 7 removed.The fix. Each value now has its own placeholder. The same bug was in the code that records a closed user session, so that is fixed too. The test database now refuses a repeated placeholder the same way MySQL does, so this cannot slip through again.
Fix: https://github.com/FOGProject/fogproject/pull/2317
To test once it is on dev-branch. Update the server to dev-branch. No schema update and no agent update are needed. You do not need to clean anything up either, because the cache is already empty. On its next run the Release Sync service downloads 7-Zip again and keeps it. The General tab on the 7-Zip entry then shows the cache state.
LibreOffice. That message is expected. A package with dependencies is not cached yet, so it installs from the internet as before.
Thanks again for digging into the code. Please post what you see after the update.
-
@Tom-Elliott The server-side cache is working perfectly now.
I have successfully cached five packages with 20 installers, totaling approximately 1.1 GB.However, I encountered another issue during client-side testing.
Test environment:
FOG Server: 1.6.1.376 (dev)
FOG Agent: 0.1.39
WinGet: 1.29.380All three assigned packages with caching enabled (7-Zip, Firefox ESR and VLC) fail with exit code 2316632068 (0x8A150004), while uncached packages update successfully.
Enabling LocalManifestFiles and restarting the agent did not resolve the issue.I investigated the cached 7-Zip manifest and found:
ManifestType: merged
ManifestVersion: 1.28.0I copied the original cached manifest to the Windows client and validated it independently of the FOG Agent:
winget validate --manifest “C:\Temp\7zip-test.yaml”Result:
Manifest Error: Field value is not supported.
[ManifestType] Value: mergedI then changed the manifest type to singleton in a local test copy. This resulted in another validation error:
Error context: <root>[Installers]
Description: Array should contain no more than 1 elements.The 7-Zip manifest contains six installer variants.
Looking at SoftwareCache.php, the rewriteManifest() function replaces the installer URLs but preserves the original manifest type and structure.It appears that the merged CDN manifest may need to be converted into a supported local manifest format, possibly a multi-file manifest to preserve WinGet’s automatic installer selection.
The HTTP cache is accessible from the client, but I have not observed any installer downloads during the failed attempts.
-
@wbg Thanks for the detailed test. I reproduced 0x8A150004 on WinGet 1.29.380, and the cause is not the
mergedmanifest type.The cause. The FOG web server collapses runs of whitespace in every reply, to make HTML pages smaller. It also did this to the JSON reply that sends the agent its software entries. The cached manifest is YAML inside that JSON, and YAML uses its spaces for structure. Each two-space indent arrived on the client as one space, so WinGet could not read the manifest. The agent details show it as “[YAML:Parser] … did not find expected key”, then “0x8a150004 : Opening manifest failed”.
About
merged.winget validatedoes rejectManifestType: merged, as you found.winget install --manifestandwinget upgrade --manifestaccept it. I tested the same 7-Zip 26.06 manifest as SYSTEM: as the server builds it, WinGet opens it and starts the download. After the whitespace collapse, it fails with your exit code. Your copy from the server cache was correct, which is why only the agent saw the problem.The fix. A reply with a JSON Content-Type now goes out unchanged. It is merged to dev-branch: https://github.com/FOGProject/fogproject/pull/2341
To test, update the server to dev-branch. No schema update and no agent update are needed, and the cached files stay as they are. The hosts try the three entries again at their next drift check (
FOG_SOFTWARE_DRIFT_INTERVAL, 6 hours by default).Please post what you see after the update.