Skip to content

Instantly share code, notes, and snippets.

@fakhamatia
Created January 31, 2021 08:34
Show Gist options
  • Save fakhamatia/edb7f5ac3d7876b05a46b7b0e97bf910 to your computer and use it in GitHub Desktop.
Save fakhamatia/edb7f5ac3d7876b05a46b7b0e97bf910 to your computer and use it in GitHub Desktop.
Find URL of dependencies of a package

Find URL of dependencies of a package and save them as a script file and you can run it for download depends packages

If some dependencies have been installed, we ignore them.

#!/bin/bash
packageName=$1
apt-get install $packageName --print-uris | grep "'" | awk '{print $1}' | sed "s/'//g" | sed -e 's/^/wget /' >"${packageName}_URL.sh"
numPacks=$(wc -l "${packageName}_URL.sh" | awk '{ print $1 }')
if [ $numPacks == "1" ]; then
echo "No needed any depends packages."
elif [ $numPacks == "0" ]; then
echo "ERROR: Failed to find any URL for $packageName. Please check the package"
rm "${packageName}_URL.sh"
exit 1
fi
echo " $numPacks packages need to install $packageName "
sed -i -e '1i#!/bin/bash\' "${packageName}_URL.sh"
chmod u+x "${packageName}_URL.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment