596
597
log.info("Installing local package file: %s", path)
597
598
# Check if the dpkg can be installed at all
598
599
trans.status = STATUS_RESOLVING_DEP
599
deb = self._check_deb_file(path, force, trans.uid)
600
deb = self._check_deb_file(trans, path, force)
600
601
# Check for required changes and apply them before
601
602
(install, remove, unauth) = deb.required_changes
602
603
self._call_plugins("modify_cache_after")
1173
1174
return depends, required_download, required_space, unauthenticated
1175
def _check_deb_file(self, path, force, uid):
1176
def _check_deb_file(self, trans, path, force):
1176
1177
"""Perform some basic checks for the Debian package.
1178
1179
:param trans: The transaction instance.
1180
1181
:returns: An apt.debfile.Debfile instance.
1182
#FIXME: Unblock lintian call
1183
1183
if not os.path.isfile(path):
1184
1184
raise TransactionFailed(ERROR_UNREADABLE_PACKAGE_FILE, path)
1185
1185
if not force and os.path.isfile("/usr/bin/lintian"):
1186
tags_dir = os.path.join(apt_pkg.config.find_dir("Dir"),
1187
"usr", "share", "aptdaemon")
1189
distro = platform.dist()[0]
1193
tags_file = os.path.join(tags_dir,
1194
"lintian-nonfatal.tags.%s" % distro)
1195
tags_fatal_file = os.path.join(tags_dir,
1196
"lintian-fatal.tags.%s" % distro)
1197
if not distro or not os.path.exists(tags_file):
1198
log.debug("Using default lintian tags file")
1199
tags_file = os.path.join(tags_dir, "lintian-nonfatal.tags")
1200
if not distro or not os.path.exists(tags_fatal_file):
1201
log.debug("Using default lintian fatal tags file")
1202
tags_fatal_file = os.path.join(tags_dir, "lintian-fatal.tags")
1203
# Run linitan as the user who initiated the transaction
1204
# Once with non fatal checks and a second time with the fatal
1205
# checks which are not allowed to be overriden
1206
nonfatal_args = ["/usr/bin/lintian", "--tags-from-file",
1208
fatal_args = ["/usr/bin/lintian", "--tags-from-file",
1209
tags_fatal_file, "--no-override", path]
1210
for lintian_args in (nonfatal_args, fatal_args):
1211
proc = subprocess.Popen(lintian_args,
1212
stderr=subprocess.STDOUT,
1213
stdout=subprocess.PIPE, close_fds=True,
1214
preexec_fn=lambda: os.setuid(uid))
1215
while proc.poll() is None:
1216
self._iterate_mainloop()
1218
#FIXME: Add an error to catch return state 2 (failure)
1219
if proc.returncode == 1:
1220
stdout = proc.stdout.read()
1221
stdout.decode(sys.stdin.encoding or "UTF-8",
1223
raise TransactionFailed(ERROR_INVALID_PACKAGE_FILE,
1224
"Lintian check results for %s:"
1225
"\n%s" % (path, stdout))
1186
with DaemonLintianProgress(trans) as progress:
1188
#FIXME: Add an error to catch return state 2 (failure)
1189
if progress._child_exit != 0:
1190
raise TransactionFailed(ERROR_INVALID_PACKAGE_FILE,
1191
"Lintian check results for %s:"
1192
"\n%s" % (path, progress.output))
1227
1194
deb = apt.debfile.DebPackage(path, self._cache)
1228
1195
except IOError: