--- rpm-4_0-4.0.4-orig/build/parseSpec.c 2002-03-26 01:09:32 +0200 +++ rpm-4_0-4.0.4/build/parseSpec.c 2004-12-10 15:13:44 +0200 @@ -16,6 +16,8 @@ /*@access FD_t @*/ /* compared with NULL */ +static FILE* temp_file;/*tempory file to output preprocessing spec*/ + /** */ /*@unchecked@*/ @@ -362,7 +364,7 @@ if ( '\n' == chomped[len-1] ) chomped[len-1] = '\0'; - puts( chomped ); + fprintf(temp_file, "%s\n", chomped ); chomped = _free( chomped ); } @@ -396,6 +398,10 @@ { rpmParseState parsePart = PART_PREAMBLE; int initialPackage = 1; + char temp_filename_pattern[25]="preprocessed-spec.XXXXXX"; + int temp_fd; + char line[255]; + #ifdef DYING const char *saveArch; #endif @@ -416,6 +422,23 @@ spec->fileStack = newOpenFileInfo(); spec->fileStack->fileName = xstrdup(spec->specFile); spec->preprocess_mode = preprocess; + + if (spec->preprocess_mode){ + temp_fd = mkstemp(temp_filename_pattern); + if (temp_fd == -1) { + rpmError(RPMERR_CREATE, _("Cannot open tempory file")); + return RPMERR_CREATE; + } + if (!(temp_file = fdopen(temp_fd, "w+b"))) { + rpmError(RPMERR_CREATE, _("Cannot create tempory file descriptor")); + return RPMERR_CREATE; + } + if (unlink(temp_filename_pattern) == -1) { + rpmError(RPMERR_UNLINK, _("Cannot delete tempory file")); + return RPMERR_UNLINK; + } + } + if (buildRootURL) { const char * buildRoot; (void) urlPath(buildRootURL, &buildRoot); @@ -636,5 +659,15 @@ closeSpec(spec); *specp = spec; + if (spec->preprocess_mode){ + if (!fseek(temp_file,0,SEEK_SET)) + while(fgets(line,255,temp_file)) + printf("%s",line); + else{ + rpmError(RPMERR_FSEEK, _("Cannot seek tempory file")); + return RPMERR_FSEEK; + } + } + return 0; }