Last active
June 4, 2022 06:39
-
-
Save nutrino/a6f0fd62530c59ce27f1d52346bac590 to your computer and use it in GitHub Desktop.
Download Debian/Ubuntu packages from online and install them to 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
| apt-get download $(apt-rdepends $1|grep -v "^ " |grep -v "^libc-dev$" | sed 's/debconf-2.0/debconf/g') |
Author
Author
getdepends.sh
https://superuser.com/questions/1112525/ignore-apt-get-download-errors
#!/bin/bash
export MAXPARAMETERS=255
function array_contains_find_index() {
local n=$#
local i=0
local value=${!n}
for (( i=1; i < n; i++ )) {
if [ "${!i}" == "${value}" ]; then
echo "REMOVING $i: ${!i} = ${value}"
return $i
fi
}
return $MAXPARAMETERS
}
LIST=( $( apt-rdepends $1 | grep -v "^ " ) )
echo ${LIST[*]}
read -n1 -r -p "... Packages that will be downloaded (Continue or CTRL+C) ..."
RESULTS=( $( apt-get download ${LIST[*]} |& cut -d' ' -f 8 ) )
LISTLEN=${#LIST[@]}
while [ ${#RESULTS[@]} -gt 0 ]; do
for (( i=0; i < $LISTLEN; i++ )); do
array_contains_find_index ${RESULTS[@]} ${LIST[$i]}
ret=$?
if (( $ret != $MAXPARAMETERS )); then
unset LIST[$i]
fi
done
FULLRESULTS=$( apt-get download ${LIST[*]} 2>&1 )
RESULTS=( $( echo $FULLRESULTS |& cut -d' ' -f 11 | sed -r "s/'(.*?):(.*$)/\1/g" ) )
done
apt-get download ${LIST[*]}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
install-deb-packages.sh
sudo dpkg -i --refuse-downgrade *.deb