|
|
ecfc91a |
diff -up ./src/rpm.c.rpm2cpio ./src/rpm.c
|
|
|
ecfc91a |
--- ./src/rpm.c.rpm2cpio 2008-10-24 13:43:04.000000000 +0200
|
|
|
ecfc91a |
+++ ./src/rpm.c 2011-03-27 03:14:20.225742237 +0200
|
|
|
ecfc91a |
@@ -23,11 +23,8 @@ extern gboolean batch_mode;
|
|
|
ecfc91a |
|
|
|
ecfc91a |
void xa_open_rpm (XArchive *archive)
|
|
|
ecfc91a |
{
|
|
|
ecfc91a |
- unsigned char bytes[8];
|
|
|
ecfc91a |
unsigned short int i;
|
|
|
ecfc91a |
- int dl,il,sigsize,offset,response;
|
|
|
ecfc91a |
- gchar *ibs,*executable;
|
|
|
ecfc91a |
- gchar *gzip_tmp = NULL;
|
|
|
ecfc91a |
+ int response;
|
|
|
ecfc91a |
GSList *list = NULL;
|
|
|
ecfc91a |
FILE *stream;
|
|
|
ecfc91a |
gboolean result;
|
|
|
ecfc91a |
@@ -56,66 +53,14 @@ void xa_open_rpm (XArchive *archive)
|
|
|
ecfc91a |
archive->column_types[i] = types[i];
|
|
|
ecfc91a |
|
|
|
ecfc91a |
xa_create_liststore (archive,names);
|
|
|
ecfc91a |
- if (fseek ( stream, 104 , SEEK_CUR ) )
|
|
|
ecfc91a |
- {
|
|
|
ecfc91a |
- fclose (stream);
|
|
|
ecfc91a |
- response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't fseek to position 104:"),g_strerror(errno));
|
|
|
ecfc91a |
- return;
|
|
|
ecfc91a |
- }
|
|
|
ecfc91a |
- if ( fread ( bytes, 1, 8, stream ) == 0 )
|
|
|
ecfc91a |
- {
|
|
|
ecfc91a |
- fclose ( stream );
|
|
|
ecfc91a |
- response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't read data from file:"),g_strerror(errno));
|
|
|
ecfc91a |
- return;
|
|
|
ecfc91a |
- }
|
|
|
ecfc91a |
- il = 256 * ( 256 * ( 256 * bytes[0] + bytes[1]) + bytes[2] ) + bytes[3];
|
|
|
ecfc91a |
- dl = 256 * ( 256 * ( 256 * bytes[4] + bytes[5]) + bytes[6] ) + bytes[7];
|
|
|
ecfc91a |
- sigsize = 8 + 16 * il + dl;
|
|
|
ecfc91a |
- offset = 104 + sigsize + ( 8 - ( sigsize % 8 ) ) % 8 + 8;
|
|
|
ecfc91a |
- if (fseek ( stream, offset , SEEK_SET ) )
|
|
|
ecfc91a |
- {
|
|
|
ecfc91a |
- fclose (stream);
|
|
|
ecfc91a |
- response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't fseek in file:"),g_strerror(errno));
|
|
|
ecfc91a |
- return;
|
|
|
ecfc91a |
- }
|
|
|
ecfc91a |
- if ( fread ( bytes, 1, 8, stream ) == 0 )
|
|
|
ecfc91a |
- {
|
|
|
ecfc91a |
- fclose ( stream );
|
|
|
ecfc91a |
- response = xa_show_message_dialog (GTK_WINDOW (xa_main_window),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,_("Can't read data from file:"),g_strerror(errno));
|
|
|
ecfc91a |
- return;
|
|
|
ecfc91a |
- }
|
|
|
ecfc91a |
- il = 256 * ( 256 * ( 256 * bytes[0] + bytes[1]) + bytes[2] ) + bytes[3];
|
|
|
ecfc91a |
- dl = 256 * ( 256 * ( 256 * bytes[4] + bytes[5]) + bytes[6] ) + bytes[7];
|
|
|
ecfc91a |
- sigsize = 8 + 16 * il + dl;
|
|
|
ecfc91a |
- offset = offset + sigsize;
|
|
|
ecfc91a |
- fclose (stream);
|
|
|
ecfc91a |
|
|
|
ecfc91a |
/* Create a unique temp dir in /tmp */
|
|
|
ecfc91a |
result = xa_create_temp_directory (archive);
|
|
|
ecfc91a |
if (!result)
|
|
|
ecfc91a |
return;
|
|
|
ecfc91a |
|
|
|
ecfc91a |
- gzip_tmp = g_strconcat (archive->tmp,"/file.gz_bz",NULL);
|
|
|
ecfc91a |
- ibs = g_strdup_printf ( "%u" , offset );
|
|
|
ecfc91a |
-
|
|
|
ecfc91a |
/* Now I run dd to have the bzip2 / gzip compressed cpio archive in /tmp */
|
|
|
ecfc91a |
- gchar *command = g_strconcat ( "dd if=",archive->escaped_path," ibs=",ibs," skip=1 of=",gzip_tmp,NULL);
|
|
|
ecfc91a |
- g_free (ibs);
|
|
|
ecfc91a |
- list = g_slist_append(list,command);
|
|
|
ecfc91a |
- batch_mode = TRUE;
|
|
|
ecfc91a |
- result = xa_run_command (archive,list);
|
|
|
ecfc91a |
- if (result == FALSE)
|
|
|
ecfc91a |
- {
|
|
|
ecfc91a |
- g_free (gzip_tmp);
|
|
|
ecfc91a |
- return;
|
|
|
ecfc91a |
- }
|
|
|
ecfc91a |
- if (xa_detect_archive_type (gzip_tmp) == XARCHIVETYPE_GZIP)
|
|
|
ecfc91a |
- executable = "gzip -dc ";
|
|
|
ecfc91a |
- else
|
|
|
ecfc91a |
- executable = "bzip2 -dc ";
|
|
|
ecfc91a |
-
|
|
|
ecfc91a |
- command = g_strconcat("sh -c \"",executable,gzip_tmp," > ",archive->tmp,"/file.cpio\"",NULL);
|
|
|
ecfc91a |
- g_free(gzip_tmp);
|
|
|
ecfc91a |
+ gchar *command = g_strconcat ( "sh -c \"rpm2cpio ",archive->escaped_path," > ",archive->tmp, "/file.cpio\"",NULL);
|
|
|
ecfc91a |
list = NULL;
|
|
|
ecfc91a |
list = g_slist_append(list,command);
|
|
|
ecfc91a |
result = xa_run_command (archive,list);
|