Commits

jjacky committed a723fe7

PostSysUpgrade: now you can use $PACKAGES to be replaced by the list of upgraded packages (close #9)

Note that the list actually is of all packages involved in the sysupgrade, i.e. also those removed or added (e.g. when a package is replaced by another one).

Comments (0)

Files changed (2)

           GtkListStore **store,
           GtkWidget    **hbox,
           const char    *column_title,
+          const char    *tooltip_list,
           const char    *tooltip_add,
           const char    *tooltip_edit,
           const char    *tooltip_remove,
     tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (*store));
     g_object_set_data (G_OBJECT (tree), "store", (gpointer) *store);
     g_object_unref (*store);
+    if (tooltip_list)
+    {
+        gtk_widget_set_tooltip_markup (tree, tooltip_list);
+    }
     
     /* vbox - sort of a toolbar but vertical */
     GtkWidget *vbox_tb;
     /* PostSysUpgrade */
     add_list (grid, top, &cmdline_post_store, &cmdline_post_hbox,
               "After completing a system upgrade, start the following :",
+              "You can use <b>$PACKAGES</b> to be replaced by the list of upgraded packages",
               "Add a new command-line",
               "Edit selected command-line",
               "Remove selected command-line",
     ++top;
     add_list (grid, top, &aur_ignore_store, &hbox,
               "Package name",
+              NULL,
               "Add a new package",
               "Edit selected package",
               "Remove selected package",
             }
         }
         
-        for (i = cmdlines; i; i = alpm_list_next (i))
-        {
-            add_log (LOGTYPE_NORMAL, "Starting: '%s' ..", i->data);
-            if (!g_spawn_command_line_async (i->data, &error))
-            {
-                add_log (LOGTYPE_NORMAL, " failed\n");
-                _show_error ("Unable to start post-sysupgrade process.",
-                    "Command-line: %s\nError: %s",
-                    i->data, error->message);
-                g_clear_error (&error);
-            }
-            else
-            {
-                add_log (LOGTYPE_NORMAL, " ok\n");
-            }
-        }
         if (cmdlines)
         {
+            /* construct list of "upgraded" packages */
+            GtkTreeIter iter;
+            GtkTreeModel *model = GTK_TREE_MODEL (updater->store);
+            GString *string;
+            char *s;
+            
+            string = g_string_sized_new (255);
+            gtk_tree_model_get_iter_first (model, &iter);
+            do
+            {
+                gtk_tree_model_get (model, &iter, UCOL_PACKAGE, &s, -1);
+                string = g_string_append (string, s);
+                string = g_string_append_c (string, ' ');
+            } while (gtk_tree_model_iter_next (model, &iter));
+            
+            /* start */
+            for (i = cmdlines; i; i = alpm_list_next (i))
+            {
+                s = strreplace (i->data, "$PACKAGES", string->str);
+                
+                add_log (LOGTYPE_NORMAL, "Starting: '%s' ..", s);
+                if (!g_spawn_command_line_async (s, &error))
+                {
+                    add_log (LOGTYPE_NORMAL, " failed\n");
+                    _show_error ("Unable to start post-sysupgrade process.",
+                        "Command-line: %s\nError: %s",
+                        s, error->message);
+                    g_clear_error (&error);
+                }
+                else
+                {
+                    add_log (LOGTYPE_NORMAL, " ok\n");
+                }
+                free (s);
+            }
+            
             FREELIST (cmdlines);
+            g_string_free (string, TRUE);
         }
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.