aboutsummaryrefslogtreecommitdiff
path: root/archival/rpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/rpm.c')
-rw-r--r--archival/rpm.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/archival/rpm.c b/archival/rpm.c
index 3b70439a7..7b27c0250 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -7,16 +7,6 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <unistd.h>
12#include <signal.h>
13#include <stdlib.h>
14#include <fcntl.h>
15#include <netinet/in.h> /* For ntohl & htonl function */
16#include <string.h> /* For strncmp */
17#include <sys/mman.h> /* For mmap */
18#include <time.h> /* For ctime */
19
20#include "busybox.h" 10#include "busybox.h"
21#include "unarchive.h" 11#include "unarchive.h"
22 12
@@ -127,7 +117,7 @@ int rpm_main(int argc, char **argv)
127 117
128 if (optind == argc) bb_show_usage(); 118 if (optind == argc) bb_show_usage();
129 while (optind < argc) { 119 while (optind < argc) {
130 rpm_fd = bb_xopen(argv[optind], O_RDONLY); 120 rpm_fd = xopen(argv[optind], O_RDONLY);
131 mytags = rpm_gettags(rpm_fd, (int *) &tagcount); 121 mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
132 offset = lseek(rpm_fd, 0, SEEK_CUR); 122 offset = lseek(rpm_fd, 0, SEEK_CUR);
133 if (!mytags) { printf("Error reading rpm header\n"); exit(-1); } 123 if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
@@ -198,7 +188,7 @@ void extract_cpio_gz(int fd) {
198 bb_error_msg_and_die("Invalid gzip magic"); 188 bb_error_msg_and_die("Invalid gzip magic");
199 } 189 }
200 check_header_gzip(archive_handle->src_fd); 190 check_header_gzip(archive_handle->src_fd);
201 bb_xchdir("/"); // Install RPM's to root 191 xchdir("/"); // Install RPM's to root
202 192
203 archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip); 193 archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
204 archive_handle->offset = 0; 194 archive_handle->offset = 0;
@@ -302,7 +292,7 @@ void fileaction_dobackup(char *filename, int fileref)
302 if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */ 292 if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
303 stat_res = lstat (filename, &oldfile); 293 stat_res = lstat (filename, &oldfile);
304 if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */ 294 if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
305 newname = bb_xstrdup(filename); 295 newname = xstrdup(filename);
306 newname = strcat(newname, ".rpmorig"); 296 newname = strcat(newname, ".rpmorig");
307 copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); 297 copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
308 remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE); 298 remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
@@ -328,7 +318,7 @@ void loop_through_files(int filetag, void (*fileaction)(char *filename, int file
328{ 318{
329 int count = 0; 319 int count = 0;
330 while (rpm_getstring(filetag, count)) { 320 while (rpm_getstring(filetag, count)) {
331 char * filename = bb_xasprintf("%s%s", 321 char * filename = xasprintf("%s%s",
332 rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, 322 rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES,
333 count)), rpm_getstring(RPMTAG_BASENAMES, count)); 323 count)), rpm_getstring(RPMTAG_BASENAMES, count));
334 fileaction(filename, count++); 324 fileaction(filename, count++);