Esempio n. 1
0
static void dcc_note_compiled(const char *input_file, const char *output_file)
{
    const char *input_base, *output_base;

    input_base = dcc_find_basename(input_file);
    output_base = dcc_find_basename(output_file);

    rs_log(RS_LOG_INFO|RS_LOG_NONAME,
           "compile from %s to %s", input_base, output_base);
}
Esempio n. 2
0
/**
 * Record the state of this process.
 *
 * The filename is trimmed down to its basename.
 *
 * If the source_file or host are NULL, then are left unchanged from
 * their previous value.
 **/
int dcc_note_state(enum dcc_phase state,
                   const char *source_file,
                   const char *host, enum dcc_host target)
{
    int fd;
    int ret;
    char *fname;
    struct timeval tv;


	if (!direct_my_state(target))
		return -1;

    my_state->struct_size = sizeof *my_state;
    my_state->magic = DCC_STATE_MAGIC;
    my_state->cpid = (unsigned long) getpid();

    if ((ret = dcc_get_state_filename(&fname)))
        return ret;

    source_file = dcc_find_basename(source_file);
    if (source_file) {
        strlcpy(my_state->file, source_file, sizeof my_state->file);
    }

    if (host) {
        strlcpy(my_state->host, host, sizeof my_state->host);
    }

    if (gettimeofday(&tv, NULL) == -1) {
        rs_log_error("gettimeofday failed: %s", strerror(errno));
        return EXIT_DISTCC_FAILED;
    }
    my_state->curr_phase = state;

    rs_trace("note state %d, file \"%s\", host \"%s\"",
             state,
             source_file ? source_file : "(NULL)",
             host ? host : "(NULL)");

    if ((ret = dcc_open_state(&fd, fname))) {
        free(fname);
        return ret;
    }

    if ((ret = dcc_write_state(fd))) {
        dcc_close(fd);
        free(fname);
        return ret;
    }

    dcc_close(fd);
    free(fname);

    return 0;
}
Esempio n. 3
0
/* Some files should always be built locally... */
int
dcc_source_needs_local(const char *filename)
{
    const char *p;

    p = dcc_find_basename(filename);

    if (str_startswith("conftest.", p) || str_startswith("tmp.conftest.", p)) {
        rs_trace("autoconf tests are run locally: %s", filename);
        return EXIT_DISTCC_FAILED;
    }

    return 0;
}
Esempio n. 4
0
/* Given the name of a dotd file, and the name of the directory
 * masquerading as root, write a @p new_dotd file that
 * contains everything in dotd, but with the "root" directory removed.
 * It will also substitute client_out_name for server_out_name,
 * rewriting the dependency target.
 */
int dcc_cleanup_dotd(const char *dotd_fname,
                     char **new_dotd_fname,
                     const char *root_dir,
                     const char *client_out_name,
                     const char *server_out_name)
{
    /* When we do the substitution of server-side output name to
     * client-side output name, we may end up with a line that
     * longer than the longest line we expect from the compiler.
     */
    char buf[2 * MAX_DOTD_LINE_LEN];

    FILE *dotd, *tmp_dotd;
    char *found;
    int ret;

    dotd = fopen(dotd_fname, "r");
    if (dotd == NULL) {
        return 1;
    }
    ret = dcc_make_tmpnam(dcc_find_basename(dotd_fname),
                          ".d", new_dotd_fname);

    if (ret) {
        fclose(dotd);
        return ret;
    }

    tmp_dotd = fopen(*new_dotd_fname, "w");
    if (tmp_dotd == NULL) {
        fclose(dotd);
        return 1;
    }

    while (fgets(buf, MAX_DOTD_LINE_LEN, dotd)) {
        if ((strchr(buf, '\n') == NULL) && !feof(dotd)) {
            /* Line length must have exceeded MAX_DOTD_LINE_LEN: bail out. */
            fclose(dotd);
            fclose(tmp_dotd);
            return 1;
        }

        /* First, the dependency target substitution */
        if (dcc_strgraft(buf, sizeof(buf),
                         server_out_name, client_out_name)) {
            fclose(dotd);
            fclose(tmp_dotd);
            return 1;
        }

        /* Second, the trimming of the "root" directory" */
        found = strstr(buf, root_dir);
        while (found) {
            char *rest_of_buf = found + strlen(root_dir);
            memmove(found, rest_of_buf, strlen(rest_of_buf) + 1);
            found = strstr(found, root_dir);
        }
        if (fprintf(tmp_dotd, "%s", buf) < 0) {
            fclose(dotd);
            fclose(tmp_dotd);
            return 1;
        }
    }
    if (ferror(dotd) || ferror(tmp_dotd)) {
       return 1;
    }
    fclose(dotd);
    if (fclose(tmp_dotd) < 0) {
        return 1;
    }
    return 0;
}