65 char BuildVersion[]=
"pkgagent build version: " VERSION_S
" r(" COMMIT_HASH_S
").\n";
76 int main (
int argc,
char *argv[])
79 char *agent_desc =
"Pulls metadata out of RPM or DEBIAN packages";
87 char *AgentARSName =
"pkgagent_ars";
93 char agent_rev[MAXCMD];
103 sprintf(agent_rev,
"%s.%s", VERSION, COMMIT_HASH);
107 while((c = getopt(argc,argv,
"ic:CvVh")) != -1)
133 if (CmdlineFlag == 0)
144 LOG_ERROR(
"You have no update permissions on upload %d",
upload_pk);
159 snprintf(sqlbuf,
sizeof(sqlbuf),
160 "select ars_pk from pkgagent_ars,agent \
161 where agent_pk=agent_fk and ars_success=true \
162 and upload_fk='%d' and agent_fk='%d'",
164 ars_result = PQexec(
db_conn, sqlbuf);
166 if (PQntuples(ars_result) > 0)
169 LOG_WARNING(
"Ignoring requested pkgagent analysis of upload %d - Results are already in database.\n",
upload_pk);
186 if (
Verbose) { printf(
"DEBUG: running in cli mode, processing file(s)\n");}
187 for (; optind < argc; optind++)
191 rpmReadConfigFiles(NULL, NULL);
int Verbose
Verbose level.
FUNCTION int ProcessUpload(int upload_pk, int agent_fk)
Process a single upload - read the first 32 bytes in each file.
int Agent_pk
agent identifier
Usage()
Print Usage statement.
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
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 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.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
#define PERM_WRITE
Read-Write permission.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
char * fo_scheduler_current()
Get the last read string from the scheduler.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
int main(int argc, char *argv[])
main function for the pkgagent
int GetMetadata(char *pkg, struct rpmpkginfo *pi)
Get RPM package info.
PGconn * db_conn
The connection to Database.
Holds meta info of rpm packages.
int req_size
Package dependency list size.
char ** requires
Package dependency list.