rpm 5.3.12
|
00001 00005 #include "system.h" 00006 00007 #include <rpmio.h> 00008 #include <rpmiotypes.h> 00009 #include <rpmlog.h> 00010 #define _RPMTAG_INTERNAL 00011 #include "rpmbuild.h" 00012 #include "debug.h" 00013 00014 int parseBuildInstallClean(Spec spec, rpmParseState parsePart) 00015 { 00016 rpmParseState nextPart; 00017 rpmiob *iobp = NULL; 00018 const char *name = NULL; 00019 rpmRC rc; 00020 00021 switch (parsePart) { 00022 case PART_BUILD: 00023 iobp = &spec->build; 00024 name = "build"; 00025 break; 00026 case PART_INSTALL: 00027 iobp = &spec->install; 00028 name = "install"; 00029 break; 00030 case PART_CHECK: 00031 iobp = &spec->check; 00032 name = "check"; 00033 break; 00034 case PART_CLEAN: 00035 iobp = &spec->clean; 00036 name = "clean"; 00037 break; 00038 case PART_ARBITRARY: 00039 assert(spec->nfoo > 0); 00040 iobp = &spec->foo[spec->nfoo-1].iob; 00041 name = spec->foo[spec->nfoo-1].str; 00042 break; 00043 default: 00044 rpmlog(RPMLOG_ERR, _("line %d: unknown specfile section\n"), 00045 spec->lineNum); 00046 return RPMRC_FAIL; 00047 break; 00048 } 00049 00050 if (*iobp != NULL) { 00051 rpmlog(RPMLOG_ERR, _("line %d: second %%%s section\n"), 00052 spec->lineNum, name); 00053 return RPMRC_FAIL; 00054 } 00055 00056 *iobp = rpmiobNew(0); 00057 00058 /* Make sure the buildroot is removed where needed. */ 00059 if (parsePart == PART_INSTALL) { 00060 const char * s = rpmExpand("%{!?__spec_install_pre:%{?buildroot:%{__rm} -rf '%{buildroot}'\n%{__mkdir_p} '%{buildroot}'\n}}\n", NULL); 00061 if (s && *s) 00062 *iobp = rpmiobAppend(*iobp, s, 0); 00063 s = _free(s); 00064 } else if (parsePart == PART_CLEAN) { 00065 const char * s = rpmExpand("%{?__spec_clean_body}%{!?__spec_clean_body:%{?buildroot:rm -rf '%{buildroot}'\n}}\n", NULL); 00066 if (s && *s) 00067 *iobp = rpmiobAppend(*iobp, s, 0); 00068 s = _free(s); 00069 #if !defined(RPM_VENDOR_OPENPKG) /* still-support-section-clean */ 00070 /* OpenPKG still wishes to use "%clean" script/section */ 00071 iobp = NULL; /* XXX skip %clean from spec file. */ 00072 #endif 00073 } 00074 00075 /* There are no options to %build, %install, %check, or %clean */ 00076 if ((rc = readLine(spec, STRIP_NOTHING)) > 0) 00077 return PART_NONE; 00078 if (rc != RPMRC_OK) 00079 return rc; 00080 00081 while ((nextPart = isPart(spec)) == PART_NONE) { 00082 if (iobp) 00083 *iobp = rpmiobAppend(*iobp, spec->line, 0); 00084 if ((rc = readLine(spec, STRIP_NOTHING)) > 0) 00085 return PART_NONE; 00086 if (rc) 00087 return rc; 00088 } 00089 00090 return nextPart; 00091 }