Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Michal Hlavinka
e113e6d59a reintroduce use more feature rich lesspipe filter, but separate
perl dependent colorizer into subpackage, credits Yaakov Selkowitz
2025-11-24 21:41:52 +01:00
Adam Williamson
d54f2ef570 Revert "use more feature rich lesspipe filter (#2308285)"
This reverts commit 7063e7b772. It
causes less to have a hard dependency on perl, which is not at
all desirable and breaks all atomic desktop builds. See:

https://bugzilla.redhat.com/show_bug.cgi?id=2308285#c3
2025-11-14 08:22:50 -08:00
Michal Hlavinka
7063e7b772 use more feature rich lesspipe filter (#2308285) 2025-11-12 12:10:33 +01:00
5 changed files with 63 additions and 199 deletions

1
.gitignore vendored
View file

@ -13,3 +13,4 @@
/less-678.tar.gz
/less-679.tar.gz
/less-685.tar.gz
/lesspipe-2.20.tar.gz

View file

@ -1,13 +1,13 @@
Summary: A text file browser similar to more, but better
Name: less
Version: 685
Release: 1%{?dist}
Release: 6%{?dist}
License: GPL-3.0-only and BSD-2-Clause
Source0: https://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
Source1: lesspipe.sh
%global lesspipe_version 2.20
Source1: https://github.com/wofr06/lesspipe/archive/refs/tags/v%{lesspipe_version}.tar.gz#/lesspipe-%{lesspipe_version}.tar.gz
Source2: less.sh
Source3: less.csh
Source4: lesspipe.sh.1
Patch4: less-394-time.patch
Patch5: less-475-fsync.patch
Patch6: less-436-manpage-add-old-bot-option.patch
@ -20,6 +20,13 @@ URL: https://www.greenwoodsoftware.com/less/
BuildRequires: ncurses-devel
BuildRequires: autoconf automake libtool
BuildRequires: make
# for lesspipe make test
BuildRequires: perl-Archive-Tar
# for lesspipe
Recommends: (less-color = %{version}-%{release} if perl-interpreter)
Recommends: unzip
Recommends: html2text
Recommends: 7zip
%description
The less utility is a text file browser that resembles more, but has
@ -31,8 +38,17 @@ example, vi).
You should install less because it is a basic utility for viewing text
files, and you'll use it frequently.
%package color
Summary: Colorizers for less
Requires: %{name} = %{version}-%{release}
Conflicts: less < 685-5
%description color
Syntax highlighting modes for the less pager.
%prep
%setup -q
%setup -q -a 1
%patch -P 4 -p1 -b .time
%patch -P 5 -p2 -b .fsync
%patch -P 6 -p1 -b .manpage-add-old-bot-option
@ -49,22 +65,60 @@ autoreconf -fiv
%configure
%make_build CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
pushd lesspipe-%{lesspipe_version}
#fix shebangs
sed -i "s|^#!/usr/bin/env bash|^#!/usr/bin/bash|" lesspipe.sh
./configure --prefix=%{_prefix}
%make_build
popd
%install
%make_install
mkdir -p $RPM_BUILD_ROOT/etc/profile.d
install -p %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}
install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT/etc/profile.d
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/profile.d
install -p -m 644 %{SOURCE4} $RPM_BUILD_ROOT/%{_mandir}/man1/lesspipe.sh.1
pushd lesspipe-%{lesspipe_version}
%make_install
rm -f $RPM_BUILD_ROOT/usr/share/bash-completion/less_completion
popd
%check
pushd lesspipe-%{lesspipe_version}
# we dont have all required components to pass full test, but it is still
# useful to run for debug purposes
make test ||:
popd
%files
%doc README NEWS INSTALL
%license LICENSE COPYING
/etc/profile.d/*
%{_bindir}/*
%{_bindir}/less
%{_bindir}/lesscomplete
%{_bindir}/lessecho
%{_bindir}/lesskey
%{_bindir}/lesspipe.sh
%{_mandir}/man1/*
%files color
%{_bindir}/archive_color
%{_bindir}/code2color
%{_bindir}/sxw2txt
%{_bindir}/vimcolor
%changelog
* Mon Nov 24 2025 Michal Hlavinka <mhlavink@redhat.com> - 685-6
- reintroduce use more feature rich lesspipe filter, but separate
perl dependent colorizer into subpackage, credits Yaakov Selkowitz
* Fri Nov 14 2025 Adam Williamson <awilliam@redhat.com> - 685-5
- Revert new lesspipe filter due to hard perl dependency
* Wed Nov 12 2025 Michal Hlavinka <mhlavink@redhat.com> - 685-4
- use more feature rich lesspipe filter (#2308285)
* Wed Oct 22 2025 Michal Hlavinka <mhlavink@redhat.com> - 685-1
- updated to 685 (#2404089)

View file

@ -1,132 +0,0 @@
#!/bin/sh
#
# To use this filter with less, define LESSOPEN:
# export LESSOPEN="|/usr/bin/lesspipe.sh %s"
#
# The script should return zero if the output was valid and non-zero
# otherwise, so less could detect even a valid empty output
# (for example while uncompressing gzipped empty file).
# For backward-compatibility, this is not required by default. To turn
# this functionality there should be another vertical bar (|) straight
# after the first one in the LESSOPEN environment variable:
# export LESSOPEN="||/usr/bin/lesspipe.sh %s"
if [ ! -e "$1" ] ; then
exit 1
fi
if [ -d "$1" ] ; then
ls -alF -- "$1"
exit $?
fi
exec 2>/dev/null
# Allow for user defined filters
if [ -x ~/.lessfilter ]; then
~/.lessfilter "$1"
if [ $? -eq 0 ]; then
exit 0
fi
fi
manfilter ()
{
if test -x /usr/bin/man ; then
# See rhbz#1241543 for more info. Well, actually we firstly
# used 'man -l', then we switched to groff, and then we again
# switched back to 'man -l'.
/usr/bin/man -P /usr/bin/cat -l "$1"
elif test -x /usr/bin/groff; then
# This is from pre-rhbz#1241543-time.
groff -Tascii -mandoc "$1" | cat -s
else
echo "WARNING:"
echo "WARNING: to better show manual pages, install 'man-db' package"
echo "WARNING:"
cat "$1"
fi
}
export MAN_KEEP_FORMATTING=1
case "$1" in
*.[1-9n].bz2|*.[1-9]x.bz2|*.man.bz2|*.[1-9n].[glx]z|*.[1-9]x.[glx]z|*.man.[glx]z|*.[1-9n].lzma|*.[1-9]x.lzma|*.man.lzma|*.[1-9n].zst|*.[1-9]x.zst|*.man.zst|*.[1-9n].br|*.[1-9]x.br|*.man.br)
case "$1" in
*.gz) DECOMPRESSOR="gzip -dc" ;;
*.bz2) DECOMPRESSOR="bzip2 -dc" ;;
*.lz) DECOMPRESSOR="lzip -dc" ;;
*.zst) DECOMPRESSOR="zstd -dcq" ;;
*.br) DECOMPRESSOR="brotli -dc" ;;
*.xz|*.lzma) DECOMPRESSOR="xz -dc" ;;
esac
if [ -n "$DECOMPRESSOR" ] && $DECOMPRESSOR -- "$1" | file - | grep -q troff; then
$DECOMPRESSOR -- "$1" | manfilter -
exit $?
fi
esac
case "$1" in
*.[1-9n]|*.[1-9]x|*.man)
if file "$1" | grep -q troff; then
manfilter "$1"
exit $?
fi
esac
case "$1" in
*.tar) tar tvvf "$1"; exit $? ;;
*.tgz|*.tar.gz|*.tar.[zZ]) tar tzvvf "$1"; exit $? ;;
*.tar.xz) tar Jtvvf "$1"; exit $? ;;
*.xz|*.lzma) xz -dc -- "$1"; exit $? ;;
*.tar.lz) tar --lzip -tvvf "$1"; exit $? ;;
*.lz) lzip -dc -- "$1"; exit $? ;;
*.tar.zst) tar --zstd -tvvf "$1"; exit $? ;;
*.zst) zstd -dcq -- "$1"; exit $? ;;
*.tar.br) brotli -dc -- "$1" | tar tvvf -; exit $? ;;
*.br) brotli -dc -- "$1"; exit $? ;;
*.tar.bz2|*.tbz2) bzip2 -dc -- "$1" | tar tvvf -; exit $? ;;
*.[zZ]|*.gz) gzip -dc -- "$1"; exit $? ;;
*.bz2) bzip2 -dc -- "$1"; exit $? ;;
*.zip|*.jar|*.nbm) zipinfo -- "$1"; exit $? ;;
# --nomanifest -> rhbz#1450277
*.rpm) rpm -qpivl --changelog --nomanifest -- "$1"; exit $? ;;
*.cpi|*.cpio) cpio -itv < "$1"; exit $? ;;
*.gpg)
if [ -x /usr/bin/gpg2 ]; then
gpg2 -d "$1"
exit $?
elif [ -x /usr/bin/gpg ]; then
gpg -d "$1"
exit $?
else
echo "No GnuPG available."
echo "Install gnupg2 or gnupg to show encrypted files."
exit 1
fi ;;
*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
if [ -x /usr/bin/identify ]; then
identify "$1"
exit $?
elif [ -x /usr/bin/gm ]; then
gm identify "$1"
exit $?
else
echo "No identify available"
echo "Install ImageMagick or GraphicsMagick to browse images"
exit 1
fi ;;
*)
if [ -x /usr/bin/file ] && [ -x /usr/bin/iconv ] && [ -x /usr/bin/cut ]; then
case `file -b "$1"` in
*UTF-16*) conv='UTF-16' ;;
*UTF-32*) conv='UTF-32' ;;
esac
if [ -n "$conv" ]; then
env=`echo $LANG | cut -d. -f2`
if [ -n "$env" -a "$conv" != "$env" ]; then
iconv -f $conv -t $env "$1"
exit $?
fi
fi
fi
exit 1
esac

View file

@ -1,60 +0,0 @@
.TH LESSPIPE.SH "1" "August 2025" "lesspipe.sh" "User Commands"
.SH NAME
lesspipe.sh \- a preprocessor for less
.SH SYNOPSIS
.B lesspipe.sh
[\fIFILE\fR]
.SH DESCRIPTION
.PP
The purpose of \fBlesspipe.sh\fP is to enhance the output of \fBless\fP.
.PP
With this preprocessor filter \fBless\fP
will be able to display contents of compressed files. For files
containing archives and directories, a table of contents will be displayed.
These filters can be applied recursively.
.SH FILTER ACTIVATION
For \fBlesspipe.sh\fP to be used by \fBless\fP the environment variable
\fBLESSOPEN\fP must be set properly. For bash like shells the command is:
.EX
.I LESSOPEN="||lesspipe.sh %s"; export LESSOPEN
.EE
Use absolute path, if \fBlesspipe.sh\fP is not in the search path.
.PP
Having set the environment variable as described above, \fBless\fP
will then display textual information for a wide range of file formats.
.SH USER DEFINED FILTERING
The \fBlesspipe.sh\fP preprocessing can be replaced or enhanced by a user defined
filter specified in \fB~/.lessfilter\fP This file should have an execute bit
set and accept only one parameter, which represents a filename. If the
user defined filter processes the file, zero should be returned. Otherwise
\fBlesspipe.sh\fP will try to handle the file.
.PP
This can be used not only to add filtering for new formats, but also to block
filtering for certain files types or files. An example ~/.lessfilter
.RS
.EX
#!/usr/bin/sh
if [[ "$1" = *.raw ]]; then
# do not process 'raw' files
cat "$1"
exit 0
elif [[ "$1" = *.txt ]]; then
if [ $(wc -l <"$1") = 1 ]; then
# decorate oneliners with cowsay
cowsay <"$1"
exit 0;
fi
fi
# default, not handled by .lessfilter
exit 1
.EE
.RE
.SH AUTHOR
Michal Hlavinka
.SH "SEE ALSO"
less(1)

View file

@ -1 +1,2 @@
SHA512 (less-685.tar.gz) = aff745f1816e0f996fbdbc33ecae0726cf0d842efc227937ff8c32e734c8b5be4c611ffbb27e5e038b4d95280c95ca60c53af1a47cf419cb06e5fab543c231f3
SHA512 (lesspipe-2.20.tar.gz) = bfeba1b921959e8cde8ce8bcc75765598cefd2cc705aa5b6417592fdbdb0c43bd3efb0d4379a0514f0da86806988ee95219539974c7af3319595d9b03aac550e