This file is indexed.

/usr/sbin/upgrade-system is in upgrade-system 1.7.3.0.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/sh
# coding: utf-8
#
## UPGRADE-SYSTEM -- Command for upgrading and sanitizing a Debian system.
#
## HOMEPAGE
#  http://q-funk.iki.fi/debian
#
## AUTHORS
#  Copyright © 2004-2014 Martin-Éric Racine <martin-eric.racine@iki.fi>
#  Copyright © 2004,2012 Christoph Schindler <hop@30hopsmax.at>
#  Copyright © 2003-2004 Martin Zdrahal <martin.zdrahal@konflux.at>
#
## LICENSE
#  GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
#
## DEPENDENCIES
#D:apt:apt-get (main/important) (>= 0.6.45: autoclean)(>= 0.7.0: --fix-policy).
#S:command-not-found:update-command-not-found (main/optional).
#  coreutils:cut,rm,sort,tty (main/required).
#D:deborphan:deborphan (universe/optional) (>= 1.7: --libdevel).
#R:debsums:debsums (universe/optional).
#  dpkg:dpkg,dpkg-query (main/required).
#  findutils:find (main/required).
#  grep:grep (main/required).
#  mawk:awk (main/required).
#  ncurses-bin:tput (main/required).
#  util-linux:setterm (main/required).
#
## CHANGES
#  2014-08-03   List DPKG config backups.       v1.7 [MER]
#  2012-03-10   Make all APT checks quiet.      v1.6 [MER]
#  2012-03-06   Add autoremove to orphan purge. v1.5 [CS]
#  2011-12-21   Add APT --fix-policy install.   v1.5 [MER]
#  2011-03-03   Add debsum reinstallation.      v1.4 [MER]
#  2010-05-02   Add crude prompt colorization.  v1.3 [MER]
#  2009-08-08   Add obsolete config purge.      v1.2 [MER]
#  2009-06-21   Add uninstalled packages purge. v1.1 [MER]
#  2005-12-04   Use APT instead of DPKG purge.  v1.0 [MER]
#  2005-05-29   Add non-interactive detection.  v0.9 [MER]
#  2004-09-04   Make orphan purge recursive.    v0.8 [CS]
#  2004-08-19   Add APT exit code check.        v0.7 [MER]
#  2004-06-07   Add CLEANOPTS to config.        v0.6 [MER]
#  2004-03-31   Create config file.             v0.5 [MER]
#  2004-03-24   Add -y to dist-upgrade.         v0.4 [MER]
#  2004-03-15   Add --guess-doc --libdevel.     v0.3 [MER]
#  2004-03-09   Rename to upgrade-system.       v0.2 [MER]
#  2004-02-16   Initial release.                v0.1 [MZ]
##
#########################################
### INSERT EVENTUAL LOCALISATION HERE ###
#########################################
DISPLAY=
LANGUAGE=
LC_ALL=C
TEXTDOMAIN=upgrade-system
export DISPLAY LANGUAGE LC_ALL TEXTDOMAIN
###########################################################
### SOURCE CONFIGURED OPTIONS AND SET FALLBACK DEFAULTS ###
###########################################################
if [ -f /etc/upgrade-system.conf ]
then
	. /etc/upgrade-system.conf
fi
: ${CLEANOPTS:="clean"}
: ${UPGRADEOPTS:="--fix-broken --purge --show-upgraded dist-upgrade"}
: ${ORPHANOPTS:="--guess-all --libdevel"}
: ${FLAUSCH:=""}
########################
### SET SHELL COLORS ###
########################
BOLD=$(setterm -bold on)
RESET=$(setterm -default)
##DEPENDS: util-linux (main/required).
if [ -x /usr/bin/tput ] && tput setaf 1 >/dev/null 2>&1;
then
	RED=${BOLD}$(tput setaf 1)
	GREEN=${BOLD}$(tput setaf 2)
	YELLOW=${BOLD}$(tput setaf 3)
else
	RED=${BOLD}
	GREEN=${BOLD}
	YELLOW=${BOLD}
fi
##DEPENDS: ncurses-bin (main/required).
############################
### SET DEBCONF FRONTEND ###
############################
tty --silent
##DEPENDS: coreutils (main/required).
if [ $? != 0 ]
then
	echo "${GREEN}N: Non-Interactive upgrade selected.${RESET}"
	NOTTY="--option DPkg::Options::=--force-confdef --quiet --yes"
	DEBIAN_FRONTEND="noninteractive"
	export DEBIAN_FRONTEND
fi
############################
### UPDATE PACKAGE LISTS ###
############################
echo "${BOLD}1) Updating package lists:${RESET}"
apt-get $NOTTY --quiet --quiet update
##DEPENDS: apt (main/important).
if [ $? != 0 ]
then
	echo "${RED}E: Some package lists could not be updated.${RESET}"
	exit 1
else
	echo "I: Package lists updated."
fi
########################
### UPGRADE PACKAGES ###
########################
echo "${BOLD}2) Checking for upgradable packages:${RESET}"
UPGRADABLE=$(apt-get $NOTTY --simulate $UPGRADEOPTS | awk '/^Inst / {print $2}')
##DEPENDS: apt (main/important), mawk (main/required).
case $UPGRADABLE in
	"")
		echo "I: No upgradable package to install."
		break
		;;
	*)
		echo  "I: Installing upgradable packages..."
		apt-get $NOTTY $UPGRADEOPTS
		##DEPENDS: apt (main/important).
		if [ $? != 0 ]
		then
			echo "${RED}E: Some packages could not be upgraded.${RESET}"
			exit 2
		fi
		;;
esac
#############################
### PURGE ORPHAN PACKAGES ###
#############################
echo "${BOLD}3) Checking for orphan packages:${RESET}"
REMOVABLE=$(apt-get $NOTTY --purge --simulate autoremove | awk '/^Purg / {print $2}')
##DEPENDS: apt (main/important), mawk (main/required).
# deborphan kludge (Debian #672829 and Ubuntu LP #940374).
while [ "${DEBORPHANS-undef}" != "$DEBORPHANS_OLD" ]
do
	DEBORPHANS_OLD=$DEBORPHANS
	DEBORPHANS=$(deborphan $ORPHANOPTS)
	if [ $? != 0 ]
	then
		echo "${RED}E: Checking failed unexpectedly. Run 'dpkg --configure --pending' as root.${RESET}"
		exit 3
	fi
	##DEPENDS: deborphan (universe/optional).
	ORPHANS=${REMOVABLE:+$REMOVABLE }$DEBORPHANS
	REMOVABLE=""
	case $ORPHANS in
		"")
			echo "I: No orphan package to purge."
			break
			;;
		*)
			echo "I: Purging orphan packages..."
			apt-get $NOTTY --purge autoremove $ORPHANS
			##DEPENDS: apt (main/important).
			### Escape dangerous purges automatically.
			if [ $? != 0 ]
			then
			        break
			fi
			;;
	esac
done
####################################################################
### FLAUSCH'S SUPER CRUFT LIQUIDATOR -- USE WITH EXTREME CAUTION ###
####################################################################
# Enabled whenever the FLAUSCH environment variable is set anywhere.
case $FLAUSCH in
	"")
		break
		;;
	*)
		echo "${YELLOW}W: FLAUSCH LOOP ENABLED. USE WITH EXTREME CAUTION!${RESET}"
		###############################################
		### REINSTALL PACKAGES WITH MISSING DEBSUMS ###
		###############################################
		if [ -x /usr/bin/debsums ]
		then
			echo "${BOLD}Checking for packages with missing debsums:${RESET}"
			while true
			do
				DEBSUM=$(dpkg-query --search 2>/dev/null $(debsums --list-missing --silent) | cut --delimiter : --fields 1 | uniq)
				##DEPENDS: dpkg (main/required), debsums (universe/optional), coreutils (main/required).
				case $DEBSUM in
					"")
						echo "I: No package with missing debsums to reinstall."
						break
						;;
					*)
						echo "I: Reinstalling packages with missing debsums..."
						apt-get $NOTTY --reinstall install $DEBSUM
						##DEPENDS: apt (main/important).
						### Escape dangerous purges automatically.
						if [ $? != 0 ]
						then
			        			break
						fi
						;;
				esac
			done
		fi
		############################################
		### FIX DEPENDENCIES TO MATCH APT POLICY ###
		############################################
		echo "${BOLD}Checking for missing dependencies:${RESET}"
		FIXABLE=$(apt-get $NOTTY --auto-remove --fix-policy --purge --simulate install | awk '/^Inst / {print $2}')
		##DEPENDS: apt (main/important), mawk (main/required).
		case $FIXABLE in
			"")
				echo "I: No missing dependency to install."
				break
				;;
			*)
				echo  "I: Installing missing dependencies..."
				apt-get $NOTTY --auto-remove --fix-policy --purge --option Debug::pkgDepCache::AutoInstall=true install
				##DEPENDS: apt (main/important).
				if [ $? != 0 ]
				then
					echo "${RED}E: Some dependencies could not be installed.${RESET}"
					exit 4
				fi
				;;
		esac
		##################################
		### PURGE UNINSTALLED PACKAGES ###
		##################################
		echo "${BOLD}Checking for uninstalled packages:${RESET}"
		while true
		do
			ORPHANS=$(dpkg-query --list | grep '^rc' | awk '{print $2}')
			##DEPENDS: dpkg (main/required), grep (main/required), mawk (main/required).
			case $ORPHANS in
				"")
					echo "I: No uninstalled package to purge."
					break
					;;
				*)
					echo "I: Purging uninstalled packages..."
					dpkg --purge $ORPHANS
					##DEPENDS: dpkg (main/required).
					### Escape dangerous purges automatically.
					if [ $? != 0 ]
					then
			        		break
					fi
					;;
			esac
		done
		###############################
		### REMOVE OBSOLETE CONFIGS ###
		###############################
		echo "${BOLD}Checking for obsolete configurations:${RESET}"
		ORPHANS=$(dpkg-query --show --showformat='${Conffiles}\n' | grep obsolete | awk '{print $1}')
		##DEPENDS: dpkg (main/required), grep (main/required), mawk (main/required).
		case $ORPHANS in
			"")
				echo "I: No obsolete configuration to purge."
				break
				;;
			*)
				echo "I: Removing obsolete configurations..."
				unique(){
					dpkg-query --search $ORPHANS | cut --delimiter : --fields 1 | uniq
					##DEPENDS: dpkg (main/required), coreutils (main/required), coreutils (main/required).
					}
				UNIQUE=$(unique)
				NUMBER=$(unique | wc --lines)
				echo "I: Number of packages affected: $NUMBER."
				dpkg-query --search $ORPHANS
				##DEPENDS: dpkg (main/required).
				echo "${YELLOW}W: BEWARE OF FALSE POSITIVES! DELETE WITH EXTREME CAUTION!${RESET}"
				rm --interactive $ORPHANS
				##DEPENDS: coreutils (main/required).
				apt-get $NOTTY --reinstall install ${UNIQUE}
				##DEPENDS: apt (main/important).
				### Escape dangerous purges automatically.
				if [ $? != 0 ]
				then
				        break
				fi
				;;
		esac
		#####################################################
		### LIST CONFIGS THAT REQUIRE MANUAL INTERVENTION ###
		#####################################################
		echo "${BOLD}Checking for configuration backups:${RESET}"
		ORPHANS=$(find /etc/ -name '*.dpkg-*')
		##DEPENDS: findutils (main/required), grep (main/required).
		case $ORPHANS in
			"")
				echo "I: No configuration backup to examine."
				break
				;;
			*)
				echo "I: Configuration backups to examine:"
				if [ -n "$(echo $ORPHANS | grep bak)" ]
				then
					echo "Backups of obsolete configurations:"
					find /etc/ -name '*.dpkg-bak' | sort
				fi
				if [ -n "$(echo $ORPHANS | grep old)" ]
				then
					echo "Backups of relevant configurations:"
					find /etc/ -name '*.dpkg-old' | sort
				fi
				if [ -n "$(echo $ORPHANS | grep dist)" ]
				then
					echo "Backups of upstream configurations:"
					find /etc/ -name '*.dpkg-dist' | sort
				fi
				;;
		esac
		####################################################################
		echo "${GREEN}N: FLAUSCH LOOP COMPLETED.${RESET}"
esac
####################################################################
#######################
### CLEAN APT CACHE ###
#######################
echo "${BOLD}4) Cleaning package cache.${RESET}"
apt-get $NOTTY $CLEANOPTS
##DEPENDS: apt (main/important).
echo "I: System upgrade completed."
#EOF