summaryrefslogtreecommitdiff
path: root/docs/man
diff options
context:
space:
mode:
authorRobbie Harwood <rharwood@redhat.com>2022-10-27 15:11:36 -0400
committerFlorian Festi <ffesti@redhat.com>2022-11-25 10:38:42 +0100
commit4c6052c42aee71695a0c1bde0b674e2ad6f8c96b (patch)
treeab2a0beb629b060278adfcb51e421ecf8577d252 /docs/man
parent96f9b82e263bc83a4aacc1d8ccd729170b1a2676 (diff)
downloadrpm-4c6052c42aee71695a0c1bde0b674e2ad6f8c96b.tar.gz
Add rpmsort utility for sorting RPM versions
rpmsort(8) is intended for use in shell scripts. sort(1) is not RPM versioning-aware, and attempting to work around that is fraught. Instead, provide a wrapper around rpmvercmp() using qsort(). Fedora's grub2 has carried a version of this since 2015, and a more complex version was also part of the grubby project (provided at /usr/libexec/grubby/rpm-sort) since 2018. This version has been simplified and adapted to the RPM project. Also-authored-by: Peter Jones <pjones@redhat.com> Signed-off-by: Peter Jones <pjones@redhat.com> Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Diffstat (limited to 'docs/man')
-rw-r--r--docs/man/CMakeLists.txt2
-rw-r--r--docs/man/index.md1
-rw-r--r--docs/man/rpmsort.8.md38
3 files changed, 40 insertions, 1 deletions
diff --git a/docs/man/CMakeLists.txt b/docs/man/CMakeLists.txt
index c59a879cb..e34dd1ee9 100644
--- a/docs/man/CMakeLists.txt
+++ b/docs/man/CMakeLists.txt
@@ -2,7 +2,7 @@
set(manuals
gendiff.1 rpm2cpio.8
rpm.8 rpmbuild.8 rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8
- rpmdeps.8 rpmgraph.8 rpmlua.8 rpm-misc.8
+ rpmdeps.8 rpmgraph.8 rpmlua.8 rpm-misc.8 rpmsort.8
)
if (WITH_ARCHIVE)
diff --git a/docs/man/index.md b/docs/man/index.md
index dfd274f20..a3c837a0f 100644
--- a/docs/man/index.md
+++ b/docs/man/index.md
@@ -15,6 +15,7 @@ title: rpm.org - RPM Manual Pages
* [rpmdb (8)](rpmdb.8.md)
* [rpmkeys (8)](rpmkeys.8.md)
* [rpmsign (8)](rpmsign.8.md)
+* [rpmsort (8)](rpmsort.8.md)
* [rpmspec (8)](rpmspec.8.md)
* [gendiff (1)](gendiff.1.md)
diff --git a/docs/man/rpmsort.8.md b/docs/man/rpmsort.8.md
new file mode 100644
index 000000000..ddf0eed97
--- /dev/null
+++ b/docs/man/rpmsort.8.md
@@ -0,0 +1,38 @@
+---
+date: 27 October 2022
+section: 8
+title: RPMSORT
+---
+
+NAME
+====
+
+rpmsort - Sort input by RPM Package Manager (RPM) versioning.
+
+SYNOPSIS
+========
+
+**rpmsort** *FILES*
+
+DESCRIPTION
+===========
+
+**rpmsort** sorts the input files, and writes a sorted list to standard out -
+like sort(1), but aware of RPM versioning.
+
+If \'-\' is given as an argument, or no arguments are given, versions are read
+from stdandard in and writen to standard out.
+
+EXAMPLES
+========
+
+\
+***$ echo -e 'rpm-4.18.0-3.fc38.x86_64\nrpm-4.18.0-1.fc38.x86_64' | rpmsort \
+rpm-4.18.0-1.fc38.x86_64 \
+rpm-4.18.0-3.fc38.x86_64***
+
+AUTHORS
+=======
+
+ Peter Jones <pjones@redhat.com>
+ Robbie Harwood <rharwood@redhat.com>