Exit proper error message when apt-get is failing (Closes: #714964)
Javier Fernandez-Sanguino
8 years ago
31 | 31 | # Version of debmany |
32 | 32 | version=1.5 |
33 | 33 | |
34 | errormsg() | |
35 | { | |
36 | # show message | |
37 | echo "ERROR: $*" >&2 | |
38 | if [ "$cmd" = "zenity" ] | |
39 | then | |
40 | $cmd --error --text="$*" | |
41 | fi | |
42 | } | |
43 | ||
34 | 44 | error() |
35 | 45 | { |
36 | 46 | # show errorcode and quit |
37 | echo "ERROR: $*" >&2 | |
38 | if [ "$cmd" = "zenity" ] | |
39 | then | |
40 | $cmd --error --text="$*" | |
41 | fi | |
47 | errormsg $* | |
42 | 48 | exit 1 |
43 | 49 | } |
44 | 50 | |
242 | 248 | |
243 | 249 | if [ -z "$file" ] |
244 | 250 | then |
245 | debug "Mode3: Determining the path of '$package'" # comment | |
251 | debug "Mode3: Determining the path of '$package' using 'apt-get -q2 --print-uris --reinstall install'" # comment | |
246 | 252 | aptdata=`apt-get -q2 --print-uris --reinstall install "$package" 2>/dev/null | grep "$package"_` |
247 | 253 | if [ -z "$aptdata" ] |
248 | 254 | then |
249 | error "There is no package called '$package'." | |
255 | errormsg "There was an error looking for package '$package'." | |
256 | apt-get -q2 --print-uris --reinstall install "dpkg" 2>&1 >/dev/null | |
257 | if [ $? -eq 0 ] ; then | |
258 | error "The package does not exist." | |
259 | else | |
260 | error "Apt-get might not be working properly Possible failure when running 'apt-get -q2 --print-uris --reinstall install \"$package\"'" | |
261 | fi | |
262 | # Note: We do not get here, error() exits before | |
250 | 263 | exit 1 |
251 | 264 | fi |
252 | 265 |