diff options
author | Michael Vogt <mvo@debian.org> | 2013-11-26 10:32:21 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-11-26 10:32:21 +0100 |
commit | e6645b9fb9ba3a7ff7b6663af3f5e1bcb6f23d78 (patch) | |
tree | d4f48ba0afd028c8683bbcf9702b28ec0548c785 /cmdline/apt.cc | |
parent | d2524a53bbd219ee6d069006fd243a5bcda0245b (diff) |
add check when sources.list changed
Diffstat (limited to 'cmdline/apt.cc')
-rw-r--r-- | cmdline/apt.cc | 20 |
1 files changed, 14 insertions, 6 deletions
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 <apt-pkg/pkgsystem.h> #include <apt-pkg/indexfile.h> #include <apt-pkg/metaindex.h> +#include <apt-pkg/hashes.h> #include <apti18n.h> @@ -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; } /*}}}*/ |