Last active
August 12, 2023 08:34
-
-
Save adujardin/fb800e91f9f3f3d43ea8e466c2671557 to your computer and use it in GitHub Desktop.
Script to download all dependencies of a package on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Inspired from https://ostechnix.com/download-packages-dependencies-locally-ubuntu/ | |
# Can be typically run in docker to select the version you want like: | |
# docker run -it -v $(pwd):/host ubuntu:20.04 bash -c "$(cat ./this_script.sh)" | |
package_to_install="docker.io" | |
apt update; apt install -y apt-rdepends lsb-release | |
# Download all dependencies + the package itself | |
apt-get download $(apt-rdepends ${package_to_install} | grep -v "^ " | sed 's/debconf-2.0/debconf/g') | |
ubuntu_version=$(lsb_release -rs) | |
# Create an archive of these | |
tar -cvf "${package_to_install}_ubuntu${ubuntu_version}_packages.tar" *.deb | |
# Get them back to the host | |
cp *.tar /host/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment