This is a complex question... For years, I have been looking for a proper solution to this problem: I am working in Africa where internet connections are often slow and limited to a few locations. When offering GNU/Linux to people here, the access to the repositories in order to update the computer or to install new software is always a problem.
This time, I have an acceptable V-Sat connection at home, but in the office, the connection is limited to the corporate computer (through VPN, etc.). Plugging a Linux box to the local network does not give access to internet.
I am willing to offer to the employees to install a GNU/Linux distrib on their old private computers (Ubuntu flavors only) and I would like to setup something that offer them the possiblity to update their computer in the office through an indirect "apt-mirror" kind solution.
Concretly, I would need to find the way to update the pkgcache.bin automatically, then they could generate a download script that I would execute at the residence and the day after, they can get the requested packages for installation/update.
To do that, I could configure a Raspberry Pi 2 box that would act as a local repository, but I do not want it to download all the available packages (9 Gb that I cannot afford), but only the ones already installed (for update) or those requested (from the script).
Suggestions/questions/thoughts are very much welcome!
NB: This is not a duplicate of How can i avoid downloading packages every-time I install my Ubuntu?. Indeed, in my case, I need a solution where the clients will connect to the local repository server in a location with no internet connection for none of them, neither the server (only local LAN). The server (i.e. a Raspbery Pi 2 machine) will then be physically moved to a site where it does have internet access and download the packages requested by the client. Once back to the local LAN, it will allow the client to update or install the requested packages...
NR 2: However, I believe it is a duplicate of this question: How can I install software or packages without Internet (offline)? and Camicri Cube may be the best solution (apt-offline may also be suitable)...
So, yes, it is a duplicate... (I do not know how to mark it as such).
I think perhaps you could make use of something like apt-cacher-ng this is a caching apt proxy rather than a mirror as such meaning that it will offer the complete repository not only those packages it has locally but requested packages will only be retrieved once and then cached, the same goes for the package lists etc which are cached so long as they are still current.
It does also include configuration options to pre cache certain individual packages or even branches of the package tree using wildcards even before they are requested by clients this might potentially offer the best of both worlds allowing the local resources to be used where possible but still providing fallback to the remote repository if needed.
This is the manual for it might be worth a look to see if it could suit your needs or not. https://www.unix-ag.uni-kl.de/~bloch/acng/html/
Edit: It occurred to me after writing this that even if you were to actually create a custom repository and maintain it yourself the clients would still look to download packages not found in that repository from the main ubuntu repos if they had a copy of a recent package listing for them unless they were disabled completely so it may just simply be easier to use apt-cacher-ng if you are careful to make sure you include everything your clients will need it should work well.