Skip to content

Commit

Permalink
Initial revision
Browse files Browse the repository at this point in the history
CVS patchset: 1
CVS date: 1995/11/27 22:31:21
  • Loading branch information
root committed Nov 27, 1995
0 parents commit 7153c16
Show file tree
Hide file tree
Showing 19 changed files with 1,544 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Makefile.in
@@ -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)
12 changes: 12 additions & 0 deletions build/build.c
@@ -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);
}
118 changes: 118 additions & 0 deletions build/spec.c
@@ -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;
}
14 changes: 14 additions & 0 deletions build/spec.h
@@ -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
7 changes: 7 additions & 0 deletions convertdb.c
@@ -0,0 +1,7 @@
/* This converts an old style (rpm 1.x) database to the new style */

#include <oldrpmdb.h>

int convertDB(char * dbprefix) {

}
31 changes: 31 additions & 0 deletions lib/Makefile.in
@@ -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

0 comments on commit 7153c16

Please sign in to comment.