{"action":"created","comment":{"url":"https://api.github.com/repos/endlessm/eos-updater/pulls/comments/53856236","id":53856236,"diff_hunk":"@@ -154,14 +211,147 @@ eos_updater_resolve_upgrade (EosUpdater  *updater,\n   if (!ostree_parse_refspec (o_refspec, &o_remote, &o_ref, error))\n     goto out;\n \n-  ret = (o_remote && o_ref && *o_remote && *o_ref);\n-\n   shuffle_out_values (upgrade_remote, o_remote, NULL);\n   shuffle_out_values (upgrade_ref, o_ref, NULL);\n \n   if (booted_checksum)\n     *booted_checksum = g_strdup (booted);\n \n+  /* Get branch configuration data baseurl */\n+  repo_config = ostree_repo_get_config (repo);\n+  osgroup = g_strdup_printf (\"remote \\\"%s\\\"\", osname);\n+  baseurl = g_key_file_get_string (repo_config, osgroup, \"url\", NULL);\n+  if (!baseurl)\n+    {\n+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,\n+                   \"No url found for %s, cannot upgrade\", osname);\n+      goto out;\n+    }\n+\n+  /* Get product identifier */\n+  hw_descriptors = g_hash_table_new_full (g_str_hash, g_str_equal,\n+                                          g_free, g_free);\n+  if (g_file_test (DT_COMPATIBLE, G_FILE_TEST_EXISTS))\n+    { /* ARM */\n+      gs_unref_object GFile *fp = NULL;\n+      gs_free gchar *fc = NULL;\n+\n+      fp = g_file_new_for_path (DT_COMPATIBLE);\n+      if (g_file_load_contents (fp, NULL, &fc, NULL, NULL, NULL))\n+        {\n+          gs_strfreev gchar **sv = g_strsplit (fc, \",\", -1);\n+\n+          if (sv && sv[0])\n+            g_hash_table_insert (hw_descriptors, g_strdup (\"sys_vendor\"),\n+                                 g_strdup (g_strstrip (sv[0])));\n+          if (sv && sv[1])\n+            g_hash_table_insert (hw_descriptors, g_strdup (\"product_name\"),\n+                                 g_strdup (g_strstrip (sv[1])));\n+        }\n+    }\n+  else\n+    { /* X86 */\n+      guint i;\n+\n+      for (i = 0; dmi_attributes[i]; i++)\n+        {\n+          gs_free gchar *path = NULL;\n+          gs_unref_object GFile *fp = NULL;\n+          gs_free gchar *fc = NULL;\n+          gsize len;\n+\n+          path = g_strconcat (DMI_PATH, dmi_attributes[i], NULL);\n+          fp = g_file_new_for_path (path);\n+          if (g_file_load_contents (fp, NULL, &fc, &len, NULL, NULL))\n+          {\n+              if (len > 128)\n+                fc[128] = '\\0';\n+              g_hash_table_insert (hw_descriptors, g_strdup (dmi_attributes[i]),\n+                                   g_strdup (g_strstrip (fc)));\n+          }\n+        }\n+    }\n+\n+  if (!g_hash_table_lookup (hw_descriptors, \"sys_vendor\"))\n+    g_hash_table_insert (hw_descriptors, g_strdup (\"sys_vendor\"),\n+                         g_strdup (\"EOSUNKNOWN\"));\n+\n+  if (!g_hash_table_lookup (hw_descriptors, \"product_name\"))\n+    g_hash_table_insert (hw_descriptors, g_strdup (\"product_name\"),\n+                         g_strdup (\"EOSUNKNOWN\"));\n+\n+  vendor = g_strdup (g_hash_table_lookup (hw_descriptors, \"sys_vendor\"));\n+  product = g_strdup (g_hash_table_lookup (hw_descriptors, \"product_name\"));\n+  p_id = g_strconcat (cleanstr (vendor), \" \", cleanstr (product), NULL);\n+  message (\"Product group: %s\", p_id);\n+\n+  /* Build the HTTP URI */\n+  g_hash_table_insert (hw_descriptors, g_strdup (\"ref\"), g_strdup (o_ref));\n+  g_hash_table_insert (hw_descriptors, g_strdup (\"commit\"), g_strdup (booted));\n+  query = soup_form_encode_hash (hw_descriptors);\n+  uri = g_strconcat (baseurl, \"/\", BRANCHES_CONFIG_PATH, \"?\", query, NULL);\n+  g_hash_table_destroy (hw_descriptors);\n+  message (\"Branches configuration URI: %s\", uri);\n+\n+  /* Download branch configuration data */\n+  soup = soup_session_new ();\n+  msg = soup_message_new (\"GET\", uri);\n+  status = soup_session_send_message (soup, msg);\n+  if (!SOUP_STATUS_IS_SUCCESSFUL (status))\n+    {\n+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_HOST_NOT_FOUND,\n+                   \"Failed to download branch config data (HTTP %d),\"\n+                   \" cannot upgrade\", status);\n+      goto out;\n+    }\n+\n+  g_object_get (G_OBJECT (msg), \"response-body\", &msg_body, NULL);","path":"src/eos-updater-util.c","position":187,"original_position":187,"commit_id":"a0956557c3152bc8971b28a4c5e88c86680d7979","original_commit_id":"a0956557c3152bc8971b28a4c5e88c86680d7979","user":{"login":"cosimoc","id":13906,"avatar_url":"https://avatars.githubusercontent.com/u/13906?v=3","gravatar_id":"","url":"https://api.github.com/users/cosimoc","html_url":"https://github.com/cosimoc","followers_url":"https://api.github.com/users/cosimoc/followers","following_url":"https://api.github.com/users/cosimoc/following{/other_user}","gists_url":"https://api.github.com/users/cosimoc/gists{/gist_id}","starred_url":"https://api.github.com/users/cosimoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cosimoc/subscriptions","organizations_url":"https://api.github.com/users/cosimoc/orgs","repos_url":"https://api.github.com/users/cosimoc/repos","events_url":"https://api.github.com/users/cosimoc/events{/privacy}","received_events_url":"https://api.github.com/users/cosimoc/received_events","type":"User","site_admin":false},"body":"True, but `g_object_get()` will copy it for you. If it's accessed directly like you suggest in another comment, it should not be necessary to free it.","created_at":"2016-02-23T21:50:01Z","updated_at":"2016-02-23T21:50:01Z","html_url":"https://github.com/endlessm/eos-updater/pull/26#discussion_r53856236","pull_request_url":"https://api.github.com/repos/endlessm/eos-updater/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/comments/53856236"},"html":{"href":"https://github.com/endlessm/eos-updater/pull/26#discussion_r53856236"},"pull_request":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/endlessm/eos-updater/pulls/26","id":58500998,"html_url":"https://github.com/endlessm/eos-updater/pull/26","diff_url":"https://github.com/endlessm/eos-updater/pull/26.diff","patch_url":"https://github.com/endlessm/eos-updater/pull/26.patch","issue_url":"https://api.github.com/repos/endlessm/eos-updater/issues/26","number":26,"state":"open","locked":false,"title":"Select OSTree branch at run-time based on product model","user":{"login":"jprvita","id":73894,"avatar_url":"https://avatars.githubusercontent.com/u/73894?v=3","gravatar_id":"","url":"https://api.github.com/users/jprvita","html_url":"https://github.com/jprvita","followers_url":"https://api.github.com/users/jprvita/followers","following_url":"https://api.github.com/users/jprvita/following{/other_user}","gists_url":"https://api.github.com/users/jprvita/gists{/gist_id}","starred_url":"https://api.github.com/users/jprvita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jprvita/subscriptions","organizations_url":"https://api.github.com/users/jprvita/orgs","repos_url":"https://api.github.com/users/jprvita/repos","events_url":"https://api.github.com/users/jprvita/events{/privacy}","received_events_url":"https://api.github.com/users/jprvita/received_events","type":"User","site_admin":false},"body":"[endlessm/eos-shell#6079]","created_at":"2016-02-05T23:52:40Z","updated_at":"2016-02-23T21:50:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd161783929f4ea377cdf5dd41d527afe44bb14c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/endlessm/eos-updater/pulls/26/commits","review_comments_url":"https://api.github.com/repos/endlessm/eos-updater/pulls/26/comments","review_comment_url":"https://api.github.com/repos/endlessm/eos-updater/pulls/comments{/number}","comments_url":"https://api.github.com/repos/endlessm/eos-updater/issues/26/comments","statuses_url":"https://api.github.com/repos/endlessm/eos-updater/statuses/a0956557c3152bc8971b28a4c5e88c86680d7979","head":{"label":"endlessm:shell/6079","ref":"shell/6079","sha":"a0956557c3152bc8971b28a4c5e88c86680d7979","user":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"repo":{"id":13253303,"name":"eos-updater","full_name":"endlessm/eos-updater","owner":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endlessm/eos-updater","description":"System components of the OS Tree based updater","fork":false,"url":"https://api.github.com/repos/endlessm/eos-updater","forks_url":"https://api.github.com/repos/endlessm/eos-updater/forks","keys_url":"https://api.github.com/repos/endlessm/eos-updater/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endlessm/eos-updater/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endlessm/eos-updater/teams","hooks_url":"https://api.github.com/repos/endlessm/eos-updater/hooks","issue_events_url":"https://api.github.com/repos/endlessm/eos-updater/issues/events{/number}","events_url":"https://api.github.com/repos/endlessm/eos-updater/events","assignees_url":"https://api.github.com/repos/endlessm/eos-updater/assignees{/user}","branches_url":"https://api.github.com/repos/endlessm/eos-updater/branches{/branch}","tags_url":"https://api.github.com/repos/endlessm/eos-updater/tags","blobs_url":"https://api.github.com/repos/endlessm/eos-updater/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endlessm/eos-updater/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endlessm/eos-updater/git/refs{/sha}","trees_url":"https://api.github.com/repos/endlessm/eos-updater/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endlessm/eos-updater/statuses/{sha}","languages_url":"https://api.github.com/repos/endlessm/eos-updater/languages","stargazers_url":"https://api.github.com/repos/endlessm/eos-updater/stargazers","contributors_url":"https://api.github.com/repos/endlessm/eos-updater/contributors","subscribers_url":"https://api.github.com/repos/endlessm/eos-updater/subscribers","subscription_url":"https://api.github.com/repos/endlessm/eos-updater/subscription","commits_url":"https://api.github.com/repos/endlessm/eos-updater/commits{/sha}","git_commits_url":"https://api.github.com/repos/endlessm/eos-updater/git/commits{/sha}","comments_url":"https://api.github.com/repos/endlessm/eos-updater/comments{/number}","issue_comment_url":"https://api.github.com/repos/endlessm/eos-updater/issues/comments{/number}","contents_url":"https://api.github.com/repos/endlessm/eos-updater/contents/{+path}","compare_url":"https://api.github.com/repos/endlessm/eos-updater/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endlessm/eos-updater/merges","archive_url":"https://api.github.com/repos/endlessm/eos-updater/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endlessm/eos-updater/downloads","issues_url":"https://api.github.com/repos/endlessm/eos-updater/issues{/number}","pulls_url":"https://api.github.com/repos/endlessm/eos-updater/pulls{/number}","milestones_url":"https://api.github.com/repos/endlessm/eos-updater/milestones{/number}","notifications_url":"https://api.github.com/repos/endlessm/eos-updater/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endlessm/eos-updater/labels{/name}","releases_url":"https://api.github.com/repos/endlessm/eos-updater/releases{/id}","deployments_url":"https://api.github.com/repos/endlessm/eos-updater/deployments","created_at":"2013-10-01T19:23:58Z","updated_at":"2015-03-05T05:29:22Z","pushed_at":"2016-02-22T19:48:03Z","git_url":"git://github.com/endlessm/eos-updater.git","ssh_url":"git@github.com:endlessm/eos-updater.git","clone_url":"https://github.com/endlessm/eos-updater.git","svn_url":"https://github.com/endlessm/eos-updater","homepage":null,"size":127,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"endlessm:master","ref":"master","sha":"dce6a8e8bb72325c8af91fb62ae37ff90dcd8b4b","user":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"repo":{"id":13253303,"name":"eos-updater","full_name":"endlessm/eos-updater","owner":{"login":"endlessm","id":1930958,"avatar_url":"https://avatars.githubusercontent.com/u/1930958?v=3","gravatar_id":"","url":"https://api.github.com/users/endlessm","html_url":"https://github.com/endlessm","followers_url":"https://api.github.com/users/endlessm/followers","following_url":"https://api.github.com/users/endlessm/following{/other_user}","gists_url":"https://api.github.com/users/endlessm/gists{/gist_id}","starred_url":"https://api.github.com/users/endlessm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endlessm/subscriptions","organizations_url":"https://api.github.com/users/endlessm/orgs","repos_url":"https://api.github.com/users/endlessm/repos","events_url":"https://api.github.com/users/endlessm/events{/privacy}","received_events_url":"https://api.github.com/users/endlessm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endlessm/eos-updater","description":"System components of the OS Tree based updater","fork":false,"url":"https://api.github.com/repos/endlessm/eos-updater","forks_url":"https://api.github.com/repos/endlessm/eos-updater/forks","keys_url":"https://api.github.com/repos/endlessm/eos-updater/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endlessm/eos-updater/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endlessm/eos-updater/teams","hooks_url":"https://api.github.com/repos/endlessm/eos-updater/hooks","issue_events_url":"https://api.github.com/repos/endlessm/eos-updater/issues/events{/number}","events_url":"https://api.github.com/repos/endlessm/eos-updater/events","assignees_url":"https://api.github.com/repos/endlessm/eos-updater/assignees{/user}","branches_url":"https://api.github.com/repos/endlessm/eos-updater/branches{/branch}","tags_url":"https://api.github.com/repos/endlessm/eos-updater/tags","blobs_url":"https://api.github.com/repos/endlessm/eos-updater/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endlessm/eos-updater/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endlessm/eos-updater/git/refs{/sha}","trees_url":"https://api.github.com/repos/endlessm/eos-updater/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endlessm/eos-updater/statuses/{sha}","languages_url":"https://api.github.com/repos/endlessm/eos-updater/languages","stargazers_url":"https://api.github.com/repos/endlessm/eos-updater/stargazers","contributors_url":"https://api.github.com/repos/endlessm/eos-updater/contributors","subscribers_url":"https://api.github.com/repos/endlessm/eos-updater/subscribers","subscription_url":"https://api.github.com/repos/endlessm/eos-updater/subscription","commits_url":"https://api.github.com/repos/endlessm/eos-updater/commits{/sha}","git_commits_url":"https://api.github.com/repos/endlessm/eos-updater/git/commits{/sha}","comments_url":"https://api.github.com/repos/endlessm/eos-updater/comments{/number}","issue_comment_url":"https://api.github.com/repos/endlessm/eos-updater/issues/comments{/number}","contents_url":"https://api.github.com/repos/endlessm/eos-updater/contents/{+path}","compare_url":"https://api.github.com/repos/endlessm/eos-updater/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endlessm/eos-updater/merges","archive_url":"https://api.github.com/repos/endlessm/eos-updater/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endlessm/eos-updater/downloads","issues_url":"https://api.github.com/repos/endlessm/eos-updater/issues{/number}","pulls_url":"https://api.github.com/repos/endlessm/eos-updater/pulls{/number}","milestones_url":"https://api.github.com/repos/endlessm/eos-updater/milestones{/number}","notifications_url":"https://api.github.com/repos/endlessm/eos-updater/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endlessm/eos-updater/labels{/name}","releases_url":"https://api.github.com/repos/endlessm/eos-updater/releases{/id}","deployments_url":"https://api.github.com/repos/endlessm/eos-updater/deployments","created_at":"2013-10-01T19:23:58Z","updated_at":"2015-03-05T05:29:22Z","pushed_at":"2016-02-22T19:48:03Z","git_url":"git://github.com/endlessm/eos-updater.git","ssh_url":"git@github.com:endlessm/eos-updater.git","clone_url":"https://github.com/endlessm/eos-updater.git","svn_url":"https://github.com/endlessm/eos-updater","homepage":null,"size":127,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/26"},"html":{"href":"https://github.com/endlessm/eos-updater/pull/26"},"issue":{"href":"https://api.github.com/repos/endlessm/eos-updater/issues/26"},"comments":{"href":"https://api.github.com/repos/endlessm/eos-updater/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/endlessm/eos-updater/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/endlessm/eos-updater/statuses/a0956557c3152bc8971b28a4c5e88c86680d7979"}}}}