plover/transaction.c
changeset 42 419a02fa70db
parent 38 a29623b68ca2
child 43 6b3034a884dc
     1.1 --- a/plover/transaction.c	Mon Jun 13 12:18:42 2016 +0100
     1.2 +++ b/plover/transaction.c	Thu Jun 16 12:11:14 2016 +0100
     1.3 @@ -428,22 +428,46 @@
     1.4    const char *install_root,GError **error)
     1.5  {
     1.6      PloverPackageSet *installed;
     1.7 +    const char *install_uri;
     1.8 +    gchar *install_path;
     1.9 +    GFile *file;
    1.10 +    gboolean retval;
    1.11      g_return_val_if_fail(PLOVER_IS_TRANSACTION(transaction),FALSE);
    1.12      if (!install_root)
    1.13 -	install_root=g_getenv("RAZOR_ROOT");
    1.14 -    if (!install_root)
    1.15 -	install_root="";
    1.16 -    if (transaction->installed && !g_strcmp0(install_root,
    1.17 +    {
    1.18 +	install_uri=g_getenv("RAZOR_ROOT");
    1.19 +	if (install_uri)
    1.20 +	{
    1.21 +	    file=g_file_new_for_uri(install_uri);
    1.22 +	    install_path=g_file_get_path(file);
    1.23 +	    g_object_unref(file);
    1.24 +	    if (!install_path)
    1.25 +	    {
    1.26 +		g_set_error(error,PLOVER_GENERAL_ERROR,
    1.27 +		  PLOVER_GENERAL_ERROR_FAILED,
    1.28 +		  "%s: Not a local URI",install_uri);
    1.29 +		return FALSE;
    1.30 +	    }
    1.31 +	}
    1.32 +	else
    1.33 +	    install_path=g_strdup("/");
    1.34 +    }
    1.35 +    else
    1.36 +	install_path=g_strdup(install_root);
    1.37 +    if (transaction->installed && !g_strcmp0(install_path,
    1.38        plover_package_set_get_install_root(transaction->installed)))
    1.39 +    {
    1.40 +	g_free(install_path);
    1.41  	return TRUE;
    1.42 +    }
    1.43      installed=plover_package_set_new();
    1.44 -    if (!plover_package_set_open(installed,install_root,TRUE,error))
    1.45 -    {
    1.46 +    retval=plover_package_set_open(installed,install_path,TRUE,error);
    1.47 +    if (retval)
    1.48 +	plover_transaction_set_installed(transaction,installed);
    1.49 +    else
    1.50  	g_object_unref(installed);
    1.51 -	return FALSE;
    1.52 -    }
    1.53 -    plover_transaction_set_installed(transaction,installed);
    1.54 -    return TRUE;
    1.55 +    g_free(install_path);
    1.56 +    return retval;
    1.57  }
    1.58  
    1.59  struct razor_set *plover_transaction_import_yum(PloverTransaction *transaction,
    1.60 @@ -709,7 +733,8 @@
    1.61  {
    1.62      int i,changed,is_leaf;
    1.63      uint32_t flags;
    1.64 -    const char *install_root;
    1.65 +    gchar *install_path;
    1.66 +    const char *install_uri;
    1.67      const char *name,*version,*maybe_unused_name;
    1.68      struct razor_set *system,*upstream;
    1.69      struct razor_transaction *trans;
    1.70 @@ -717,6 +742,7 @@
    1.71      PloverTransaction *transaction;
    1.72      struct plover_vector *package_names;
    1.73      GList *to_remove,*lnk,*lnk2,*what_requires,*what_provides;
    1.74 +    GFile *file;
    1.75      struct razor_package *package,*maybe_unused_package;
    1.76      struct razor_property *property;
    1.77      struct razor_package_query *query;
    1.78 @@ -724,15 +750,29 @@
    1.79      struct razor_property_iterator *removed_props;
    1.80      if (!pkgs)
    1.81  	return plover_transaction_new_remove(NULL,error);
    1.82 +    install_uri=g_getenv("RAZOR_ROOT");
    1.83 +    if (install_uri)
    1.84 +    {
    1.85 +	file=g_file_new_for_uri(install_uri);
    1.86 +	install_path=g_file_get_path(file);
    1.87 +	g_object_unref(file);
    1.88 +	if (!install_path)
    1.89 +	{
    1.90 +	    g_set_error(error,PLOVER_GENERAL_ERROR,PLOVER_GENERAL_ERROR_FAILED,
    1.91 +	      "%s: Not a local URI",install_uri);
    1.92 +	    return NULL;
    1.93 +	}
    1.94 +    }
    1.95 +    else
    1.96 +	install_path=g_strdup("/");
    1.97      installed=plover_package_set_new();
    1.98 -    install_root=g_getenv("RAZOR_ROOT");
    1.99 -    if (!install_root)
   1.100 -	install_root="";
   1.101 -    if (!plover_package_set_open(installed,install_root,TRUE,error))
   1.102 +    if (!plover_package_set_open(installed,install_path,TRUE,error))
   1.103      {
   1.104  	g_object_unref(installed);
   1.105 +	g_free(install_path);
   1.106  	return NULL;
   1.107      }
   1.108 +    g_free(install_path);
   1.109      system=plover_package_set_get_razor(installed);
   1.110      package_names=plover_vector_new();
   1.111      for(i=0;pkgs[i];i++)