diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-11-18 20:07:02 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-11-18 20:15:08 +0100 |
| commit | 1c4fa81cc398e21868ad237509f1ea8e772d76de (patch) | |
| tree | 9376185fca5ef2a2c794a2d976d2e559f7b05b07 | |
| parent | 963efeff8778afacef35f69c181d234e0a27d5d3 (diff) | |
Add a --comment option to record Comment: in history
Suggested-by: mhoye on IRC
| -rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 2 | ||||
| -rw-r--r-- | apt-private/private-cmndline.cc | 1 | ||||
| -rw-r--r-- | doc/apt-get.8.xml | 5 | ||||
| -rw-r--r-- | doc/examples/configure-index | 2 | ||||
| -rwxr-xr-x | test/integration/test-history | 40 |
5 files changed, 50 insertions, 0 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ecedb8cd5..8cadd2712 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1087,6 +1087,8 @@ bool pkgDPkgPM::OpenLog() std::string RequestingUser = AptHistoryRequestingUser(); if (RequestingUser != "") WriteHistoryTag("Requested-By", RequestingUser); + if (auto comment = _config->Find("APT::History::Comment"); not comment.empty()) + WriteHistoryTag("Comment", comment); WriteHistoryTag("Install", install); WriteHistoryTag("Reinstall", reinstall); WriteHistoryTag("Upgrade", upgrade); diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 3a8cc6b1d..5d4eeb5cb 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -192,6 +192,7 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const addArg(0, "solver", "APT::Solver", CommandLine::HasArg); addArg(0, "strict-pinning", "APT::Solver::Strict-Pinning", 0); addArg(0, "planner", "APT::Planner", CommandLine::HasArg); + addArg(0, "comment", "APT::History::Comment", CommandLine::HasArg); addArg('U', "update", "APT::Update", 0); if (CmdMatches("upgrade")) { diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml index f1089f5d6..7d0ccece7 100644 --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@ -416,6 +416,11 @@ Configuration Item: <literal>APT::Get::List-Columns</literal>.</para></listitem> </varlistentry> + <varlistentry><term><option>--comment</option></term> + <listitem><para>Add the given value to the <literal>Comment:</literal> field in history.log + Configuration Item: <literal>APT::History::Comment</literal>.</para></listitem> + </varlistentry> + <varlistentry><term><option>-a</option></term> <term><option>--host-architecture</option></term> <listitem><para>This option controls the architecture packages are built for diff --git a/doc/examples/configure-index b/doc/examples/configure-index index feadca8d2..6723a48da 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -903,3 +903,5 @@ APT::Color::Show::Package "<STRING>"; update-manager::always-include-phased-updates "<BOOL>"; update-manager::never-include-phased-updates "<BOOL>"; + +apt::history::comment "<STRING>"; diff --git a/test/integration/test-history b/test/integration/test-history new file mode 100755 index 000000000..47829e162 --- /dev/null +++ b/test/integration/test-history @@ -0,0 +1,40 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' + +buildsimplenativepackage 'pkg1' 'amd64' '1' 'stable' +buildsimplenativepackage 'pkg2' 'amd64' '1' 'stable' + + +setupaptarchive + +cathistory() { + sed rootdir/var/log/apt/history.log -re 's/^(Commandline|Start-Date|End-Date):.*/\1: dummy/' +} + + +testsuccess aptget install pkg1 + +testequal " +Start-Date: dummy +Commandline: dummy +Install: pkg1:amd64 (1) +End-Date: dummy" cathistory + +testsuccess aptget install pkg2 --comment="A test comment" + +testequal " +Start-Date: dummy +Commandline: dummy +Install: pkg1:amd64 (1) +End-Date: dummy + +Start-Date: dummy +Commandline: dummy +Comment: A test comment +Install: pkg2:amd64 (1) +End-Date: dummy" cathistory |
