69 fd =
Fopen(specfile,
"r");
70 if (fd == NULL ||
Ferror(fd)) {
75 count =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), fd);
79 for (s = buf; count--; s++) {
90 if (checking && !(isprint(*s) || isspace(*s)))
return 0;
106 const char * cookie = ba->
cookie;
108 const char * specFile;
109 const char * specURL;
124 const char * specDir;
128 static const char *zcmds[] =
129 {
"cat",
"gunzip",
"bunzip2",
"cat" };
133 tmpSpecFile = (
char *)
rpmGetPath(
"%{_specdir}/",
"rpm-spec.XXXXXX", NULL);
134 #if defined(HAVE_MKSTEMP)
135 (void) close(mkstemp(tmpSpecFile));
137 (void) mktemp(tmpSpecFile);
142 cmd =
alloca(strlen(arg) + 50 + strlen(tmpSpecFile));
143 sprintf(cmd,
"%s < %s | tar xOvf - Specfile 2>&1 > %s",
144 zcmds[res & 0x3], arg, tmpSpecFile);
145 if (!(fp = popen(cmd,
"r"))) {
147 specDir =
_free(specDir);
148 tmpSpecFile =
_free(tmpSpecFile);
151 if ((!fgets(buf,
sizeof(buf) - 1, fp)) || !strchr(buf,
'/')) {
155 sprintf(cmd,
"%s < %s | tar xOvf - --wildcards \\*.spec 2>&1 > %s",
156 zcmds[res & 0x3], arg, tmpSpecFile);
157 if (!(fp = popen(cmd,
"r"))) {
159 specDir =
_free(specDir);
160 tmpSpecFile =
_free(tmpSpecFile);
163 if (!fgets(buf,
sizeof(buf) - 1, fp)) {
167 (void) unlink(tmpSpecFile);
168 specDir =
_free(specDir);
169 tmpSpecFile =
_free(tmpSpecFile);
176 while (*cmd !=
'\0') {
177 if (*cmd ==
'/') s = cmd + 1;
184 s = cmd + strlen(cmd) - 1;
187 specURL = s =
alloca(strlen(specDir) + strlen(cmd) + 5);
188 sprintf(s,
"%s/%s", specDir, cmd);
189 res = rename(tmpSpecFile, s);
190 specDir =
_free(specDir);
195 (void) unlink(tmpSpecFile);
196 tmpSpecFile =
_free(tmpSpecFile);
199 tmpSpecFile =
_free(tmpSpecFile);
205 if (getcwd(buf, BUFSIZ) == NULL) strcpy(buf,
".");
211 cmd = buf + strlen(buf) - 1;
212 while (*cmd !=
'/') cmd--;
221 specut =
urlPath(specURL, &specFile);
222 if (*specFile !=
'/') {
224 if (getcwd(s, BUFSIZ) == NULL) strcpy(s,
".");
232 if (
Stat(specURL, &st) < 0) {
237 if (! S_ISREG(st.st_mode)) {
247 _(
"File %s does not appear to be a specfile.\n"), specURL);
254 #define _anyarch(_f) \
255 (((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0)
298 #define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC)
312 if (targets == NULL) {
320 printf(
_(
"Building target platforms: %s\n"), targets);
323 for (t = targets; *t !=
'\0'; t = te) {
325 if ((te = strchr(t,
',')) == NULL)
328 strncpy(target, t, (te-t));
353 if ((te = strchr(t,
',')) == NULL)
356 strncpy(target, t, (te-t));