77 char BuildVersion[]=
"pkgagent build version: " VERSION_S
" r(" COMMIT_HASH_S
").\n";
88 int main (
int argc,
char *argv[])
91 char *agent_desc =
"Pulls metadata out of RPM or DEBIAN packages";
99 char *AgentARSName =
"pkgagent_ars";
101 PGresult *ars_result;
105 char agent_rev[MAXCMD];
115 sprintf(agent_rev,
"%s.%s", VERSION, COMMIT_HASH);
119 while((c = getopt(argc,argv,
"ic:CvVh")) != -1)
145 if (CmdlineFlag == 0)
156 LOG_ERROR(
"You have no update permissions on upload %d", upload_pk);
160 if (
Verbose) { printf(
"PKG: pkgagent read %d\n", upload_pk);}
161 if (upload_pk ==0)
continue;
171 snprintf(sqlbuf,
sizeof(sqlbuf),
172 "select ars_pk from pkgagent_ars,agent \ 173 where agent_pk=agent_fk and ars_success=true \ 174 and upload_fk='%d' and agent_fk='%d'",
175 upload_pk, Agent_pk);
176 ars_result = PQexec(
db_conn, sqlbuf);
178 if (PQntuples(ars_result) > 0)
181 LOG_WARNING(
"Ignoring requested pkgagent analysis of upload %d - Results are already in database.\n",upload_pk);
198 if (
Verbose) { printf(
"DEBUG: running in cli mode, processing file(s)\n");}
199 for (; optind < argc; optind++)
203 rpmReadConfigFiles(NULL, NULL);
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int GetMetadata(char *pkg, struct rpmpkginfo *pi)
Get RPM package info.
FUNCTION int ProcessUpload(int upload_pk, int agent_fk)
Process a single upload - read the first 32 bytes in each file.
int Verbose
Verbose level.
char * fo_scheduler_current()
Get the last read string from the scheduler.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
Holds meta info of rpm packages.
char ** requires
Package dependency list.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
Usage()
Print Usage statement.
int Agent_pk
agent identifier
int main(int argc, char *argv[])
main function for the pkgagent
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
FUNCTION int fo_GetAgentKey(PGconn *pgConn, const char *agent_name, long Upload_pk, const char *rev, const char *agent_desc)
Get the latest enabled agent key (agent_pk) from the database.
PGconn * db_conn
The connection to Database.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
FUNCTION int fo_WriteARS(PGconn *pgConn, int ars_pk, int upload_pk, int agent_pk, const char *tableName, const char *ars_status, int ars_success)
Write ars record.
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
int req_size
Package dependency list size.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
#define PERM_WRITE
Read-Write permission.