diff --git a/apt-fast b/apt-fast index 83cdc78..5006422 100755 --- a/apt-fast +++ b/apt-fast @@ -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= @@ -118,7 +121,8 @@ 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)" @@ -168,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= @@ -321,10 +331,11 @@ get_uris(){ # Add header to overwrite file. echo "# apt-fast mirror list: $(date)" > "$DLLIST" # NOTE: "aptitude" doesn't have this functionality - # so we use "${_APTMGR}" to get package URI's + # 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='apt-get';; + *) uri_mgr="${real_APT}";; esac uris_full="$("$uri_mgr" "${APT_SCRIPT_WARNING[@]}" -y --print-uris "$@")" CLEANUP_STATE="$?"