From e6645b9fb9ba3a7ff7b6663af3f5e1bcb6f23d78 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Nov 2013 10:32:21 +0100 Subject: add check when sources.list changed --- cmdline/apt.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 38610e731..47187fac2 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -61,21 +62,21 @@ // --------------------------------------------------------------------- bool EditSources(CommandLine &CmdL) { - // FIXME: suport CmdL.FileList to specify sources.list.d files + bool res; + pkgSourceList sl; + std::string outs; + // FIXME: suport CmdL.FileList to specify sources.list.d files std::string sourceslist = _config->FindFile("Dir::Etc::sourcelist"); - // FIXME: take hash before, - // when changed display message to apt update - bool res; - pkgSourceList sl; + HashString before; + before.FromFile(sourceslist); do { EditFileInSensibleEditor(sourceslist); _error->PushToStack(); res = sl.Read(sourceslist); if (!res) { - std::string outs; strprintf(outs, _("Failed to parse %s. Edit again? "), sourceslist.c_str()); std::cout << outs; @@ -84,6 +85,13 @@ bool EditSources(CommandLine &CmdL) _error->RevertToStack(); } while (res == false); + if (!before.VerifyFile(sourceslist)) { + strprintf( + outs, _("Your '%s' file changed, please run 'apt-get update'."), + sourceslist.c_str()); + std::cout << outs << std::endl; + } + return true; } /*}}}*/ -- cgit v1.2.3