Created
April 23, 2023 19:28
-
-
Save james-see/a1c1c6fb3dd3a4e670525b58d37f3bf2 to your computer and use it in GitHub Desktop.
download package dependancies and get them ready to deploy offline
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
#!/bin/bash | |
# Convoy downloads the stuff you need per package name for debian/ubuntu | |
# Requirements: dpkg-dev | |
# Example: ./convoy.sh python3-pip | |
get list of dependancies and download | |
sudo apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances "$1" | grep "^\w" | sort -u) | |
# create necessary Packages.gz file | |
sudo dpkg-scanpackages . | gzip -9c > Packages.gz | |
# gzipped all of it and ready | |
tar czvf convoyed.tar.gz . | |
On target machine run the following: | |
# echo "deb [trusted=yes] file:<your folder here> ./ | sudo tee -a /etc/apt/sources.list |
updated for rhel too:
#!/bin/bash
# Convoy downloads the dependencies for a specified package name for Debian/Ubuntu or RHEL
# Requirements: dpkg-dev for Debian/Ubuntu, yum-utils for RHEL
# Example: ./convoy.sh python3-pip
read -p "Enter the deployment (ubuntu/rhel): " deployment
if [ "$deployment" = "ubuntu" ]; then
if [ -z "$1" ]; then
read -p "Enter the package name: " package_name
else
package_name="$1"
fi
# Get list of dependencies and download
sudo apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances "$package_name" | grep "^\w" | sort -u)
# Create necessary Packages.gz file
sudo dpkg-scanpackages . | gzip -9c > Packages.gz
else
if [ -z "$1" ]; then
read -p "Enter the package name: " package_name
else
package_name="$1"
fi
# Get list of dependencies and download
sudo yumdownloader --resolve "$package_name"
# Create necessary repo file for RHEL
echo "[local-repo]
name=Local Repository
baseurl=file://<your folder here>/
enabled=1
gpgcheck=0" | sudo tee /etc/yum.repos.d/local-repo.repo >/dev/null
fi
# Gzip all of it and ready
tar czvf convoyed.tar.gz .
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated: