Logo Search packages:      
Sourcecode: langupdate version File versions  Download package

static void output ( gpointer  key,
gpointer  data 
) [static]

install each available package name

Todo:
run all install operations in one call - need to create it here and pass back.

Definition at line 182 of file langupdate.cc.

References c, and lu_get_aptstring().

Referenced by main().

{
      gchar * name, * hdl, * hdl_err, * config_str, * cmd, * func;
      gint err_status = 0;
      GError * gerr = NULL;

      c++;
      g_print ("%s: %s %s\n", PACKAGE, _("installing:"), (gchar*)key);
      name = NULL;
      config_str = lu_get_aptstring();
      if (dry_run)
      {
            cmd = g_strdup("apt-cache");
            func = g_strdup("show");
      }
      else
      {
            cmd = g_strdup ("apt-get");
            func = g_strdup("install -y");
      }
      if ((key) and (strcmp ((gchar*)key, "")))
            name = g_strdup_printf ( "%s %s %s %s", cmd, config_str, func, (gchar*)key);
      g_free (config_str);
      if (verbose >= 4)
            g_print ("%s: %s %s\n", PACKAGE, _("running apt command: "), name);
      g_spawn_command_line_sync (name, &hdl, &hdl_err, &err_status, &gerr);
      g_print (hdl);
      g_free (name);
      g_free (cmd);
      g_free (func);
      if (gerr)
      {
            fprintf (stdout, _("apt returned an error: %s\n"), hdl_err);
            fprintf (stdout, _("status code: %d\n"), err_status);
            fprintf (stdout, "%s\n", gerr->message);
            fprintf (stdout, "%s\n", hdl);
            g_clear_error (&gerr);
            g_free (hdl_err);
            return;
      }
      if (dry_run)
      {
            fprintf (stdout, "%s\n", hdl);
            g_free (hdl);
            return;
      }
      if (unpack_mode)
      {
            GDir * tdebs;
            gchar * dir, * arch, *path, * system;
            const gchar * filename;
            gint i;

            arch = (user_arch) ? g_strdup(user_arch) : g_strdup(HOST_CPU);
            /* TDebs have no maintainer scripts, just use dpkg -x dir/
             This puts the files in the right place but doesn't alter
             dpkg data. (i.e. the TDeb does not get configured).
            */
            dir = g_build_filename (prefix, G_DIR_SEPARATOR_S, "var","lib",
                        PACKAGE, suite_codename, "archives", NULL);
            tdebs = g_dir_open (dir, 0, &gerr);
            if (gerr) 
            {
                  g_critical ("%s: %s", PACKAGE,_("Failed to open directory"));
                  g_clear_error (&gerr);
                  return;
            }
            filename = g_dir_read_name (tdebs);
            path = g_build_filename (dir, filename, NULL);
            /* find the right TDeb */
            while (filename and (!g_str_has_prefix(filename, (gchar*)key)))
            {
                  g_free (path);
                  filename = g_dir_read_name (tdebs);
                  path = g_build_filename (dir, filename, NULL);
            }
            if (verbose >= 2)
                  g_print (_("%s: Extracting TDeb '%s' into '%s'\n"), 
                  PACKAGE, filename, prefix);
            name = g_strdup_printf ("dpkg-deb --extract %s %s", path, prefix);
            g_spawn_command_line_sync (name, &hdl, &hdl_err, &err_status, &gerr);
            g_print (hdl);
            if (gerr)
            {
                  fprintf (stdout, _("dpkg-deb returned an error: %s\n"), hdl_err);
                  fprintf (stdout, _("status code:%d\n"), err_status);
                  fprintf (stdout, "%s\n", gerr->message);
                  fprintf (stdout, "%s\n", hdl);
                  g_clear_error (&gerr);
                  g_free (hdl_err);
            }
            system = g_build_filename (prefix, 
                              "var", "cache", "apt", "archives", filename, NULL);
            g_print ("%s: %s: '%s'", PACKAGE, 
                        _("Copying unpacked TDeb to apt cache"), system);
            i = g_rename (path, system);
            if (i)
            {
                  g_print ("%s: %s", PACKAGE, 
                        _("Unable to move the unpacked TDeb, deleting instead."));
                  g_unlink (path);
            }
            g_dir_close (tdebs);
            g_free (dir);
            g_free (name);
            g_free (path);
      }
}


Generated by  Doxygen 1.6.0   Back to index