Skip to content
Draft
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions apt-fast
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# apt-fast v1.9
# apt-fast v1.9.11
# Use this just like aptitude or apt-get for faster package downloading.
#
# Copyright: 2008-2012 Matt Parnell, http://www.mattparnell.com
Expand Down Expand Up @@ -33,6 +33,9 @@ msg(){
fi
}

# Stores fullpath of real "apt-get"
real_APT="/usr/bin/apt-get"

# Search for known options and decide if root privileges are needed.
root=1 # default value: we need root privileges
option=
Expand Down Expand Up @@ -119,7 +122,7 @@ LCK_FD=99

# Set default package manager, APT cache, temporary download dir,
# temporary download list file, and maximal parallel downloads
_APTMGR=apt-get
_APTMGR="${real_APT}"
eval "$(apt-config shell APTCACHE Dir::Cache::archives/d)"
# Check if APT config option Dir::Cache::archives::apt-fast-partial is set.
eval "$(apt-config shell apt_fast_partial Dir::Cache::archives::apt-fast-partial/d)"
Expand Down Expand Up @@ -169,6 +172,12 @@ for Prefix in /usr/local/etc /etc; do
fi
done

# Check if "${real_APT}" exists
if [ '!' -x "${real_APT}" ]; then
msg "We use ${real_APT} in case ${_APTMGR} doesn't work, but it doesn't exist!" 'warning'
exit 1
fi

# no proxy as default
ftp_proxy=
http_proxy=
Expand Down Expand Up @@ -321,11 +330,12 @@ get_uris(){

# Add header to overwrite file.
echo "# apt-fast mirror list: $(date)" > "$DLLIST"
#NOTE: aptitude doesn't have this functionality, so we use apt-get to get
# package URIs.
case "$_APTMGR" in
apt|apt-get) uri_mgr=$_APTMGR;;
*) uri_mgr=apt-get;;
# NOTE: "aptitude" doesn't have this functionality
# so we use either "${_APTMGR}" or "${real_APT}"
# to get package URI's
case "$(basename "${_APTMGR}")" in
'apt'|'apt-get') uri_mgr="${_APTMGR}";;
*) uri_mgr="${real_APT}";;
esac
uris_full="$("$uri_mgr" "${APT_SCRIPT_WARNING[@]}" -y --print-uris "$@")"
CLEANUP_STATE="$?"
Expand Down Expand Up @@ -463,7 +473,7 @@ fi

# Disable script warning if apt is used.
APT_SCRIPT_WARNING=()
if [ "$_APTMGR" == "apt" ]; then
if [ "$(basename "${_APTMGR}")" == 'apt' ]; then
APT_SCRIPT_WARNING=(-o "Apt::Cmd::Disable-Script-Warning=true")
fi

Expand Down Expand Up @@ -601,7 +611,7 @@ if [ "$option" == "install" ]; then
fi

# different problem resolving for aptitude
if [ -z "$DOWNLOAD_ONLY" ] || [ "$_APTMGR" == "aptitude" ]; then
if [ -z "$DOWNLOAD_ONLY" ] || [ "$(basename "${_APTMGR}")" == 'aptitude' ]; then
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"
fi

Expand Down Expand Up @@ -630,7 +640,7 @@ elif [ "$option" == "download" ]; then
fi

# different problem resolving for aptitude
if [ "$_APTMGR" == "aptitude" ]; then
if [ "$(basename "${_APTMGR}")" == 'aptitude' ]; then
"${_APTMGR}" "$@"
fi

Expand Down