- local x=$(mktemp -d)/f # safe way to get file name without creating one
- sudo netselect-apt -o "$x" || return 1
- x=$(_debian_pick_mirror_grep stable "$x")
+ # netselect-apt finds a fast mirror.
+ # but we need to replace the mirrors ourselves,
+ # because it doesn't do that. best it can do is
+ # output a basic sources file
+ # here we get the server it found, get the main server we use
+ # then substitute all instances of one for the other in the sources file
+ # and backup original to /etc/apt/sources.list-original.
+ # this is idempotent. the only way to identify debian sources is to
+ # note the original server, so we put it in a comment so we can
+ # identify it later.
+ local file=$(mktemp -d)/f # safe way to get file name without creating one
+ sudo netselect-apt -o "$file" || return 1
+ url=$(grep ^\\w $file | head -n1 | awk '{print $2}')