Ejemplo n.º 1
0
int rcps_check(struct rcps_problem *p) {
	/* XXX check for structural problems */
	int result = RCPS_CHECK_OK;
	result = check_dependencies( p );
	printf("rcps_check: result='%s'\n", rcps_error(result));
	return result;
}
/**
*  Make a new graph_node and a container list_node to hold it, to
*  represent the command COMMAND. Also check for any dependencies on commands
*  which have already been processed.
**/
graph_node *
process_command(command_t command)
{
  // new graph node
  graph_node *node = (graph_node *)checked_malloc(sizeof(graph_node));
  node->root = command;
  node->next = node->prev = NULL;
  node->pid = -1;
  node->before = NULL;
  node->before_size = 0;

  // new list node
  list_node *list = (list_node *)checked_malloc(sizeof(list_node));
  list->node = node;
  list->write_list = list->read_list = NULL;
  list->write_size = list->read_size = 0;
  list->next = list->prev = NULL;
  process_read_write(list, command);
  check_dependencies(list);

  // push to global dependencies linked list
  if (depend_head) {
    list->next = depend_head;
    depend_head->prev = list;
  }
  depend_head = list;

  return node;
}
Ejemplo n.º 3
0
optional<std::tuple<level_param_names, expr, expr>>
definition_cache::find(environment const & env, name const & n, expr const & pre_type, expr const & pre_value, bool is_trusted) {
    entry e;
    {
        lock_guard<mutex> lc(m_mutex);
        if (auto it = m_definitions.find(n)) {
            e = *it;
        } else {
            return optional<std::tuple<level_param_names, expr, expr>>();
        }
    }
    level_param_names ls;
    if (e.m_is_trusted == is_trusted &&
        expr_eq_modulo_placeholders_fn()(e.m_pre_type, pre_type) &&
        expr_eq_modulo_placeholders_fn()(e.m_pre_value, pre_value) &&
        get_fingerprint(env) == e.m_fingerprint &&
        check_dependencies(env, e.m_dependencies)) {
        return some(std::make_tuple(e.m_params, e.m_type, e.m_value));
    } else {
        return optional<std::tuple<level_param_names, expr, expr>>();
    }
}
Ejemplo n.º 4
0
void test_install( char *package, char *gisbase, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version )
{
  char tmp[2048];
  char dir[2048];
  char sysstr[2048];
  int error = stat( gisbase, &buf.st_dev );
  struct stat buf;
  FILE *f;
  char *verstr;
  char *grass_major;
  char *grass_minor;
  char *grass_revision;
  int major, minor, revision;
  if ( error < 0 )
  {
    print_error( -5, "installation directory invalid: %s\n", strerror( *(int*)(__errno_location( )) ) );
  }
  sprintf( GINSTALL_DST, "GINSTALL_DST=%s", gisbase );
  putenv( GINSTALL_DST );
  sprintf( tmp, "%s/include", gisbase );
  sprintf( GINSTALL_INC, "GINSTALL_INC=%s", tmp );
  putenv( GINSTALL_INC );
  sprintf( tmp, "%s/lib", gisbase );
  sprintf( GINSTALL_LIB, "GINSTALL_LIB=%s", tmp );
  putenv( GINSTALL_LIB );
  sprintf( GEM_GRASS_DIR, "GEM_GRASS_DIR=%s", gisbase );
  putenv( GEM_GRASS_DIR );
  verstr = strdup( grass_version );
  grass_major = strtok( verstr, "." );
  grass_minor = strtok( 0, "." );
  grass_revision = strtok( 0, "." );
  major = strtol( grass_major, 0, 10 );
  minor = strtol( grass_minor, 0, 10 );
  revision = strtol( grass_revision, 0, 10 );
  free( verstr );
  atexit( &exit_tmp );
  sprintf( dir, "%s/src", basename( package ) );
  error = chdir( dir );
  if ( error < 0 )
  {
    print_error( -2, "extension files in '%s' not accessible: %s\n", package, strerror( *(int*)(__errno_location( )) ) );
  }
  if ( SKIP_CFG == 0 )
  {
    if ( VERBOSE )
    {
      fwrite( "Running configure script:\n", 1, 26, stdout );
      sprintf( sysstr, "sh %s %s", CONFIG_CMD, CONFIG_OPTS );
      error = system( sysstr );
    }
    else
    {
      fwrite( "Configuring...", 1, 14, stdout );
      sprintf( sysstr, "sh %s %s --quiet &&gt; %s", CONFIG_CMD, CONFIG_OPTS, TMP_NULL );
      error = system( sysstr );
    }
    if ( error == -1 )
      print_error( -27, "could not run configure script.\n" );
    if ( error > 0 )
      print_error( -3, "system configuration failed.\n" );
    print_done( );
    print_cfg( );
  }
  sprintf( GEM_EXT_NAME, "GEM_EXT_NAME=%s", pkg_short_name );
  putenv( GEM_EXT_NAME );
  sprintf( tmp, "%i.%i.%i", pkg_major, pkg_minor, pkg_revision );
  sprintf( GEM_EXT_VERSION, "GEM_EXT_VERSION=%s", tmp );
  putenv( GEM_EXT_VERSION );
  dump_plain( "../description", TMP_DESCR );
  dump_plain( "../info", TMP_INFO );
  dump_plain( "../depends", TMP_DEPS );
  dump_plain( "../bugs", TMP_BUGS );
  dump_plain( "../authors", TMP_AUTHORS );
  sprintf( GEM_EXT_DESCR, "GEM_EXT_DESCR=%s", TMP_DESCR );
  putenv( GEM_EXT_DESCR );
  sprintf( GEM_EXT_INFO, "GEM_EXT_INFO=%s", TMP_INFO );
  putenv( GEM_EXT_INFO );
  sprintf( GEM_EXT_DEPS, "GEM_EXT_DEPS=%s", TMP_DEPS );
  putenv( GEM_EXT_DEPS );
  sprintf( GEM_EXT_BUGS, "GEM_EXT_BUGS=%s", TMP_BUGS );
  putenv( GEM_EXT_BUGS );
  sprintf( GEM_EXT_AUTHORS, "GEM_EXT_AUTHORS=%s", TMP_AUTHORS );
  putenv( GEM_EXT_AUTHORS );
  atexit( &exit_tmp );
  check_dependencies( package, gisbase, grass_version );
  if ( VERBOSE )
  {
    fprintf( stdout, "Running '%s':\n", MAKE_CMD );
    sprintf( sysstr, "%s -f Makefile", MAKE_CMD );
    error = system( sysstr );
  }
  else
  {
    fwrite( "Compiling...", 1, 12, stdout );
    sprintf( sysstr, "%s -f Makefile &&gt; %s", MAKE_CMD, TMP_NULL );
    error = system( sysstr );
  }
  if ( error == -1 && VERBOSE == 0 )
    print_error( -9, "could not run '%s' do you have make tools installed?\n", MAKE_CMD[0] );
  if ( error > 0 )
    print_error( -4, "source code could not be compiled.\n \t\t\tRun again with option -v to see what is causing trouble.\n" );
  print_done( );
  fwrite( "Installing...", 1, 13, stdout );
  f = (FILE*)fopen( "../uninstall", "r" );
  if ( f == 0 )
  {
    print_warning( "error checking for uninstall script: %s\n \t\t\t\tUninstalling this extension may leave orphaned files on your system", strerror( *(int*)(__errno_location( )) ) );
  }
  else
    fclose( f );
  register_extension( gisbase, "src", pkg_short_name, pkg_major, pkg_minor, pkg_revision );
  check_dependencies( package, gisbase, grass_version );
  if ( major == 6 && minor <= 0 )
    register_entries_gisman( pkg_short_name, gisbase );
  register_entries_gisman2( pkg_short_name, gisbase );
  register_html( pkg_short_name, gisbase, pkg_major, pkg_minor, pkg_revision );
  fprintf( stdout, "(skipping '%s install')...", MAKE_CMD );
  print_done( );
  return;
}
Ejemplo n.º 5
0
void bin_install( char *package, char *gisbase, char *bins, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version )
{
  char tmp[2048];
  char dir[2048];
  char install_cmd[2048];
  char post_cmd[2048];
  int error = stat( gisbase, &buf.st_dev );
  struct stat buf;
  FILE *f;
  char *verstr;
  char *grass_major;
  char *grass_minor;
  char *grass_revision;
  int major, minor, revision;
  if ( error < 0 )
  {
    print_error( -5, "installation directory invalid: %s\n", strerror( *(int*)(__errno_location( )) ) );
  }
  sprintf( GINSTALL_DST, "GINSTALL_DST=%s", gisbase );
  putenv( GINSTALL_DST );
  sprintf( tmp, "%s/include", gisbase );
  sprintf( GINSTALL_INC, "GINSTALL_INC=%s", tmp );
  putenv( GINSTALL_INC );
  sprintf( tmp, "%s/lib", gisbase );
  sprintf( GINSTALL_LIB, "GINSTALL_LIB=%s", tmp );
  putenv( GINSTALL_LIB );
  sprintf( GEM_GRASS_DIR, "GEM_GRASS_DIR=%s", gisbase );
  putenv( GEM_GRASS_DIR );
  verstr = strdup( grass_version );
  grass_major = strtok( verstr, "." );
  grass_minor = strtok( 0, "." );
  grass_revision = strtok( 0, "." );
  major = strtol( grass_major, 0, 10 );
  minor = strtol( grass_minor, 0, 10 );
  revision = strtol( grass_revision, 0, 10 );
  free( verstr );
  atexit( &exit_tmp );
  sprintf( dir, "%s/%s", basename( package ), bins );
  error = chdir( dir );
  if ( error < 0 )
  {
    print_error( -2, "extension file binaries in '%s' not accessible: %s\n", package, strerror( *(int*)(__errno_location( )) ) );
  }
  sprintf( GEM_EXT_NAME, "GEM_EXT_NAME=%s", pkg_short_name );
  putenv( GEM_EXT_NAME );
  sprintf( tmp, "%i.%i.%i", pkg_major, pkg_minor, pkg_revision );
  sprintf( GEM_EXT_VERSION, "GEM_EXT_VERSION=%s", tmp );
  putenv( GEM_EXT_VERSION );
  dump_html( "../description", TMP_DESCR );
  dump_html( "../info", TMP_INFO );
  dump_html( "../depends", TMP_DEPS );
  dump_html( "../bugs", TMP_BUGS );
  dump_html( "../authors", TMP_AUTHORS );
  sprintf( GEM_EXT_DESCR, "GEM_EXT_DESCR=%s", TMP_DESCR );
  putenv( GEM_EXT_DESCR );
  sprintf( GEM_EXT_INFO, "GEM_EXT_INFO=%s", TMP_INFO );
  putenv( GEM_EXT_INFO );
  sprintf( GEM_EXT_DEPS, "GEM_EXT_DEPS=%s", TMP_DEPS );
  putenv( GEM_EXT_DEPS );
  sprintf( GEM_EXT_BUGS, "GEM_EXT_BUGS=%s", TMP_BUGS );
  putenv( GEM_EXT_BUGS );
  sprintf( GEM_EXT_AUTHORS, "GEM_EXT_AUTHORS=%s", TMP_AUTHORS );
  putenv( GEM_EXT_AUTHORS );
  atexit( &exit_tmp );
  check_dependencies( package, gisbase, grass_version );
  fwrite( "Installing...", 1, 13, stdout );
  f = (FILE*)fopen( "../uninstall", "r" );
  if ( f == 0 )
  {
    print_warning( "error checking for uninstall script: %s\n \t\t\t\tUninstalling this extension may leave orphaned files on your system", strerror( *(int*)(__errno_location( )) ) );
  }
  else
  {
    if ( VERBOSE )
    {
      sprintf( tmp, "cp -vf ../uninstall %s/etc/uninstall.%s ;", gisbase, pkg_short_name );
      strcpy( UNINSTALL_CMD, tmp );
    }
    else
    {
      sprintf( tmp, "cp -f ../uninstall %s/etc/uninstall.%s &&gt; %s ;", gisbase, pkg_short_name, TMP_NULL );
      strcpy( UNINSTALL_CMD, tmp );
    }
    fclose( f );
  }
  register_extension( gisbase, bins, pkg_short_name, pkg_major, pkg_minor, pkg_revision );
  check_dependencies( package, gisbase, grass_version );
  if ( major == 6 && minor <= 0 )
    register_entries_gisman( pkg_short_name, gisbase );
  register_entries_gisman2( pkg_short_name, gisbase );
  register_html( pkg_short_name, gisbase, pkg_major, pkg_minor, pkg_revision );
  if ( VERBOSE )
  {
    fprintf( stdout, "Running '%s install':\n", MAKE_CMD );
    sprintf( install_cmd, "bin/%s -f Makefile install ; \t\t\t\t\tcp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;", MAKE_CMD, TMPDB, gisbase, gisbase );
  }
  else
    sprintf( install_cmd, "bin/%s -f Makefile -s install &&gt; %s ; \t\t\t\t\tcp -f %s %s/etc/extensions.db &&gt; %s ; chmod a+r %s/etc/extensions.db &&gt; %s ;", MAKE_CMD, TMP_NULL, TMPDB, gisbase, TMP_NULL, gisbase, TMP_NULL );
  if ( VERBOSE )
    memcpy( post_cmd, "sh ../post", 11 );
  else
    sprintf( post_cmd, "sh ../post &&gt; %s", TMP_NULL );
  sprintf( tmp, "%s %s %s %s %s %s", install_cmd, UNINSTALL_CMD, GISMAN_CMD, GISMAN2_CMD, HTML_CMD, post_cmd );
  su( gisbase, tmp );
  print_done( );
  return;
}