summaryrefslogtreecommitdiff
path: root/build/parseFiles.c
diff options
context:
space:
mode:
authorKim Kibum <kb0929.kim@samsung.com>2012-05-21 17:49:08 +0900
committerKim Kibum <kb0929.kim@samsung.com>2012-05-21 17:49:08 +0900
commitdec48cfa66e17ba4a7e50c92cb24b913289feb12 (patch)
treee1f48cd5cabb40a1d604b36949ff072d01267cb5 /build/parseFiles.c
parentb7a3bffb8e0341b7e4ef69def268bca3a7f279ff (diff)
downloadrpm-dec48cfa66e17ba4a7e50c92cb24b913289feb12.tar.gz
rpm-dec48cfa66e17ba4a7e50c92cb24b913289feb12.tar.bz2
rpm-dec48cfa66e17ba4a7e50c92cb24b913289feb12.zip
Upload Tizen:Base source
Diffstat (limited to 'build/parseFiles.c')
-rw-r--r--build/parseFiles.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/build/parseFiles.c b/build/parseFiles.c
new file mode 100644
index 0000000..7c51c3a
--- /dev/null
+++ b/build/parseFiles.c
@@ -0,0 +1,99 @@
+/** \ingroup rpmbuild
+ * \file build/parseFiles.c
+ * Parse %files section from spec file.
+ */
+
+#include "system.h"
+
+#include <rpm/rpmlog.h>
+#include <rpm/rpmfileutil.h>
+#include "build/rpmbuild_internal.h"
+#include "debug.h"
+
+int parseFiles(rpmSpec spec)
+{
+ int nextPart, res = PART_ERROR;
+ Package pkg;
+ int rc, argc;
+ int arg;
+ const char ** argv = NULL;
+ const char *name = NULL;
+ int flag = PART_SUBNAME;
+ poptContext optCon = NULL;
+ struct poptOption optionsTable[] = {
+ { NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL},
+ { NULL, 'f', POPT_ARG_STRING, NULL, 'f', NULL, NULL},
+ { 0, 0, 0, 0, 0, NULL, NULL}
+ };
+
+ if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
+ rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%files: %s\n"),
+ spec->lineNum, poptStrerror(rc));
+ goto exit;
+ }
+
+ optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
+ while ((arg = poptGetNextOpt(optCon)) > 0) {
+ if (arg == 'n') {
+ flag = PART_NAME;
+ }
+ }
+
+ if (arg < -1) {
+ rpmlog(RPMLOG_ERR, _("line %d: Bad option %s: %s\n"),
+ spec->lineNum,
+ poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
+ spec->line);
+ goto exit;
+ }
+
+ if (poptPeekArg(optCon)) {
+ if (name == NULL)
+ name = poptGetArg(optCon);
+ if (poptPeekArg(optCon)) {
+ rpmlog(RPMLOG_ERR, _("line %d: Too many names: %s\n"),
+ spec->lineNum,
+ spec->line);
+ goto exit;
+ }
+ }
+
+ if (lookupPackage(spec, name, flag, &pkg)) {
+ rpmlog(RPMLOG_ERR, _("line %d: Package does not exist: %s\n"),
+ spec->lineNum, spec->line);
+ goto exit;
+ }
+
+ for (arg=1; arg<argc; arg++) {
+ if (rstreq(argv[arg], "-f") && argv[arg+1]) {
+ char *file = rpmGetPath(argv[arg+1], NULL);
+ argvAdd(&(pkg->fileFile), file);
+ free(file);
+ }
+ }
+
+ pkg->fileList = argvNew();
+
+ if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
+ nextPart = PART_NONE;
+ } else if (rc < 0) {
+ goto exit;
+ } else {
+ while (! (nextPart = isPart(spec->line))) {
+ argvAdd(&(pkg->fileList), spec->line);
+ if ((rc = readLine(spec, STRIP_COMMENTS)) > 0) {
+ nextPart = PART_NONE;
+ break;
+ } else if (rc < 0) {
+ goto exit;
+ }
+ }
+ }
+ res = nextPart;
+
+exit:
+ argv = _free(argv);
+ optCon = poptFreeContext(optCon);
+
+ return res;
+}