9 #include <rpm/rpmcli.h> 10 #include <rpm/rpmtag.h> 11 #include <rpm/rpmlib.h> 12 #include <rpm/rpmbuild.h> 14 #include <rpm/rpmps.h> 15 #include <rpm/rpmte.h> 16 #include <rpm/rpmts.h> 17 #include <rpm/rpmfileutil.h> 18 #include <rpm/rpmlog.h> 63 f = fopen(specfile,
"r");
64 if (f == NULL || ferror(f)) {
66 specfile, strerror(
errno));
69 count = fread(buf,
sizeof(buf[0]),
sizeof(buf), f);
76 for (s = buf; count--; s++) {
87 if (checking && !(isprint(*s) || isspace(*s)))
return 0;
90 if (checking && !(isprint(*s) || isspace(*s)) && *(
unsigned char *)s < 32)
return 0;
104 char *specFile = NULL;
110 int gotspec = 0, res;
111 static const char *tryspec[] = {
"Specfile",
"\\*.spec", NULL };
114 tmpSpecFile =
rpmGetPath(
"%{_specdir}/",
"rpm-spec.XXXXXX", NULL);
116 (void) close(mkstemp(tmpSpecFile));
118 for (
try = tryspec; *
try != NULL;
try++) {
122 cmd =
rpmExpand(
"%{uncompress: ", arg,
"} | ",
123 "%{__tar} xOvf - --wildcards ", *
try,
124 " 2>&1 > ", tmpSpecFile, NULL);
126 if (!(fp = popen(cmd,
"r"))) {
131 fok = fgets(tarbuf,
sizeof(tarbuf) - 1, fp);
133 if (!fok || strncmp(fok,
"tar: ", 5) != 0)
137 gotspec = (fok != NULL) &&
isSpecFile(tmpSpecFile);
150 specBase = basename(tarbuf);
152 specBase[strlen(specBase)-1] =
'\0';
154 rasprintf(&specFile,
"%s/%s", specDir, specBase);
155 res = rename(tmpSpecFile, specFile);
159 tmpSpecFile, specFile);
165 umask(mask = umask(0));
166 (void) chmod(specFile, 0666 & ~mask);
170 (void) unlink(tmpSpecFile);
181 const char * cookie = ba->
cookie;
183 char * buildRootURL = NULL;
184 char * specFile = NULL;
196 const char * buildtree =
"%{_topdir}:%{_specdir}:%{_sourcedir}:%{_builddir}:%{_rpmdir}:%{_srcrpmdir}:%{_buildrootdir}";
203 char *srcdir = NULL, *dir;
217 srcdir = dirname(dir);
224 if (*specFile !=
'/') {
234 if (stat(specFile, &st) < 0) {
238 if (! S_ISREG(st.st_mode)) {
246 _(
"File %s does not appear to be a specfile.\n"), specFile);
252 rc = unlink(specFile);
257 #define _anyarch(_f) \ 258 (((_f)&(RPMBUILD_PREP|RPMBUILD_BUILD|RPMBUILD_INSTALL|RPMBUILD_PACKAGEBINARY)) == 0) 272 rc = unlink(specFile);
289 (void) unlink(specFile);
304 #define buildCleanMask (RPMBUILD_RMSOURCE|RPMBUILD_RMSPEC) 317 if (targets == NULL) {
324 printf(
_(
"Building target platforms: %s\n"), targets);
327 for (t = targets; *t !=
'\0'; t = te) {
329 if ((te = strchr(t,
',')) == NULL)
332 strncpy(target, t, (te-t));
339 printf(
_(
"Building for target %s\n"), target);
static int isSpecFile(const char *specfile)
int rpmtsCheck(rpmts ts)
Perform dependency resolution on the transaction set.
int build(rpmts ts, const char *arg, BTA_t ba, const char *rcfile)
static int buildForTarget(rpmts ts, const char *arg, BTA_t ba)
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
char * rstrscat(char **dest, const char *arg,...) RPM_GNUC_NULL_TERMINATED
Concatenate multiple strings with dynamically (re)allocated memory.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
const char * rpmtsRootDir(rpmts ts)
Get transaction rootDir, i.e.
void initSourceHeader(rpmSpec spec)
Create and initialize header for source package.
int rpmReadConfigFiles(const char *file, const char *target)
Read macro configuration file(s) for a target.
int parseSpec(rpmts ts, const char *specFile, const char *rootDir, const char *buildRoot, int recursing, const char *passPhrase, const char *cookie, int anyarch, int force)
Parse spec file into spec control structure.
The structure used to store values parsed from a spec file.
void rpmSetTables(int archTable, int osTable)
rpmRC doRmSource(rpmSpec spec)
Remove all sources assigned to spec file.
enum rpmVSFlags_e rpmVSFlags
Bit(s) to control digest and signature verification.
static int rstreq(const char *s1, const char *s2)
Test for string equality.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
int rpmpsNumProblems(rpmps ps)
Return number of problems in set.
static int checkSpec(rpmts ts, Header h)
Parse spec file and build package.
static char * getTarSpec(const char *arg)
int rpmtsAddInstallElement(rpmts ts, Header h, const fnpyKey key, int upgrade, rpmRelocation *relocs)
Add package to be installed to transaction set.
int rpmMkdirs(const char *root, const char *pathstr)
Create several directories (including parents if needed) in one go.
rpmSpec rpmtsSetSpec(rpmts ts, rpmSpec spec)
Set a spec control structure in transaction set.
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
char * rpmGetPath(const char *path,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) expanded, canonicalized, file path.
void addMacro(rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
rpmSpec freeSpec(rpmSpec spec)
Destroy Spec structure.
#define _RPMVSF_NOSIGNATURES
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
char * rpmExpand(const char *arg,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) concatenated macro expansion(s).
struct rpmts_s * rpmts
The main types involved in transaction manipulation.
int rasprintf(char **strp, const char *fmt,...) RPM_GNUC_PRINTF(2
asprintf() clone
void rpmFreeRpmrc(void)
Destroy rpmrc arch/os compatibility tables.
#define _RPMVSF_NODIGESTS
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
Describe build command line request.
char * rpmGetCwd(void)
Like getcwd() but the result is malloced.
rpmRC buildSpec(rpmts ts, rpmSpec spec, int what, int test)
Build stages state machine driver.
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
Generate a log message using FMT string and option arguments.
struct headerToken_s * Header
RPM header and data retrieval types.