summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-05-16 22:27:59 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-05-16 22:27:59 +0200
commit554dc681d36b7e1cb306eb8d7ce5958a87dfc397 (patch)
treefe348cebc150dc98d3a5714ea3ff2e10eb4c7570 /src/plugins
parent5de5702c52cab8b0684ed4dc4df01f09657f9527 (diff)
downloadabrt-554dc681d36b7e1cb306eb8d7ce5958a87dfc397.tar.gz
abrt-554dc681d36b7e1cb306eb8d7ce5958a87dfc397.tar.xz
abrt-554dc681d36b7e1cb306eb8d7ce5958a87dfc397.zip
abrt-action-install-debuginfo: support --ids=- (read from stdin)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/abrt-action-install-debuginfo.c7
-rwxr-xr-xsrc/plugins/abrt-action-install-debuginfo.py33
2 files changed, 25 insertions, 15 deletions
diff --git a/src/plugins/abrt-action-install-debuginfo.c b/src/plugins/abrt-action-install-debuginfo.c
index 112620b4..0d5d0d9d 100644
--- a/src/plugins/abrt-action-install-debuginfo.c
+++ b/src/plugins/abrt-action-install-debuginfo.c
@@ -45,13 +45,18 @@ static void error_msg_and_die(const char *msg, const char *arg)
int main(int argc, char **argv)
{
/*
- * We disallow passing of arguments which point to writable dirs.
+ * We disallow passing of arguments which point to writable dirs
+ * and other files possibly not accessible to calling user.
* This way, the script will always use default values for these arguments.
*/
char **pp = argv;
char *arg;
while ((arg = *++pp) != NULL)
{
+ /* Allow taking ids from stdin */
+ if (strcmp(arg, "--ids=-") == 0)
+ continue;
+
if (strncmp(arg, "--cache", 7) == 0)
error_msg_and_die("bad option", arg);
if (strncmp(arg, "--tmpdir", 8) == 0)
diff --git a/src/plugins/abrt-action-install-debuginfo.py b/src/plugins/abrt-action-install-debuginfo.py
index e15fc12b..1a697744 100755
--- a/src/plugins/abrt-action-install-debuginfo.py
+++ b/src/plugins/abrt-action-install-debuginfo.py
@@ -5,12 +5,13 @@
PROGNAME = "abrt-action-install-debuginfo.py"
-from subprocess import Popen, PIPE
import sys
import os
+import errno
import time
import getopt
import shutil
+from subprocess import Popen, PIPE
from yum import _, YumBase
from yum.callbacks import DownloadBaseCallback
@@ -315,8 +316,8 @@ class DebugInfoDownload(YumBase):
else:
# normalize the name
# just str(pkg) doesn't work because it can have epoch
- pkg_nvra = (pkg.name +"-"+ pkg.version +"-"+
- pkg.release +"."+ pkg.arch)
+ pkg_nvra = (pkg.name + "-" + pkg.version + "-" +
+ pkg.release + "." + pkg.arch)
unpack_result = unpack_rpm(pkg_nvra, files, self.tmpdir,
self.cachedir, keeprpms)
@@ -334,7 +335,7 @@ class DebugInfoDownload(YumBase):
try:
os.rmdir(self.tmpdir)
except OSError:
- print _("Can't remove %s, probably contains an error log") % self.tmpdir
+ error_msg(_("Can't remove %s, probably contains an error log"), self.tmpdir)
def build_ids_to_path(build_ids):
"""
@@ -365,10 +366,12 @@ def filter_installed_debuginfos(build_ids, cache_dir):
tmpdir = None
def clean_up():
- try:
- shutil.rmtree(tmpdir)
- except OSError, ex:
- print _("Can't remove '%s': %s") % (tmpdir, ex)
+ if tmpdir:
+ try:
+ shutil.rmtree(tmpdir)
+ except OSError, ex:
+ if ex.errno != errno.ENOENT:
+ error_msg(_("Can't remove '%s': %s"), tmpdir, ex)
def sigterm_handler(signum, frame):
clean_up()
@@ -377,7 +380,8 @@ def sigterm_handler(signum, frame):
def sigint_handler(signum, frame):
clean_up()
print "\n", _("Exiting on user command")
- exit(RETURN_OK)
+ # ??! without "sys.", I am getting segv!
+ sys.exit(RETURN_OK)
import signal
@@ -460,11 +464,12 @@ if __name__ == "__main__":
# for now, we use /tmp...
tmpdir = "/tmp/abrt-tmp-debuginfo-%s.%u" % (time.strftime("%Y-%m-%d-%H:%M:%S"), os.getpid())
- try:
- fin = open(fbuild_ids, "r")
- except IOError, ex:
- print _("Can't open %s: %s" % (fbuild_ids, ex))
- exit(RETURN_FAILURE)
+ fin = sys.stdin
+ if fbuild_ids != "-":
+ try:
+ fin = open(fbuild_ids, "r")
+ except IOError, ex:
+ error_msg_and_die(_("Can't open %s: %s"), fbuild_ids, ex)
for line in fin.readlines():
b_ids.append(line.strip('\n'))