View | Details | Raw Unified | Return to bug 7229
Collapse All | Expand All

(-)univention-actualise (-47 / +44 lines)
 Lines 35-40    Link Here 
35
35
36
import univention.config_registry as ucr
36
import univention.config_registry as ucr
37
37
38
LOGNAME = '/var/log/univention/actualise.log'
39
38
configRegistry = ucr.ConfigRegistry()
40
configRegistry = ucr.ConfigRegistry()
39
configRegistry.load()
41
configRegistry.load()
40
42
 Lines 64-70    Link Here 
64
			if self.filter:
66
			if self.filter:
65
				tee = subprocess.Popen( tee_command, stdin = p.stdout, stdout = subprocess.PIPE, stderr = subprocess.STDOUT )
67
				tee = subprocess.Popen( tee_command, stdin = p.stdout, stdout = subprocess.PIPE, stderr = subprocess.STDOUT )
66
				egrep = subprocess.Popen( [ 'egrep', self.filter ], stdin = tee.stdout )
68
				egrep = subprocess.Popen( [ 'egrep', self.filter ], stdin = tee.stdout )
67
				return egrep.wait()
69
				ret = egrep.wait()
68
			else:
70
			else:
69
				tee = subprocess.Popen( tee_command, stdin = p.stdout )
71
				tee = subprocess.Popen( tee_command, stdin = p.stdout )
70
		else:
72
		else:
 Lines 72-78    Link Here 
72
			tee = subprocess.Popen( tee_command, stdin = p.stdout, stdout = devnull )
74
			tee = subprocess.Popen( tee_command, stdin = p.stdout, stdout = devnull )
73
			devnull.close()
75
			devnull.close()
74
76
77
		# Must wait for exit from back to front, only the exit status of p is relevant
75
		ret = tee.wait()
78
		ret = tee.wait()
79
		ret = p.wait()
76
		if devnull:
80
		if devnull:
77
			devnull.close()
81
			devnull.close()
78
82
 Lines 110-116    Link Here 
110
	print "Running apt-get update"
114
	print "Running apt-get update"
111
	waitForLock()
115
	waitForLock()
112
	createLock()
116
	createLock()
113
	logfile = open( '/var/log/univention/actualise.log', 'a' )
117
	logfile = open( LOGNAME, 'a' )
114
	res = subprocess.call( cmd_update.split( ' ' ), stdout = logfile, stderr = logfile )
118
	res = subprocess.call( cmd_update.split( ' ' ), stdout = logfile, stderr = logfile )
115
	logfile.close()
119
	logfile.close()
116
	if os.path.exists('/var/run/apt-get.lock'):
120
	if os.path.exists('/var/run/apt-get.lock'):
 Lines 138-144    Link Here 
138
		f.write( '\n'.join( lines ) )
142
		f.write( '\n'.join( lines ) )
139
		f.write( '\n' )
143
		f.write( '\n' )
140
		f.close()
144
		f.close()
141
		debug_file=open('/var/log/univention/actualise.log', 'a+')
145
		debug_file=open(LOGNAME, 'a+')
142
		debug_file.write('Hint: deactivated %d lines in /etc/apt/sources.list:\n' % cnt)
146
		debug_file.write('Hint: deactivated %d lines in /etc/apt/sources.list:\n' % cnt)
143
		debug_file.write( '   %s\n' % '\n   '.join(deactivated_lines) )
147
		debug_file.write( '   %s\n' % '\n   '.join(deactivated_lines) )
144
		debug_file.close()
148
		debug_file.close()
 Lines 241-290    Link Here 
241
	dist_upgrade = False
245
	dist_upgrade = False
242
	check_only = False
246
	check_only = False
243
247
244
	try:
248
	# parse arguments
245
		if configRegistry.has_key('ldap/hostdn') and configRegistry['ldap/hostdn']:
249
	for arg in sys.argv[1:]:
250
		if arg == "--silent":
251
			silent = True
252
		elif arg == "-?" or arg=="--help":
253
			print_usage = True
254
		elif arg == "--dist-upgrade":
255
			dist_upgrade = True
256
		elif arg == '--check':
257
			check_only = True
258
		else:
259
			# unknown parameter
260
			print_usage=True
246
261
247
			# parse arguments
262
	if print_usage:
248
			for arg in sys.argv[1:]:
263
		usage()
249
				if arg == "--silent":
264
		sys.exit(0)
250
					silent = True
251
				elif arg == "-?" or arg=="--help":
252
					print_usage = True
253
				elif arg == "--dist-upgrade":
254
					dist_upgrade = True
255
				elif arg == '--check':
256
					check_only = True
257
				else:
258
					# unknown parameter
259
					print_usage=True
260
265
261
			if print_usage:
266
	if silent:
262
				usage()
267
		# redirect stdout to /dev/null
263
				sys.exit(0)
268
		sys.stdout = open("/dev/null", "w")
264
269
265
			if silent:
270
	try:
266
				# redirect stdout to /dev/null
271
		if check_only:
267
				sys.stdout = open("/dev/null", "w")
272
			# Only probe for packages to add/remove
273
			res=check(configRegistry, dist_upgrade)
274
			sys.exit(res)
268
275
269
			if check_only:
276
		if configRegistry.has_key('ldap/hostdn') and configRegistry['ldap/hostdn']:
270
				# Only probe for packages to add/remove
277
			logfile = open( LOGNAME, 'a' )
271
				res=check(configRegistry, dist_upgrade)
272
				sys.exit(res)
273
274
275
			logfile = open( '/var/log/univention/actualise.log', 'a' )
276
			logfile.write('***** Starting univention-actualise at %s\n' % time.ctime())
278
			logfile.write('***** Starting univention-actualise at %s\n' % time.ctime())
277
279
278
			deactivateSourcesListMethods( methods = [ 'cdrom' ] )
280
			deactivateSourcesListMethods( methods = [ 'cdrom' ] )
279
281
280
			getUpdate( configRegistry )
282
			getUpdate( configRegistry )
281
283
284
			# temporarily disable pkgdb
282
			if configRegistry.has_key('pkgdb/scan') and configRegistry['pkgdb/scan']:
285
			if configRegistry.has_key('pkgdb/scan') and configRegistry['pkgdb/scan']:
283
				pkgdb=configRegistry['pkgdb/scan']
286
				pkgdb=configRegistry['pkgdb/scan']
287
				if pkgdb:
288
					ucr.handler_set(['pkgdb/scan=no'])
284
289
285
			if pkgdb:
286
				ucr.handler_set(['pkgdb/scan=no'])
287
288
			rem_packages=getPackageList(configRegistry, 'remove')
290
			rem_packages=getPackageList(configRegistry, 'remove')
289
			for package in rem_packages:
291
			for package in rem_packages:
290
				waitForLock()
292
				waitForLock()
 Lines 305-312    Link Here 
305
					os.unlink('/var/run/apt-get.lock')
307
					os.unlink('/var/run/apt-get.lock')
306
				if res != 0:
308
				if res != 0:
307
					print >>sys.stderr, "E: failed to remove %s" % package
309
					print >>sys.stderr, "E: failed to remove %s" % package
308
					if pkgdb:
309
						ucr.handler_set(['pkgdb/scan=%s' % pkgdb])
310
					sys.exit(res)
310
					sys.exit(res)
311
311
312
312
 Lines 329-336    Link Here 
329
					os.unlink('/var/run/apt-get.lock')
329
					os.unlink('/var/run/apt-get.lock')
330
				if res != 0:
330
				if res != 0:
331
					print >>sys.stderr, "E: failed to install %s" % package
331
					print >>sys.stderr, "E: failed to install %s" % package
332
					if pkgdb:
333
						ucr.handler_set(['pkgdb/scan=%s' % pkgdb])
334
					sys.exit(res)
332
					sys.exit(res)
335
333
336
			waitForLock()
334
			waitForLock()
 Lines 352-372    Link Here 
352
350
353
		createLock()
351
		createLock()
354
		os.environ[ 'DEBIAN_FRONTEND' ] = 'noninteractive'
352
		os.environ[ 'DEBIAN_FRONTEND' ] = 'noninteractive'
355
		tee = Tee( [ '/var/log/univention/actualise.log' ], stdout = not silent  )
353
		tee = Tee( [ LOGNAME ], stdout = not silent  )
356
		res = tee.call( cmd_config.split( ' ' ) )
354
		res = tee.call( cmd_config.split( ' ' ) )
357
		if res == 0:
355
		if res != 0:
358
			tee = Tee( [ '/var/log/univention/actualise.log' ], stdout = not silent, filter = '(^Get|^Unpacking|^Preparing|^Setting up|packages upgraded)' )
356
			print >>sys.stderr, "E: failed to configure packets, see %s for details." % LOGNAME
357
		else:
358
			tee = Tee( [ LOGNAME ], stdout = not silent, filter = '(^Get|^Unpacking|^Preparing|^Setting up|packages upgraded)' )
359
			res = tee.call( cmd.split( ' ' ) )
359
			res = tee.call( cmd.split( ' ' ) )
360
			if res != 0:
361
				print >>sys.stderr, "E: failed to upgrade, see %s for details." % LOGNAME
360
362
361
		if os.path.exists('/var/run/apt-get.lock'):
363
		if os.path.exists('/var/run/apt-get.lock'):
362
			os.unlink('/var/run/apt-get.lock')
364
			os.unlink('/var/run/apt-get.lock')
363
365
364
		if configRegistry.has_key('ldap/hostdn') and configRegistry['ldap/hostdn']:
366
		sys.exit(res)
365
			if res != 0:
366
				print >>sys.stderr, "E: failed to upgrade"
367
				if pkgdb:
368
					ucr.handler_set(['pkgdb/scan=%s' % pkgdb])
369
				sys.exit(res)
370
367
371
	finally:
368
	finally:
372
		if pkgdb:
369
		if pkgdb:

Return to bug 7229