add generation time to package versions
This commit is contained in:
@@ -185,11 +185,11 @@ static void process_packages(char *filename, char *product, bool update)
|
|||||||
|
|
||||||
while (fgets(line, sizeof(line), file))
|
while (fgets(line, sizeof(line), file))
|
||||||
{
|
{
|
||||||
char *package, *version, *current_version;
|
char *package, *version, *cur_version;
|
||||||
bool security, update_version = TRUE;
|
bool security, update_version = TRUE;
|
||||||
int current_security;
|
int cur_security;
|
||||||
u_int32_t gid = 0, vid = 0;
|
u_int32_t gid = 0, vid = 0;
|
||||||
time_t generation_time;
|
time_t gen_time, cur_time;
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
@@ -198,16 +198,16 @@ static void process_packages(char *filename, char *product, bool update)
|
|||||||
}
|
}
|
||||||
if (count == 3)
|
if (count == 3)
|
||||||
{
|
{
|
||||||
generation_time = extract_time(line);
|
gen_time = extract_time(line);
|
||||||
|
|
||||||
if (generation_time == UNDEFINED_TIME)
|
if (gen_time == UNDEFINED_TIME)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "could not extract generation time\n");
|
fprintf(stderr, "could not extract generation time\n");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
db->destroy(db);
|
db->destroy(db);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("Generated: %T\n", &generation_time, TRUE);
|
printf("Generated: %T\n", &gen_time, TRUE);
|
||||||
}
|
}
|
||||||
if (count < 7)
|
if (count < 7)
|
||||||
{
|
{
|
||||||
@@ -286,14 +286,15 @@ static void process_packages(char *filename, char *product, bool update)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check for package versions already in database */
|
/* check for package versions already in database */
|
||||||
e = db->query(db, "SELECT id, release, security FROM versions "
|
e = db->query(db,
|
||||||
"WHERE package = ? AND product = ?",
|
"SELECT id, release, security, time FROM versions "
|
||||||
DB_INT, gid, DB_INT, pid, DB_INT, DB_TEXT, DB_INT);
|
"WHERE package = ? AND product = ?",
|
||||||
|
DB_INT, gid, DB_INT, pid, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
while (e->enumerate(e, &vid, ¤t_version, ¤t_security))
|
while (e->enumerate(e, &vid, &cur_version, &cur_security, &cur_time))
|
||||||
{
|
{
|
||||||
if (streq(version, current_version))
|
if (streq(version, cur_version))
|
||||||
{
|
{
|
||||||
update_version = FALSE;
|
update_version = FALSE;
|
||||||
}
|
}
|
||||||
@@ -302,12 +303,13 @@ static void process_packages(char *filename, char *product, bool update)
|
|||||||
}
|
}
|
||||||
if ((!vid && security) || (vid && update_version))
|
if ((!vid && security) || (vid && update_version))
|
||||||
{
|
{
|
||||||
printf("'%s' (%s) %s\n", package, version, security ? "[s]" : "");
|
printf("%s (%s) %s\n", package, version, security ? "[s]" : "");
|
||||||
|
|
||||||
if (db->execute(db, &gid,
|
if (db->execute(db, &gid,
|
||||||
"INSERT INTO versions (package, product, release, security) "
|
"INSERT INTO versions "
|
||||||
"VALUES (?, ?, ?, ?)", DB_INT, gid, DB_INT, pid,
|
"(package, product, release, security, time) "
|
||||||
DB_TEXT, version, DB_INT, security) != 1)
|
"VALUES (?, ?, ?, ?, ?)", DB_INT, gid, DB_INT, pid,
|
||||||
|
DB_TEXT, version, DB_INT, security, DB_INT, gen_time) != 1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "could not store version '%s' to database\n",
|
fprintf(stderr, "could not store version '%s' to database\n",
|
||||||
version);
|
version);
|
||||||
|
|||||||
@@ -913,12 +913,12 @@ METHOD(attest_db_t, list_packages, void,
|
|||||||
{
|
{
|
||||||
if (gid != gid_old)
|
if (gid != gid_old)
|
||||||
{
|
{
|
||||||
printf("%5d: %s", gid, package);
|
printf("%5d: %s,", gid, package);
|
||||||
gid_old = gid;
|
gid_old = gid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spaces = 7 + strlen(package);
|
spaces = 8 + strlen(package);
|
||||||
while (spaces--)
|
while (spaces--)
|
||||||
{
|
{
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|||||||
Reference in New Issue
Block a user