Skip to content

Commit 58f7bdd

Browse files
committed
better README documentation
Use better description, and use clearer example. Fix leftover in 'dnf diff --help' output.
1 parent 4983345 commit 58f7bdd

File tree

2 files changed

+72
-22
lines changed

2 files changed

+72
-22
lines changed

README

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,77 @@
1-
dnf-plugin-diff - compare package contents against local changes
2-
================================================================
1+
dnf-plugin-diff - show local changes in RPM packages
2+
====================================================
33

4-
Typical use-case:
4+
It is often very convenient to edit files installed/tracked by RPM -
5+
typically to hot-fix a source code on production system, or change the
6+
default configuration files.
57

6-
$ echo '# some change' >> \
7-
/usr/lib/python3.6/site-packages/dnf-plugins/diff.py
8-
$ dnf diff dnf-plugin-diff
9-
Last metadata expiration check: 0:04:12 ago on Mon 03 Sep 2018 05:12:09 PM CEST.
10-
--- /usr/lib/python3.6/site-packages/dnf-plugins/diff.py 2018-09-03 16:41:36.000000000 +0200
11-
+++ /usr/lib/python3.6/site-packages/dnf-plugins/diff.py 2018-09-03 17:16:17.476547131 +0200
12-
@@ -96,3 +96,5 @@
13-
else:
14-
self._diff_package(pkg, check_pkg,
15-
self._list_of_changed_files(check_pkg))
16-
+
17-
+# some change
8+
It is easy to detect what files have been changed in particular installed
9+
RPM package (`$ rpm -V PACKAGE` helps here), but it was a pretty laborious
10+
job to print the actual changes (diff). You had to a) download the
11+
original RPM package, b) extract the package somewhere, c) detect what
12+
files have actually been changed on the system and d) manually diff the
13+
extracted files against the changed files installed on the system. This
14+
is where the simple helper `dnf-plugin-diff` steps in.
15+
16+
17+
Options/usage
18+
-------------
19+
20+
$ dnf diff PKG [FILE [FILE ...]]
21+
22+
Diff original <PKG> contents against the locally changed files. By
23+
default - `dnf diff` prints (to stdout) complete changes. Optionally the
24+
output can be filtered by <FILE> arguments.
25+
26+
27+
Typical use-case
28+
----------------
29+
30+
I recall I changed a configuration of my `cgit` service, so I check what
31+
configuration files I changed:
32+
33+
$ rpm -V cgit
34+
S.5....T. c /etc/cgitrc
35+
S.5....T. c /etc/httpd/conf.d/cgit.conf
36+
37+
But to see what has actually been change, I can do:
38+
39+
$ dnf diff cgit /etc/httpd/conf.d/cgit.conf
40+
--- /etc/httpd/conf.d/cgit.conf 2018-08-18 03:31:33.000000000 +0200
41+
+++ /etc/httpd/conf.d/cgit.conf 2018-12-15 10:27:23.310626910 +0100
42+
@@ -1,5 +1,5 @@
43+
Alias /cgit-data /usr/share/cgit
44+
ScriptAlias /cgit /var/www/cgi-bin/cgit
45+
-<Directory "/usr/share/cgit">
46+
+<Directory "/data/cgit">
47+
Require all granted
48+
</Directory>
1849

1950

2051
How to install
2152
--------------
2253

23-
$ dnf copr enable praiskup/dnf-plugin-diff
24-
$ dnf install dnf-plugins-diff
54+
Temporarily, it's built only in copr:
55+
56+
$ dnf copr enable praiskup/dnf-plugin-diff
57+
58+
Execute:
59+
60+
$ dnf diff ...
61+
No such command: diff. Please use /usr/bin/dnf --help
62+
It could be a DNF plugin command, try: "dnf install 'dnf-command(diff)'"
63+
$ sudo dnf install 'dnf-command(diff)'
64+
65+
66+
Build from source
67+
-----------------
68+
69+
$ autoreconf -vfi
70+
$ ./configure --prefix=/usr
71+
$ sudo make install
72+
2573

26-
or build from source:
74+
Build RPM from source
75+
---------------------
2776

28-
$ autoreconf -vfi && ./configure --prefix=/usr && sudo make install
77+
Run `make dist` and use *.tar.gz file with rpm/*.spec file.

dnf-plugins/diff.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# supplies the 'diff' command.
1+
# supplies the dnf 'diff' command.
22
#
33
# Copyright (C) 2018 Red Hat, Inc.
4+
# Written by Pavel Raiskup <[email protected]>.
45
#
56
# This copyrighted material is made available to anyone wishing to use,
67
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -28,8 +29,8 @@
2829
@dnf.plugin.register_command
2930
class DiffCommand(dnf.cli.Command):
3031
aliases = ("diff",)
31-
summary = "Do blah."
32-
usage = "ahoj"
32+
summary = "Show local changes in RPM packages."
33+
usage = ""
3334

3435
@staticmethod
3536
def set_argparser(parser):

0 commit comments

Comments
 (0)