Show
Ignore:
Timestamp:
08/07/08 21:40:18 (5 months ago)
Author:
codehelp
Message:

clean up the downloaded packages and the arch-specific lists too

Location:
current/host/trunk/langupdate/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • current/host/trunk/langupdate/trunk/debian/changelog

    r4703 r4704  
    22 
    33  * 0.0.5 Cleanup temporary files after each run 
     4  * clean up the downloaded packages and the arch-specific lists too 
    45 
    5  -- Neil Williams <codehelp@debian.org>  Thu, 07 Aug 2008 17:53:58 -0300 
     6 -- Neil Williams <codehelp@debian.org>  Thu, 07 Aug 2008 18:38:22 -0300 
    67 
    78langupdate (0.0.4) unstable; urgency=low 
  • current/host/trunk/langupdate/trunk/src/aptcache.cc

    r4629 r4704  
    8080//      gboolean All = _config->FindB("APT::Cache::AllNames","false"); 
    8181 
    82         path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/lists/partial", NULL); 
     82        path = g_strconcat ("/var/lib/"PACKAGE"/", suite_codename, "/lists/partial", NULL); 
    8383        g_mkdir_with_parents (path, 0755); 
    8484        g_free (path); 
    85         path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/archives/partial", NULL); 
     85        path = g_strconcat ("/var/lib/"PACKAGE"/", suite_codename, "/archives/partial", NULL); 
    8686        g_mkdir_with_parents (path, 0755); 
    8787        g_free (path); 
    88         fout = fopen ("/var/lib/langupdate/status", "a"); 
     88        fout = fopen ("/var/lib/"PACKAGE"/status", "a"); 
    8989        fclose (fout); 
    90         path = g_strconcat ("/var/lib/langupdate/", suite_codename, "/lists/lock", NULL); 
     90        path = g_strconcat ("/var/lib/"PACKAGE"/", suite_codename, "/lists/lock", NULL); 
    9191        fout = fopen (path, "a"); 
    9292        fclose (fout); 
     
    103103        _config->Set("Apt::Architecture", HOST_CPU); 
    104104        _config->Set("help", true); 
    105         _config->Set("APT::Get::List-Cleanup", "off"); 
     105        _config->Set("APT::Get::List-Cleanup", "on"); 
    106106        _config->Set("Apt::Install-Recommends","false"); 
    107         _config->Set("Dir",      "/var/lib/langupdate"); 
    108         _config->Set("Dir::Etc", "/var/lib/langupdate"); 
    109         _config->Set("Dir::Etc::SourceList", "/var/lib/langupdate/sources.list"); 
     107        _config->Set("Dir",      "/var/lib/"PACKAGE); 
     108        _config->Set("Dir::Etc", "/var/lib/"PACKAGE); 
     109        _config->Set("Dir::Etc::SourceList", "/var/lib/"PACKAGE"/sources.list"); 
    110110        _config->Set("Dir::State", suite_codename); 
    111         _config->Set("Dir::State::Status", "/var/lib/langupdate/status"); 
     111        _config->Set("Dir::State::Status", "/var/lib/"PACKAGE"/status"); 
    112112        _config->Set("Dir::Cache", suite_codename); 
    113113        if (_config->FindB("APT::Cache::Generate",true) == false) 
  • current/host/trunk/langupdate/trunk/src/langupdate.cc

    r4703 r4704  
    128128                name = g_strdup_printf ( "%s %s %s %s", cmd, config_str, func, (gchar*)value); 
    129129        g_spawn_command_line_sync (name, &hdl, &hdl_err, &err_status, &gerr); 
     130        g_free (name); 
    130131        if (gerr)  
    131132        { 
     
    134135                fprintf (stdout, _("status code:%d\n"), err_status); 
    135136                fprintf (stdout, "%s\n", gerr->message); 
     137                g_clear_error (&gerr); 
     138                g_free (hdl_err); 
    136139                return; 
    137140        } 
    138141        if (dry_run) 
     142        { 
    139143                fprintf (stdout, "%s\n", hdl); 
     144                g_free (hdl); 
     145        } 
     146        g_free (cmd); 
     147        g_free (func); 
    140148} 
    141149 
     
    255263        g_unlink (path); 
    256264        g_free (path); 
     265} 
     266 
     267static void 
     268run_apt_clean (const gchar * user_suite) 
     269{ 
     270        gchar * config_str, * hdl, * hdl_err, * name; 
     271        GError * gerr = NULL; 
     272        gint err_status = 0; 
     273 
     274        config_str = lu_get_aptstring(); 
     275        name = g_strdup_printf ( "%s %s %s", "apt-get", config_str, "clean"); 
     276        g_spawn_command_line_sync (name, &hdl, &hdl_err, &err_status, &gerr); 
     277        if (gerr)  
     278        { 
     279                /// \todo rationalise error output. 
     280                fprintf (stdout, _("apt returned an error:%s\n"), hdl_err); 
     281                fprintf (stdout, _("status code:%d\n"), err_status); 
     282                fprintf (stdout, "%s\n", gerr->message); 
     283                g_clear_error (&gerr); 
     284                g_free (hdl_err); 
     285                return; 
     286        } 
     287} 
     288 
     289static void 
     290remove_binlists (gpointer value, gpointer data) 
     291{ 
     292        gchar * code, * path, *suite; 
     293        suite = (gchar*) data; 
     294        code = (gchar*) value; 
     295        if ((code) && (strcmp (code, ""))) 
     296        { 
     297                path = g_strconcat ("/var/lib/",PACKAGE,"/", suite,  
     298                        "/lists/buildd.emdebian.org_locale_dists_", suite, "_", 
     299                        code, "_binary-",HOST_CPU,"_Packages", NULL); 
     300                g_unlink (path); 
     301                g_free (path); 
     302        } 
    257303} 
    258304 
     
    368414        g_list_foreach (choices, output, NULL); 
    369415        g_hash_table_destroy (tbl); 
    370         g_list_free (locales); 
    371416        g_list_free (choices); 
     417        run_apt_clean (suite_codename); 
    372418        remove_cache ("lists/lock", suite_codename); 
    373419        remove_cache ("lock", suite_codename); 
     
    375421        remove_cache ("pkgcache.bin", suite_codename); 
    376422        remove_lists (suite_codename); 
     423        g_list_foreach (locales, remove_binlists, suite_codename); 
     424        g_list_free (locales); 
    377425        g_unlink (sourceslist); 
    378426        return 0;