Download packages one at a time instead of a single batch apt-get call,
so a typo'd or unavailable package name (or a transient network error on
one package) no longer aborts the entire run. Failed packages are
collected, printed as a warning, and the repo/archive are still built
from whatever succeeded.
Exit codes: 0 = all packages downloaded, 1 = fatal (nothing downloaded
at all), 2 = repo/archive built but some packages were skipped.
Verified manually against the ALT SP Server test machine.
Convenient for transferring the offline repo as one file instead of a
directory tree; excludes the internal .cache/ (download cache + fakeroot
rpm db), which the target machine doesn't need.
Downloads one or more packages together with their full dependency
closure (resolved against an empty rpm db so the result works on a
target machine with an arbitrary baseline, not just what's missing on
the machine running the script), then builds a local apt-rpm "classic"
repository via genbasedir --bloat (required: without --bloat, genbasedir
strips version data from some soname Provides, e.g. libssh2 -> mc, which
breaks dependency resolution on a truly clean target even though the
same packages resolve fine against the real upstream repo).
Verified end-to-end against a live ALT SP Server 10.2.2 test machine,
including simulating a from-scratch install using only the generated
repo (no upstream access).