Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CVS patchset: 1 CVS date: 1995/11/27 22:31:21
- Loading branch information
root committed
Nov 27, 1995
0 parents commit 7153c16
Showing 19 changed files with 1,544 additions and 0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* This converts an old style (rpm 1.x) database to the new style */ | ||
#include <oldrpmdb.h> | ||
int convertDB(char * dbprefix) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.