Permalink
Browse files

Initial revision

CVS patchset: 1
CVS date: 1995/11/27 22:31:21
  • Loading branch information...
root
root committed Nov 27, 1995
0 parents commit 7153c160969d70a083f791bf75f9b4d09d2f2a45
Showing with 1,544 additions and 0 deletions.
  1. +25 −0 Makefile.in
  2. +12 −0 build/build.c
  3. +118 −0 build/spec.c
  4. +14 −0 build/spec.h
  5. +7 −0 convertdb.c
  6. +31 −0 lib/Makefile.in
  7. +464 −0 lib/header.c
  8. +85 −0 lib/header.h
  9. +49 −0 lib/messages.c
  10. +17 −0 lib/messages.h
  11. +42 −0 lib/misc.c
  12. +7 −0 lib/misc.h
  13. +70 −0 lib/oldrpmdb.h
  14. +8 −0 lib/rpm_malloc.h
  15. +8 −0 lib/rpmerr.c
  16. +32 −0 lib/test.c
  17. +498 −0 oldrpmdb.c
  18. +49 −0 rpmio/messages.c
  19. +8 −0 rpmio/rpmerr.c
@@ -0,0 +1,25 @@
+SUBDIRS = lib
+OBJS = spec.o
+PROGS = build
+
+WARNINGS = -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes
+DEBUG = -g
+OPTS = -O2
+CFLAGS = $(WARNINGS) $(DEBUG) $(OPTS) -Ilib
+LDFLAGS = $(DEBUG) -Llib
+LOADLIBES = -lrpm
+
+all: make-subdirs $(OBJS) $(PROGS)
+
+make-subdirs:
+ for d in $(SUBDIRS); do \
+ (cd $$d; $(MAKE)) ;\
+ done
+
+build: build.o spec.o
+
+clean:
+ for d in $(SUBDIRS); do \
+ (cd $$d; $(MAKE) $@) ;\
+ done
+ rm -f *.o *~ $(PROGS)
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "spec.h"
+
+void main(int argc, char **argv)
+{
+ FILE *f;
+
+ printf("hello\n");
+ f = fopen(argv[1], "r");
+ parse_spec(f);
+ fclose(f);
+}
@@ -0,0 +1,118 @@
+/* RPM - Copyright (C) 1995 Red Hat Software
+ *
+ * spec.c - routines for parsing a spec file
+ */
+
+#include "header.h"
+#include "spec.h"
+#include "rpmerr.h"
+#include <stdlib.h>
+#include <string.h>
+
+#define LINE_BUF_SIZE 1024
+
+struct spec {
+ Header header;
+ char *prep;
+ char *build;
+ char *install;
+ char *clean;
+};
+
+void free_spec(Spec s)
+{
+ freeHeader(s->header);
+ free(s->prep);
+ free(s->build);
+ free(s->install);
+ free(s->clean);
+ free(s);
+}
+
+static int read_line(FILE *f, char *line);
+static int match_arch(char *s);
+static int match_os(char *s);
+
+static int match_arch(char *s)
+{
+ if (! strncmp(s, "%ifarch i386", 12)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static int match_os(char *s)
+{
+ if (! strncmp(s, "%ifos linux", 11)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static int reading = 0;
+static int iflevels = 0;
+static int skiplevels = 0;
+static int skip = 0;
+
+static int read_line(FILE *f, char *line)
+{
+ char *r = fgets(line, LINE_BUF_SIZE, f);
+
+ if (! r) {
+ /* the end */
+ if (iflevels) return RPMERR_UNMATCHEDIF;
+ return 0;
+ }
+
+ skip = 0;
+
+ if (! strncmp("%ifarch", line, 7)) {
+ iflevels++;
+ skip = 1;
+ if (! match_arch(line)) {
+ reading = 0;
+ skiplevels++;
+ }
+ }
+ if (! strncmp("%ifos", line, 5)) {
+ iflevels++;
+ skip = 1;
+ if (! match_os(line)) {
+ reading = 0;
+ skiplevels++;
+ }
+ }
+
+ if (! strncmp("%endif", line, 6)) {
+ iflevels--;
+ skip = 1;
+ if (skiplevels) {
+ if (! --skiplevels) reading = 1;
+ }
+ }
+
+ return 1;
+}
+
+Spec parse_spec(FILE *f)
+{
+ char line[LINE_BUF_SIZE];
+ Spec s = (struct spec *) malloc(sizeof(struct spec));
+ int x;
+
+ reading = 1;
+
+ while ((x = read_line(f, line))) {
+ if (!reading) continue;
+ if (skip) continue;
+ puts(line);
+ }
+ if (x < 0) {
+ /* error */
+ return NULL;
+ }
+
+ return s;
+}
@@ -0,0 +1,14 @@
+/* RPM - Copyright (C) 1995 Red Hat Software
+ *
+ * spec.h - routines for parsing are looking up info in a spec file
+ */
+
+#ifndef _spec_h
+#define _spec_h
+
+typedef struct spec *Spec;
+
+Spec parse_spec(FILE *f);
+void free_spec(Spec s);
+
+#endif _spec_h
@@ -0,0 +1,7 @@
+/* This converts an old style (rpm 1.x) database to the new style */
+
+#include <oldrpmdb.h>
+
+int convertDB(char * dbprefix) {
+
+}
@@ -0,0 +1,31 @@
+LIBS = -lefence
+
+LIBOBJECTS = header.o oldrpmdb.o misc.o messages.o
+LIBRPM = librpm.a
+
+WARNINGS = -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes
+DEBUG = -g
+OPTS = -O2
+
+all: test dump
+
+# -----------------------------------------------------------------------
+
+AR = ar r
+RANLIB = ranlib
+
+CFLAGS = $(WARNINGS) $(DEBUG) $(OPTS)
+LDFLAGS = $(DEBUG) $(LIBS)
+
+test: librpm.a
+ $(CC) -o $@ test.c librpm.a $(LIBS)
+
+dump: librpm.a
+ $(CC) -o $@ dump.c librpm.a $(LIBS)
+
+$(LIBRPM): $(LIBOBJECTS)
+ $(AR) $@ $(LIBOBJECTS)
+ $(RANLIB) $@
+
+clean:
+ rm -f *.a *.o *~ test dump test.out
Oops, something went wrong.

0 comments on commit 7153c16

Please sign in to comment.