Ejemplo n.º 1
0
int check_versions(int *current_version,
		   int *server_version,
		   char *path_prefix)
{

	read_versions(current_version, server_version, path_prefix);

	if (*current_version < 0) {
		fprintf(stderr, "Error: Unable to determine current OS version\n");
		return -1;
	}
	if (*current_version == 0) {
		fprintf(stderr, "Update from version 0 not supported yet.\n");
		return -1;
	}
	if (SWUPD_VERSION_IS_DEVEL(*current_version) || SWUPD_VERSION_IS_RESVD(*current_version)) {
		fprintf(stderr, "Update of dev build not supported %d\n", *current_version);
		return -1;
	}
	swupd_curl_set_current_version(*current_version);

	/* set preferred version and content server urls */
	if (*current_version < 0) {
		have_network = false;
		return -1;
	}

	have_network = true;

	//TODO allow policy layer to send us to intermediate version?

	swupd_curl_set_requested_version(*server_version);

	return 0;
}
Ejemplo n.º 2
0
static void grab_version (FILE * out, const database_t * db,
                          cvs_connection_t * s, version_t * version)
{
    if (version == NULL || version->mark != SIZE_MAX)
        return;

    const char * path = version->file->path;
    const char * slash = strrchr (path, '/');
    // Make sure we have the directory.
    if (slash != NULL
        && (version->parent == NULL
            || version->parent->mark == SIZE_MAX
            || version->parent->mark <= cached_marks))
        cvs_printf (s, "Directory %s/%.*s\n" "%s%.*s\n",
                    s->module, (int) (slash - path), path,
                    s->prefix, (int) (slash - path), path);

    // Go to the main directory.
    cvs_printf (s,
                "Directory %s\n%.*s\n", s->module,
                (int) strlen (s->prefix) - 1, s->prefix);

    cvs_printff (s,
                 "Argument -kk\n"
                 "Argument -r%s\n"
                 "Argument --\n"
                 "Argument %s\nupdate\n",
                 version->version, version->file->path);

    read_versions (out, db, s);

    if (version->mark == SIZE_MAX)
        fatal ("cvs checkout - failed to get %s %s\n",
               version->file->path, version->version);
}
Ejemplo n.º 3
0
static void print_versions()
{
	int current_version, server_version;

	swupd_curl_init();
	read_versions(&current_version, &current_version, &server_version, path_prefix);

	if (current_version < 0) {
		printf("Cannot determine current OS version\n");
	} else {
		printf("Current OS version: %d\n", current_version);
	}

	if (server_version < 0) {
		printf("Cannot get latest the server version.Could not reach server\n");
	} else {
		printf("Latest server version: %d\n", server_version);
	}
}
Ejemplo n.º 4
0
int check_versions(int *current_version, int *server_version, int requested_version, char *path_prefix)
{
	if (read_versions(current_version, server_version, path_prefix) != 0) {
		return -1;
	}
	if (*current_version == 0) {
		fprintf(stderr, "Update from version 0 not supported yet.\n");
		return -1;
	}
	if (requested_version != -1) {
		if (requested_version <= *current_version) {
			fprintf(stderr, "Requested version for update (%d) must be greater than current version (%d)\n",
				requested_version, *current_version);
			return -1;
		}
		if (requested_version < *server_version) {
			*server_version = requested_version;
		}
	}

	return 0;
}
Ejemplo n.º 5
0
static void grab_by_option (FILE * out,
                            const database_t * db,
                            cvs_connection_t * s,
                            const char * r_arg,
                            const char * D_arg,
                            version_t ** fetch, version_t ** fetch_end)
{
    // Build an array of the paths that we're getting.  FIXME - if changeset
    // versions were sorted we wouldn't need this.
    const char ** paths = NULL;
    const char ** paths_end = NULL;

    for (version_t ** i = fetch; i != fetch_end; ++i) {
        version_t * v = version_live (*i);
        assert (v && v->used && v->mark == SIZE_MAX);
        ARRAY_APPEND (paths, v->file->path);
    }

    assert (paths != paths_end);

    ARRAY_SORT (paths, (int(*)(const void *, const void *)) strcmp);

    const char * d = NULL;
    ssize_t d_len = SSIZE_MAX;

    for (const char ** i = paths; i != paths_end; ++i) {
        const char * slash = strrchr (*i, '/');
        if (slash == NULL)
            continue;
        if (slash - *i == d_len && memcmp (*i, d, d_len) == 0)
            continue;
        // Tell the server about this directory.
        d = *i;
        d_len = slash - d;
        cvs_printf (s,
                    "Directory %s/%.*s\n"
                    "%s%.*s\n",
                    s->module, (int) d_len, d,
                    s->prefix, (int) d_len, d);
    }

    // Go to the main directory.
    cvs_printf (s,
                "Directory %s\n%.*s\n", s->module,
                (int) (strlen (s->prefix) - 1), s->prefix);

    // Update args:
    if (r_arg)
        cvs_printf (s, "Argument -r%s\n", r_arg);

    if (D_arg)
        cvs_printf (s, "Argument -D%s\n", D_arg);

    cvs_printf (s, "Argument -kk\n" "Argument --\n");

    for (const char ** i = paths; i != paths_end; ++i)
        cvs_printf (s, "Argument %s\n", *i);

    xfree (paths);

    cvs_printff (s, "update\n");

    read_versions (out, db, s);
}