From: marc Date: Thu, 14 Dec 1995 15:56:10 +0000 (+0000) Subject: routines for building packages from parsed spec structs X-Git-Tag: rpm-4.4-release~5695 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3d821cea4dafe238d16a7e0a46942ec9c4b040f;p=platform%2Fupstream%2Frpm.git routines for building packages from parsed spec structs CVS patchset: 40 CVS date: 1995/12/14 15:56:10 --- diff --git a/build/build.c b/build/build.c index 8475db6..005c869 100644 --- a/build/build.c +++ b/build/build.c @@ -1,14 +1,128 @@ +/* RPM - Copyright (C) 1995 Red Hat Software + * + * build.c - routines for building a package + */ + +#include #include +#include +#include +#include + +#include "build.h" +#include "header.h" #include "spec.h" +#include "specP.h" +#include "rpmerr.h" #include "messages.h" +#include "stringbuf.h" + +struct Script { + char *name; + FILE *file; +}; -void main(int argc, char **argv) +struct Script *openScript(void); +void writeScript(struct Script *script, char *s); +int execScript(struct Script *script); +void closeScript(struct Script *script); + +struct Script *openScript(void) { - FILE *f; + struct Script *script = malloc(sizeof(struct Script)); + + script->name = tempnam("/usr/tmp", "rpmbuild"); + script->file = fopen(script->name, "w"); + fprintf(script->file, "#!/bin/sh\n"); + + return script; +} - setVerbosity(MESS_DEBUG); +void writeScript(struct Script *script, char *s) +{ + fprintf(script->file, "%s", s); +} - f = fopen(argv[1], "r"); - parseSpec(f); - fclose(f); +int execScript(struct Script *script) +{ + int pid; + int status; + + fclose(script->file); + chmod(script->name, 0700); + if (!(pid = fork())) { + execl(script->name, script->name, NULL); + error(RPMERR_SCRIPT, "Exec failed"); + exit(RPMERR_SCRIPT); + } + wait(&status); + if (! WIFEXITED(status) || WEXITSTATUS(status)) { + error(RPMERR_SCRIPT, "Bad exit status"); + exit(RPMERR_SCRIPT); + } + return 0; +} + +void closeScript(struct Script *script) +{ + fclose(script->file); + unlink(script->name); + free(script->name); + free(script); +} + +int execPrep(Spec s) +{ + struct Script *script; + + script = openScript(); + writeScript(script, getStringBuf(s->prep)); + execScript(script); + closeScript(script); + return 0; +} + +int execBuild(Spec s) +{ + struct Script *script; + + script = openScript(); + writeScript(script, getStringBuf(s->build)); + execScript(script); + closeScript(script); + return 0; +} + +int execInstall(Spec s) +{ + struct Script *script; + + script = openScript(); + writeScript(script, getStringBuf(s->install)); + execScript(script); + closeScript(script); + return 0; +} + +int execClean(Spec s) +{ + struct Script *script; + + script = openScript(); + writeScript(script, getStringBuf(s->clean)); + execScript(script); + closeScript(script); + return 0; +} + +int verifyList(Spec s) +{ +} + +int packageBinaries(Spec s) +{ +} + +int packageSource(Spec s) +{ }