diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-06 16:56:38 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-06 16:56:38 +0200 |
commit | 5dfd9c4dbcc30d6d3f745316fd11a797c06f06d0 (patch) | |
tree | b4ce4e091998bd652636c6da5e5039ccf6e7781b | |
parent | 27653adc8b7ebe44bd357511de53d0c14eef0894 (diff) | |
download | busybox-w32-5dfd9c4dbcc30d6d3f745316fd11a797c06f06d0.tar.gz busybox-w32-5dfd9c4dbcc30d6d3f745316fd11a797c06f06d0.tar.bz2 busybox-w32-5dfd9c4dbcc30d6d3f745316fd11a797c06f06d0.zip |
rpm: make rpm -i SRPM.rpm install it to surrent dir; better help text
function old new delta
rpm_main 1355 1358 +3
packed_usage 26732 26728 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-4) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/rpm.c | 18 | ||||
-rw-r--r-- | include/usage.h | 8 |
2 files changed, 17 insertions, 9 deletions
diff --git a/archival/rpm.c b/archival/rpm.c index 77679c275..38ec20ef5 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -71,7 +71,7 @@ static void *map; | |||
71 | static rpm_index **mytags; | 71 | static rpm_index **mytags; |
72 | static int tagcount; | 72 | static int tagcount; |
73 | 73 | ||
74 | static void extract_cpio_gz(int fd); | 74 | static void extract_cpio(int fd, const char *source_rpm); |
75 | static rpm_index **rpm_gettags(int fd, int *num_tags); | 75 | static rpm_index **rpm_gettags(int fd, int *num_tags); |
76 | static int bsearch_rpmtag(const void *key, const void *item); | 76 | static int bsearch_rpmtag(const void *key, const void *item); |
77 | static char *rpm_getstr(int tag, int itemindex); | 77 | static char *rpm_getstr(int tag, int itemindex); |
@@ -122,6 +122,8 @@ int rpm_main(int argc, char **argv) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | while (*argv) { | 124 | while (*argv) { |
125 | const char *source_rpm; | ||
126 | |||
125 | rpm_fd = xopen(*argv++, O_RDONLY); | 127 | rpm_fd = xopen(*argv++, O_RDONLY); |
126 | mytags = rpm_gettags(rpm_fd, &tagcount); | 128 | mytags = rpm_gettags(rpm_fd, &tagcount); |
127 | if (!mytags) | 129 | if (!mytags) |
@@ -130,11 +132,13 @@ int rpm_main(int argc, char **argv) | |||
130 | /* Mimimum is one page */ | 132 | /* Mimimum is one page */ |
131 | map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0); | 133 | map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0); |
132 | 134 | ||
135 | source_rpm = rpm_getstr(TAG_SOURCERPM, 0); | ||
136 | |||
133 | if (func & rpm_install) { | 137 | if (func & rpm_install) { |
134 | /* Backup any config files */ | 138 | /* Backup any config files */ |
135 | loop_through_files(TAG_BASENAMES, fileaction_dobackup); | 139 | loop_through_files(TAG_BASENAMES, fileaction_dobackup); |
136 | /* Extact the archive */ | 140 | /* Extact the archive */ |
137 | extract_cpio_gz(rpm_fd); | 141 | extract_cpio(rpm_fd, source_rpm); |
138 | /* Set the correct file uid/gid's */ | 142 | /* Set the correct file uid/gid's */ |
139 | loop_through_files(TAG_BASENAMES, fileaction_setowngrp); | 143 | loop_through_files(TAG_BASENAMES, fileaction_setowngrp); |
140 | } | 144 | } |
@@ -161,7 +165,7 @@ int rpm_main(int argc, char **argv) | |||
161 | strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm); | 165 | strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm); |
162 | printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring); | 166 | printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring); |
163 | printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0)); | 167 | printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0)); |
164 | printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0)); | 168 | printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), source_rpm); |
165 | printf("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0)); | 169 | printf("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0)); |
166 | printf("URL : %s\n", rpm_getstr(TAG_URL, 0)); | 170 | printf("URL : %s\n", rpm_getstr(TAG_URL, 0)); |
167 | printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0)); | 171 | printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0)); |
@@ -194,10 +198,15 @@ int rpm_main(int argc, char **argv) | |||
194 | return 0; | 198 | return 0; |
195 | } | 199 | } |
196 | 200 | ||
197 | static void extract_cpio_gz(int fd) | 201 | static void extract_cpio(int fd, const char *source_rpm) |
198 | { | 202 | { |
199 | archive_handle_t *archive_handle; | 203 | archive_handle_t *archive_handle; |
200 | 204 | ||
205 | if (source_rpm != NULL) { | ||
206 | /* Binary rpm (it was built from some SRPM), install to root */ | ||
207 | xchdir("/"); | ||
208 | } /* else: SRPM, install to current dir */ | ||
209 | |||
201 | /* Initialize */ | 210 | /* Initialize */ |
202 | archive_handle = init_handle(); | 211 | archive_handle = init_handle(); |
203 | archive_handle->seek = seek_by_read; | 212 | archive_handle->seek = seek_by_read; |
@@ -215,7 +224,6 @@ static void extract_cpio_gz(int fd) | |||
215 | archive_handle->src_fd = fd; | 224 | archive_handle->src_fd = fd; |
216 | /*archive_handle->offset = 0; - init_handle() did it */ | 225 | /*archive_handle->offset = 0; - init_handle() did it */ |
217 | 226 | ||
218 | xchdir("/"); /* Install RPM's to root */ | ||
219 | setup_unzip_on_fd(archive_handle->src_fd /*, fail_if_not_detected: 1*/); | 227 | setup_unzip_on_fd(archive_handle->src_fd /*, fail_if_not_detected: 1*/); |
220 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) | 228 | while (get_header_cpio(archive_handle) == EXIT_SUCCESS) |
221 | continue; | 229 | continue; |
diff --git a/include/usage.h b/include/usage.h index 636d01943..d619d9ed7 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3810,13 +3810,13 @@ | |||
3810 | "\n -A inet" IF_FEATURE_IPV6("{6}") " Select address family" \ | 3810 | "\n -A inet" IF_FEATURE_IPV6("{6}") " Select address family" \ |
3811 | 3811 | ||
3812 | #define rpm_trivial_usage \ | 3812 | #define rpm_trivial_usage \ |
3813 | "-i -q[ildc]p PACKAGE.rpm" | 3813 | "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm" |
3814 | #define rpm_full_usage "\n\n" \ | 3814 | #define rpm_full_usage "\n\n" \ |
3815 | "Manipulate RPM packages\n" \ | 3815 | "Manipulate RPM packages\n" \ |
3816 | "\nOptions:" \ | 3816 | "\nCommands:" \ |
3817 | "\n -i Install package" \ | 3817 | "\n -i Install package" \ |
3818 | "\n -q Query package" \ | 3818 | "\n -qp Query package" \ |
3819 | "\n -p Query uninstalled package" \ | 3819 | "\nOptions:" \ |
3820 | "\n -i Show information" \ | 3820 | "\n -i Show information" \ |
3821 | "\n -l List contents" \ | 3821 | "\n -l List contents" \ |
3822 | "\n -d List documents" \ | 3822 | "\n -d List documents" \ |