diff options
author | rbuj <[email protected]> | 2020-01-01 23:39:04 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-01-04 13:29:35 +0100 |
commit | 4deb89e7fa95e8abffb86f517878a9bc0d30b7bc (patch) | |
tree | f67633477c1d14b05c8918687607bee296933973 | |
parent | f0805f3afe61c035cc3477cba880322c15e95766 (diff) | |
download | engrampa-4deb89e7fa95e8abffb86f517878a9bc0d30b7bc.tar.bz2 engrampa-4deb89e7fa95e8abffb86f517878a9bc0d30b7bc.tar.xz |
fr-command-rpm: Use rpm2cpio binary shipped with rpm package
closes #350
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/commands/Makefile.am | 12 | ||||
-rw-r--r-- | src/commands/rpm2cpio.c | 134 | ||||
-rw-r--r-- | src/fr-command-rpm.c | 11 | ||||
-rw-r--r-- | src/fr-process.c | 4 |
7 files changed, 9 insertions, 159 deletions
diff --git a/configure.ac b/configure.ac index 84ab58a..505f880 100644 --- a/configure.ac +++ b/configure.ac @@ -182,7 +182,6 @@ AC_CONFIG_FILES([Makefile data/icons/Makefile copy-n-paste/Makefile src/Makefile - src/commands/Makefile src/sh/Makefile src/ui/Makefile caja/Makefile diff --git a/po/POTFILES.in b/po/POTFILES.in index 9ea5328..6224e54 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -15,7 +15,6 @@ caja/caja-engrampa.h caja/libcaja-engrampa.caja-extension.desktop.in.in src/actions.c src/actions.h -src/commands/rpm2cpio.c src/dlg-add-files.c src/dlg-add-files.h src/dlg-add-folder.c diff --git a/src/Makefile.am b/src/Makefile.am index 576c803..43cb092 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ NULL = -SUBDIRS = commands sh ui +SUBDIRS = sh ui bin_PROGRAMS = engrampa libexec_PROGRAMS = engrampa-server @@ -8,11 +8,9 @@ noinst_PROGRAMS = test-server if RUN_IN_PLACE privdatadir = $(top_srcdir)/data/ -privexecdir = $(abs_top_builddir)/src/commands/ shdir = $(top_srcdir)/src/sh/ else privdatadir = $(datadir)/engrampa/ -privexecdir = $(libexecdir)/engrampa/ shdir = $(libexecdir)/engrampa/ endif @@ -29,7 +27,6 @@ AM_CPPFLAGS = \ -DPKG_DATA_DIR=\"$(pkgdatadir)\" \ -DPIXMAPSDIR=\""$(datadir)/pixmaps"\" \ -DGLADEDIR=\""$(gladedir)"\" \ - -DPRIVEXECDIR=\"$(privexecdir)\" \ -DLOCALEDIR=\""$(datadir)/locale"\" \ -DSHDIR=\"$(shdir)\" \ $(FR_CFLAGS) \ diff --git a/src/commands/Makefile.am b/src/commands/Makefile.am deleted file mode 100644 index d423737..0000000 --- a/src/commands/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -NULL = - -privexecdir = $(libexecdir)/$(PACKAGE) -privexec_PROGRAMS = rpm2cpio - -AM_CPPFLAGS = \ - $(FR_CFLAGS) \ - $(WARN_CFLAGS) \ - $(NULL) - -rpm2cpio_SOURCES = rpm2cpio.c -rpm2cpio_LDADD = $(FR_LIBS) diff --git a/src/commands/rpm2cpio.c b/src/commands/rpm2cpio.c deleted file mode 100644 index bdadb3d..0000000 --- a/src/commands/rpm2cpio.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * File-Roller - * - * Copyright (C) 2001 The Free Software Foundation, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <config.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <glib.h> - - -static const char * -get_mime_type_from_magic_numbers (char *buffer) -{ - static struct { - const char *mime_type; - const char *first_bytes; - int offset; - int len; - } sniffer_data [] = { - { "application/x-bzip2", "BZh", 0, 3 }, - { "application/x-gzip", "\037\213", 0, 2 }, - { "application/x-xz", "\3757zXZ\000", 0, 6 }, - { NULL, NULL, 0 } - }; - int i; - - for (i = 0; sniffer_data[i].mime_type != NULL; i++) - if (memcmp (sniffer_data[i].first_bytes, - buffer + sniffer_data[i].offset, - sniffer_data[i].len) == 0) - { - return sniffer_data[i].mime_type; - } - - return NULL; -} - - -int -main (int argc, char **argv) -{ - const char *filename; - GString *cpio_args; - int i; - FILE *stream; - guchar bytes[8]; - int il, dl, sigsize, offset; - const char *mime_type; - const char *archive_command; - char *command; - - if (argc < 3) - return 0; - - filename = argv[1]; - cpio_args = g_string_new (argv[2]); - for (i = 3; i < argc; i++) { - g_string_append (cpio_args, " "); - g_string_append (cpio_args, argv[i]); - } - - stream = fopen (filename, "r"); - if (stream == NULL) - return 1; - - if (fseek (stream, 104 , SEEK_CUR) != 0) { - fclose (stream); - return 1; - } - if (fread (bytes, 1, 8, stream) == 0) { - fclose (stream); - return 1; - } - il = 256 * (256 * (256 * bytes[0] + bytes[1]) + bytes[2]) + bytes[3]; - dl = 256 * (256 * (256 * bytes[4] + bytes[5]) + bytes[6]) + bytes[7]; - sigsize = 8 + 16 * il + dl; - offset = 104 + sigsize + (8 - (sigsize % 8)) % 8 + 8; - if (fseek (stream, offset, SEEK_SET) != 0) { - fclose (stream); - return 1; - } - if (fread (bytes, 1, 8, stream) == 0) { - fclose (stream); - return 1; - } - il = 256 * (256 * (256 * bytes[0] + bytes[1]) + bytes[2]) + bytes[3]; - dl = 256 * (256 * (256 * bytes[4] + bytes[5]) + bytes[6]) + bytes[7]; - sigsize = 8 + 16 * il + dl; - offset = offset + sigsize; - - /* get the payload type */ - - if (fseek (stream, offset, SEEK_SET) != 0) { - fclose (stream); - return 1; - } - if (fread (bytes, 1, 8, stream) == 0) { - fclose (stream); - return 1; - } - mime_type = get_mime_type_from_magic_numbers ((char *)bytes); - if (mime_type == NULL) - archive_command = "lzma -dc"; - else if (strcmp (mime_type, "application/x-xz") == 0) - archive_command = "xz -dc"; - else if (strcmp (mime_type, "application/x-gzip") == 0) - archive_command = "gzip -dc"; - else - archive_command = "bzip2 -dc"; - fclose (stream); - - command = g_strdup_printf ("sh -c \"dd if=%s ibs=%u skip=1 2>/dev/null | %s | " CPIO_PATH " %s\"", g_shell_quote (filename), offset, archive_command, cpio_args->str); - - return system (command); -} diff --git a/src/fr-command-rpm.c b/src/fr-command-rpm.c index 751f9a9..227fd58 100644 --- a/src/fr-command-rpm.c +++ b/src/fr-command-rpm.c @@ -184,7 +184,7 @@ fr_command_rpm_list (FrCommand *comm) fr_process_begin_command (comm->process, "sh"); fr_process_add_arg (comm->process, "-c"); - fr_process_add_arg_concat (comm->process, PRIVEXECDIR "rpm2cpio ", comm->e_filename, " -itv", NULL); + fr_process_add_arg_concat (comm->process, "rpm2cpio < ", comm->e_filename, " | cpio -itv", NULL); fr_process_end_command (comm->process); fr_process_start (comm->process); } @@ -207,14 +207,14 @@ fr_command_rpm_extract (FrCommand *comm, fr_process_set_working_dir (comm->process, dest_dir); fr_process_add_arg (comm->process, "-c"); - cmd = g_string_new (PRIVEXECDIR "rpm2cpio "); + cmd = g_string_new ("rpm2cpio < "); g_string_append (cmd, comm->e_filename); - g_string_append (cmd, " -idu "); + g_string_append (cmd, " | cpio -idu"); for (scan = file_list; scan; scan = scan->next) { + g_string_append (cmd, " "); char *filename = g_shell_quote (scan->data); g_string_append (cmd, filename); g_free (filename); - g_string_append (cmd, " "); } fr_process_add_arg (comm->process, cmd->str); g_string_free (cmd, TRUE); @@ -241,7 +241,8 @@ fr_command_rpm_get_capabilities (FrCommand *comm, FrCommandCap capabilities; capabilities = FR_COMMAND_CAN_ARCHIVE_MANY_FILES; - if (is_program_available (CPIO_PATH, check_command)) + if (is_program_available ("rpm2cpio", check_command) && + is_program_available (CPIO_PATH, check_command)) capabilities |= FR_COMMAND_CAN_READ; return capabilities; diff --git a/src/fr-process.c b/src/fr-process.c index 73395ad..cfd4033 100644 --- a/src/fr-process.c +++ b/src/fr-process.c @@ -641,7 +641,7 @@ child_setup (gpointer user_data) FrProcess *process = user_data; if (process->priv->use_standard_locale) - putenv ("LC_MESSAGES=C"); + putenv ("LC_ALL=C"); /* detach from the tty */ @@ -745,7 +745,7 @@ start_current_command (FrProcess *process) int j; if (process->priv->use_standard_locale) - g_print ("\tLC_MESSAGES=C\n"); + g_print ("\tLC_ALL=C\n"); if (info->dir != NULL) g_print ("\tcd %s\n", info->dir); |