PERFORCE change 124707 for review
Andrew Turner
andrew at FreeBSD.org
Sat Aug 4 22:12:58 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=124707
Change 124707 by andrew at andrew_hermies on 2007/08/05 05:12:46
Convert the patchlevel to a number when reading it from the tag file
Add db_next_patch to the fbsd_update_db struct to record the patch level that will be installed when "freebsd-update install" is run or 0 if no patches are avaliable
Use the value of db_next_patch to implement list_updates
Affected files ...
.. //depot/projects/soc2007/andrew-update/backend/facund-be.c#22 edit
Differences ...
==== //depot/projects/soc2007/andrew-update/backend/facund-be.c#22 (text+ko) ====
@@ -98,6 +98,8 @@
char *db_dir;
int db_fd;
+ unsigned int db_next_patch;
+
char *db_tag_file;
};
@@ -107,7 +109,7 @@
struct fbsd_tag_line {
char *tag_platform;
char *tag_release;
- char *tag_patch;
+ unsigned int tag_patch;
char tag_tindexhash[65];
char tag_eol[11];
};
@@ -120,7 +122,8 @@
{
struct fbsd_tag_line *line;
unsigned int len, item;
- const char *str, *ptr;
+ char *num_buf;
+ const char *str, *ptr, *errstr;
if (buf == NULL)
return NULL;
@@ -156,11 +159,16 @@
strlcpy(line->tag_release, str, len + 1);
break;
case 3:
- line->tag_patch = malloc(len + 1);
- if (line->tag_patch == NULL)
+ num_buf = malloc(len + 1);
+ if (num_buf == NULL)
goto facund_decode_tag_line_exit;
- strlcpy(line->tag_patch, str, len + 1);
+ strlcpy(num_buf, str, len + 1);
+ line->tag_patch = strtonum(num_buf, 0, UINT_MAX,
+ &errstr);
+ free(num_buf);
+ if (errstr != NULL)
+ goto facund_decode_tag_line_exit;
break;
case 4:
if (len != 64)
@@ -203,9 +211,6 @@
if (line->tag_release != NULL)
free(line->tag_release);
- if (line->tag_patch != NULL)
- free(line->tag_patch);
-
free(line);
}
@@ -233,6 +238,8 @@
while (fgets(buf, sizeof buf, tag_fd) != NULL) {
line = facund_tag_decode_line(buf);
if (line != NULL) {
+ watched_db[pos].db_next_patch =
+ line->tag_patch;
facund_tag_free(line);
}
}
@@ -459,6 +466,8 @@
return -1;
}
+ watched_db[pos].db_next_patch = 0;
+
ptr = next_ptr;
if (ptr[0] == '\0') {
return 0;
@@ -714,30 +723,51 @@
args = facund_object_new_array();
for (pos = 0; base_dirs[pos] != NULL; pos++) {
struct facund_object *pair, *item, *updates;
+ unsigned int i;
+ char *buf;
+
+ for (i = 0; i < watched_db_count; i++) {
+ if (strcmp(watched_db[i].db_base, base_dirs[pos]) != 0)
+ continue;
- pair = facund_object_new_array();
+ printf("= %u\n", watched_db[i].db_next_patch);
+ if (watched_db[i].db_next_patch == 0)
+ break;
+
+ pair = facund_object_new_array();
+
+ /* Add the directory to the start of the array */
+ item = facund_object_new_string();
+ facund_object_set_string(item, base_dirs[pos]);
+ facund_object_array_append(pair, item);
- /* Add the directory to the start of the array */
- item = facund_object_new_string();
- facund_object_set_string(item, base_dirs[pos]);
- facund_object_array_append(pair, item);
+ /* Add a list of updates to the array */
+ updates = facund_object_new_array();
+ item = facund_object_new_string();
+ asprintf(&buf, "6.2-p%u", watched_db[i].db_next_patch);
+ if (buf == NULL)
+ return facund_response_new(id, 1,
+ "Malloc failed", NULL);
- /* Add a list of updates to the array */
- updates = facund_object_new_array();
- item = facund_object_new_string();
- facund_object_set_string(item, "6.2-p2");
- facund_object_array_append(updates, item);
- facund_object_array_append(pair, updates);
+ facund_object_set_string(item, buf);
+ free(buf);
+ facund_object_array_append(updates, item);
+ facund_object_array_append(pair, updates);
- /* Add the directory on to the end of the arguments to return */
- facund_object_array_append(args, pair);
+ /*
+ * Add the directory on to the
+ * end of the arguments to return
+ */
+ facund_object_array_append(args, pair);
+ break;
+ }
+ }
+ facund_object_print(args);
+ if (facund_object_array_size(args) == 0) {
+ facund_object_free(args);
+ args = NULL;
}
- printf("STUB: %s (base: %s, ports: %s)\n", __func__,
- (get_base ? "yes" : "no"), (get_ports ? "yes" : "no"));
- for (pos = 0; base_dirs[pos] != NULL; pos++) {
- printf("Dir: %s\n", base_dirs[pos]);
- }
free(base_dirs);
return facund_response_new(id, RESP_GOOD, "Success", args);
}
More information about the p4-projects
mailing list