summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-apps/less')
-rw-r--r--sys-apps/less/Manifest3
-rw-r--r--sys-apps/less/files/README.Gentoo22
-rw-r--r--sys-apps/less/files/code2color-0.2.patch26
-rw-r--r--sys-apps/less/files/lesspipe.sh274
-rw-r--r--sys-apps/less/less-481.ebuild112
-rw-r--r--sys-apps/less/metadata.xml24
6 files changed, 461 insertions, 0 deletions
diff --git a/sys-apps/less/Manifest b/sys-apps/less/Manifest
new file mode 100644
index 00000000..002809e8
--- /dev/null
+++ b/sys-apps/less/Manifest
@@ -0,0 +1,3 @@
+DIST code2color-0.2 200711 SHA256 2365c9009b1cc3c30430b88775ec402164df105fd12364871d05dcaed20be954 SHA512 c0ab9f411d5a106c81334343e3c4a63b67d27b95e2d128145e3ac1ee46cd6c228c61796cf96e51826e69b3e465e7bdaa81b1a48cad934c23b310f2ea2ebd8e75 WHIRLPOOL d0207e84a5849c554b1dfc5882ab46d8afc411c7d26e912235ec05565880e6ed0db8449133502234a01ae8f59feae211486b6a523e37859d8404f72fff9b8f93
+DIST less-481.tar.gz 316622 SHA256 3fa38f2cf5e9e040bb44fffaa6c76a84506e379e47f5a04686ab78102090dda5 SHA512 29995757ac416ed6770cf6e82e6fe325bd1d61d51666d80c4fe72b2b4217b0b1d706d337d89ed54bdc4d83d57f3e2c0166e642b20ef2ad194e52aad630b3e717 WHIRLPOOL e5c8b22d7d1149feafdad0130e00aa5564e818a845c3b4e2b6d151e851dd64ff390fdad01ee79580fe6ab92defc11930d3f3e0ca0d189d2882419444a3d7028c
+DIST less-select-2.6.tar.gz 26354 SHA256 df4ab8f17568cabd864358e5f0a765241f586b8c30341116a649db91db9048bf SHA512 d674e2bcbda2155bd3da862452a78f8aa410661b887ab1c28ac2b338bd602335bbaaebf4daaf3eba120400b2d58244c98e5a96d4d2c7b74fb5b12e2210dbb00d WHIRLPOOL 04a2df34bb0daf0b86044f887bf10a6af9d941314028b052f5dfe7c0dbd4e74ecb69f88eaf8c24dbad446e8de1bcc81401118df04e186887eba126362bbb32d5
diff --git a/sys-apps/less/files/README.Gentoo b/sys-apps/less/files/README.Gentoo
new file mode 100644
index 00000000..dca83280
--- /dev/null
+++ b/sys-apps/less/files/README.Gentoo
@@ -0,0 +1,22 @@
+This version of less comes with some Gentoo enhancements:
+ - default lesspipe.sh script to "view" files
+ - colorization support
+
+To see what file types are supported, just read the /usr/bin/lesspipe.sh
+script (it's just a plain text bash script).
+
+Colorization support is disabled by default. To enable it, export the
+LESSCOLOR variable to "yes":
+ $ export LESSCOLOR=yes
+
+We also provide a colorization script, 'code2color', that is used by
+default. If you wish to use another script, simply export the LESSCOLORIZER
+variable to name of the script:
+ $ export LESSCOLORIZER=some-other-script
+
+If you want to use the code2color script and the default color schemes are
+not acceptable, you can develop your own schemes and save them in one of
+the following places:
+ /etc/code2color
+ ~/.code2color
+ CODE2COLOR_CONFIG env var
diff --git a/sys-apps/less/files/code2color-0.2.patch b/sys-apps/less/files/code2color-0.2.patch
new file mode 100644
index 00000000..f8a78250
--- /dev/null
+++ b/sys-apps/less/files/code2color-0.2.patch
@@ -0,0 +1,26 @@
+--- code2color
++++ code2color
+@@ -163,11 +163,11 @@
+ # building up the database
+ # newer entries overwrite old ones
+ my @CONFIG_FILES;
+- push @CONFIG_FILES, "/etc/code2html.config";
++ push @CONFIG_FILES, "/etc/code2color";
+ push @CONFIG_FILES,
+- $ENV{'HOME'}."/.code2html.config" if $ENV{'HOME'};
++ $ENV{'HOME'}."/.code2color" if $ENV{'HOME'};
+ push @CONFIG_FILES,
+- split(/:/,$ENV{'CODE2HTML_CONFIG'}) if $ENV{'CODE2HTML_CONFIG'};
++ split(/:/,$ENV{'CODE2COLOR_CONFIG'}) if $ENV{'CODE2COLOR_CONFIG'};
+ push @CONFIG_FILES,
+ split(/:/,$params{'langfile'}) if $params{'langfile'};
+
+@@ -3192,7 +3192,7 @@
+ #
+
+ $LANGUAGE{'shellscript'} = {
+- 'filename' => '\\.(sh|shell)$',
++ 'filename' => '\\.(ebuild|eclass|sh|shell)$',
+ 'regex' => '^\\s*#\\s*![^\\s]*(sh|bash|ash|zsh|ksh)',
+ 'patterns' => [ {
+ 'name' => 'comment',
diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh
new file mode 100644
index 00000000..6edaa3ce
--- /dev/null
+++ b/sys-apps/less/files/lesspipe.sh
@@ -0,0 +1,274 @@
+#!/bin/bash
+#
+# Preprocessor for 'less'. Used when this environment variable is set:
+# LESSOPEN="|lesspipe %s"
+
+# TODO: handle compressed files better
+
+[[ -n ${LESSDEBUG} ]] && set -x
+
+trap 'exit 0' PIPE
+
+guesscompress() {
+ case "$1" in
+ *.gz|*.z) echo "gunzip -c" ;;
+ *.bz2|*.bz) echo "bunzip2 -c" ;;
+ *.lz) echo "lzip -dc" ;;
+ *.lzma) echo "unlzma -c" ;;
+ *.lzo) echo "lzop -dc" ;;
+ *.xz) echo "xzdec" ;;
+ *) echo "cat" ;;
+ esac
+}
+
+lesspipe_file() {
+ local out=$(file -L -- "$1")
+ local suffix
+ case ${out} in
+ *" 7-zip archive"*) suffix="7z";;
+ *" ar archive"*) suffix="a";;
+ *" CAB-Installer"*) suffix="cab";;
+ *" cpio archive"*) suffix="cpio";;
+ *" ELF "*) suffix="elf";;
+ *" LHa"*archive*) suffix="lha";;
+ *" troff "*) suffix="man";;
+ *" script text"*) suffix="sh";;
+ *" shared object"*) suffix="so";;
+ *" tar archive"*) suffix="tar";;
+ *" Zip archive"*) suffix="zip";;
+ *": data") hexdump -C -- "$1"; return 0;;
+ *) return 1;;
+ esac
+ lesspipe "$1" ".${suffix}"
+ return 0
+}
+
+lesspipe() {
+ local match=$2
+ [[ -z ${match} ]] && match=$1
+
+ local DECOMPRESSOR=$(guesscompress "${match}")
+
+ # User filters
+ if [[ -x ~/.lessfilter ]] ; then
+ ~/.lessfilter "$1" && exit 0
+ fi
+
+ local ignore
+ for ignore in ${LESSIGNORE} ; do
+ [[ ${match} == *.${ignore} ]] && exit 0
+ done
+
+ case "${match}" in
+
+ ### Doc files ###
+ *.[0-9n]|*.man|\
+ *.[0-9n].bz2|*.man.bz2|\
+ *.[0-9n].gz|*.man.gz|\
+ *.[0-9n].lzma|*.man.lzma|\
+ *.[0-9n].xz|*.man.xz|\
+ *.[0-9][a-z].gz|*.[0-9][a-z].gz)
+ local out=$(${DECOMPRESSOR} -- "$1" | file -)
+ case ${out} in
+ *troff*)
+ # Need to make sure we pass path to man or it will try
+ # to locate "$1" in the man search paths
+ if [[ $1 == /* ]] ; then
+ man -- "$1"
+ else
+ man -- "./$1"
+ fi
+ ;;
+ *text*)
+ ${DECOMPRESSOR} -- "$1"
+ ;;
+ *)
+ # We could have matched a library (libc.so.6), so let
+ # `file` figure out what the hell this thing is
+ lesspipe_file "$1"
+ ;;
+ esac
+ ;;
+ *.dvi) dvi2tty "$1" ;;
+ *.ps|*.pdf) ps2ascii "$1" || pstotext "$1" || pdftotext "$1" ;;
+ *.doc) antiword "$1" || catdoc "$1" ;;
+ *.rtf) unrtf --nopict --text "$1" ;;
+ *.conf|*.txt|*.log) ;; # force less to work on these directly #150256
+
+ ### URLs ###
+ ftp://*|http://*|*.htm|*.html)
+ for b in links2 links lynx ; do
+ ${b} -dump "$1" && exit 0
+ done
+ html2text -style pretty "$1"
+ ;;
+
+ ### Tar files ###
+ *.tar|\
+ *.tar.bz2|*.tar.bz|*.tar.gz|*.tar.z|\
+ *.tar.lz|*.tar.tlz|\
+ *.tar.lzma|*.tar.xz)
+ ${DECOMPRESSOR} -- "$1" | tar tvvf -;;
+ *.tbz2|*.tbz|*.tgz|*.tlz|*.txz)
+ lesspipe "$1" "$1".tar.${1##*.t} ;;
+
+ ### Misc archives ###
+ *.bz2|\
+ *.gz|*.z|\
+ *.lz|\
+ *.lzma|*.xz) ${DECOMPRESSOR} -- "$1" ;;
+ *.rpm) rpm -qpivl --changelog -- "$1" || rpm2tar -O "$1" | tar tvvf -;;
+ *.cpi|*.cpio) cpio -itv < "$1" ;;
+ *.ace) unace l "$1" ;;
+ *.arc) arc v "$1" ;;
+ *.arj) unarj l -- "$1" ;;
+ *.cab) cabextract -l -- "$1" ;;
+ *.lha|*.lzh) lha v "$1" ;;
+ *.zoo) zoo -list "$1" || unzoo -l "$1" ;;
+ *.7z|*.exe) 7z l -- "$1" || 7za l -- "$1" || 7zr l -- "$1" ;;
+ *.a) ar tv "$1" ;;
+ *.elf) readelf -a -W -- "$1" ;;
+ *.so) readelf -h -d -s -W -- "$1" ;;
+ *.mo|*.gmo) msgunfmt -- "$1" ;;
+
+ *.rar|.r[0-9][0-9]) unrar l -- "$1" ;;
+
+ *.jar|*.war|*.ear|*.xpi|*.zip)
+ unzip -v "$1" || miniunzip -l "$1" || miniunz -l "$1" || zipinfo -v "$1"
+ ;;
+
+ *.deb|*.udeb)
+ if type -P dpkg > /dev/null ; then
+ dpkg --info "$1"
+ dpkg --contents "$1"
+ else
+ ar tv "$1"
+ ar p "$1" data.tar.gz | tar tzvvf -
+ fi
+ ;;
+
+ ### Filesystems ###
+ *.squashfs) unsquashfs -s "$1" && unsquashfs -ll "$1" ;;
+
+ ### Media ###
+ *.bmp|*.gif|*.jpeg|*.jpg|*.ico|*.pcd|*.pcx|*.png|*.ppm|*.tga|*.tiff|*.tif|*.webp)
+ identify "$1" || file -L -- "$1"
+ ;;
+ *.asf|*.avi|*.mov|*.mp4|*.mpeg|*.mpg|*.qt|*.ram|*.rm|*.webm|*.wmv)
+ midentify "$1" || file -L -- "$1"
+ ;;
+ *.mp3) mp3info "$1" || id3info "$1" ;;
+ *.ogg) ogginfo "$1" ;;
+ *.flac) metaflac --list "$1" ;;
+ *.torrent) torrentinfo "$1" || torrentinfo-console "$1" || ctorrent -x "$1" ;;
+ *.bin|*.cue|*.raw)
+ # not all .bin/.raw files are cd images #285507
+ # fall back to lesspipe_file if .cue doesn't exist, or if
+ # cd-info failed to parse things sanely
+ [[ -e ${1%.*}.cue ]] \
+ && cd-info --no-header --no-device-info "$1" \
+ || lesspipe_file "$1"
+ ;;
+ *.iso)
+ iso_info=$(isoinfo -d -i "$1")
+ echo "${iso_info}"
+ # Joliet output overrides Rock Ridge, so prefer the better Rock
+ case ${iso_info} in
+ *$'\n'"Rock Ridge"*) iso_opts="-R";;
+ *$'\n'"Joliet"*) iso_opts="-J";;
+ *) iso_opts="";;
+ esac
+ isoinfo -l ${iso_opts} -i "$1"
+ ;;
+
+ ### Encryption stuff ###
+ *.crl) openssl crl -hash -text -noout -in "$1" ;;
+ *.csr) openssl req -text -noout -in "$1" ;;
+ *.crt|*.pem) openssl x509 -hash -text -noout -in "$1" ;;
+
+# May not be such a good idea :)
+# ### Device nodes ###
+# /dev/[hs]d[a-z]*)
+# fdisk -l "${1:0:8}"
+# [[ $1 == *hd* ]] && hdparm -I "${1:0:8}"
+# ;;
+
+ ### Everything else ###
+ *)
+ case $(( recur++ )) in
+ # Maybe we didn't match due to case issues ...
+ 0) lesspipe "$1" "$(echo $1 | LC_ALL=C tr '[:upper:]' '[:lower:]')" ;;
+
+ # Maybe we didn't match because the file is named weird ...
+ 1) lesspipe_file "$1" ;;
+ esac
+
+ # So no matches from above ... finally fall back to an external
+ # coloring package. No matching here so we don't have to worry
+ # about keeping in sync with random packages. Any coloring tool
+ # you use should not output errors about unsupported files to
+ # stdout. If it does, it's your problem.
+
+ # Allow people to flip color off if they dont want it
+ case ${LESSCOLOR} in
+ always) LESSCOLOR=2;;
+ [yY][eE][sS]|[yY]|1|true) LESSCOLOR=1;;
+ [nN][oO]|[nN]|0|false) LESSCOLOR=0;;
+ *) LESSCOLOR=0;; # default to no color #188835
+ esac
+ if [[ ${LESSCOLOR} != "0" ]] && [[ -n ${LESSCOLORIZER=code2color} ]] ; then
+ # 2: Only colorize if user forces it ...
+ # 1: ... or we know less will handle raw codes -- this will
+ # not detect -seiRM, so set LESSCOLORIZER yourself
+ if [[ ${LESSCOLOR} == "2" ]] || [[ " ${LESS} " == *" -"[rR]" "* ]] ; then
+ LESSQUIET=true ${LESSCOLORIZER} "$1"
+ fi
+ fi
+
+ # Nothing left to do but let less deal
+ exit 0
+ ;;
+ esac
+}
+
+if [[ -z $1 ]] ; then
+ echo "Usage: lesspipe <file>"
+elif [[ $1 == "-V" || $1 == "--version" ]] ; then
+ Id="cvsid"
+ cat <<-EOF
+ $Id$
+ Copyright 2001-2013 Gentoo Foundation
+ Mike Frysinger <vapier@gentoo.org>
+ (with plenty of ideas stolen from other projects/distros)
+
+
+ EOF
+ less -V
+elif [[ $1 == "-h" || $1 == "--help" ]] ; then
+ cat <<-EOF
+ lesspipe: preprocess files before sending them to less
+
+ Usage: lesspipe <file>
+
+ lesspipe specific settings:
+ LESSCOLOR env - toggle colorizing of output (no/yes/always)
+ LESSCOLORIZER env - program used to colorize output (default: code2color)
+ LESSIGNORE - list of extensions to ignore (don't do anything fancy)
+
+ You can create per-user filters as well by creating the executable file:
+ ~/.lessfilter
+ One argument is passed to it: the file to display.
+
+ To use lesspipe, simply add to your environment:
+ export LESSOPEN="|lesspipe %s"
+
+ Run 'less --help' or 'man less' for more info
+ EOF
+elif [[ -d $1 ]] ; then
+ ls -alF -- "$1"
+else
+ recur=0
+ [[ -n ${LESSDEBUG} ]] \
+ && lesspipe "$1" \
+ || lesspipe "$1" 2> /dev/null
+fi
diff --git a/sys-apps/less/less-481.ebuild b/sys-apps/less/less-481.ebuild
new file mode 100644
index 00000000..ddbb26ff
--- /dev/null
+++ b/sys-apps/less/less-481.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit eutils
+
+CODE2COLOR_PV="0.2"
+CODE2COLOR_P="code2color-${CODE2COLOR_PV}"
+DESCRIPTION="Excellent text file viewer, optionally with additional selection feature"
+PATCHN="less-select"
+PATCHV="2.6"
+PATCHVER="466"
+PATCHRUMP="${PATCHN}-${PATCHV}"
+PATCHBALL="${PATCHRUMP}.tar.gz"
+SELECTDIR="${WORKDIR}/${PATCHRUMP}"
+HOMEPAGE="http://www.greenwoodsoftware.com/less/ https://github.com/vaeth/${PATCHN}"
+SRC_URI="http://www.greenwoodsoftware.com/less/${P}.tar.gz
+ less-select? ( https://github.com/vaeth/${PATCHN}/archive/v${PATCHV}.tar.gz -> ${PATCHBALL} )
+ http://www-zeuthen.desy.de/~friebel/unix/less/code2color -> ${CODE2COLOR_P}"
+
+LICENSE="|| ( GPL-3 BSD-2 )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="+lesspipe +less-select pcre original-gentoo source unicode"
+
+DEPEND=">=app-misc/editor-wrapper-3
+ >=sys-libs/ncurses-5.2
+ pcre? ( dev-libs/libpcre )"
+RDEPEND="${DEPEND}
+ less-select? ( dev-lang/perl
+ || ( >=dev-lang/perl-5.10.1 >=virtual/perl-File-Temp-0.19 )
+ )"
+PDEPEND="lesspipe? ( sys-apps/lesspipe )"
+
+pkg_setup() {
+ if use source && ! use less-select
+ then ewarn 'ignoring USE=source without USE=less-select'
+ fi
+}
+
+src_unpack() {
+ unpack ${P}.tar.gz
+ cp "${DISTDIR}/${CODE2COLOR_P}" "${S}"/code2color || die
+ if use less-select
+ then unpack ${PATCHBALL}
+ fi
+}
+
+src_prepare() {
+ if use less-select
+ then epatch "${SELECTDIR}/patches/less-${PATCHVER}-select.patch" || die
+ "${SELECTDIR}"/after-patch || die "${SELECTDIR}/after-patch failed"
+ sed -i -e 's|\([^a-zA-Z]\)/etc/less-select-key.bin|\1'"${EPREFIX}"'/etc/less/select-key.bin|g' \
+ "${SELECTDIR}/bin/less-select" || die
+ fi
+ epatch "${FILESDIR}/${CODE2COLOR_P}.patch"
+ chmod a+x configure || die
+ epatch_user
+}
+
+src_configure() {
+ export ac_cv_lib_ncursesw_initscr=$(usex unicode)
+ export ac_cv_lib_ncurses_initscr=$(usex !unicode)
+ econf \
+ --with-regex=$(usex pcre pcre posix) \
+ --with-editor="${EPREFIX}"/usr/libexec/editor
+}
+
+src_compile() {
+ default
+ if use less-select
+ then ./lesskey -o normal-key.bin "${SELECTDIR}/keys/less-normal-key.src" || die
+ ./lesskey -o select-key.bin "${SELECTDIR}/keys/less-select-key.src" || die
+ fi
+}
+
+src_install() {
+ local a
+ default
+
+ if ! use lesspipe
+ then dobin code2color
+ newbin "${FILESDIR}"/lesspipe.sh lesspipe
+ dosym lesspipe /usr/bin/lesspipe.sh
+ fi
+ if use original-gentoo
+ then a="-R -M --shift 5"
+ else a="-sFRiMX --shift 5"
+ fi
+ printf '%s\n' 'LESSOPEN="|lesspipe.sh %s"' "LESS=\"${a}\"" >70less
+ doenvd 70less
+
+ dodoc "${FILESDIR}"/README.Gentoo
+
+ if use less-select
+ then newdoc "${SELECTDIR}"/README README.less-select
+ dobin "${SELECTDIR}/bin/"*
+ insinto /etc/less
+ doins select-key.bin normal-key.bin
+ if use source
+ then newins "${SELECTDIR}/keys/less-select-key.src" select-key.src
+ newins "${SELECTDIR}/keys/less-normal-key.src" normal-key.src
+ fi
+ fi
+}
+
+pkg_postinst() {
+ use lesspipe || \
+ elog "lesspipe offers colorization options. Run 'lesspipe -h' for info."
+}
diff --git a/sys-apps/less/metadata.xml b/sys-apps/less/metadata.xml
new file mode 100644
index 00000000..b6405b97
--- /dev/null
+++ b/sys-apps/less/metadata.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>base-system</herd>
+ <maintainer>
+ <email>martin@mvath.de</email>
+ <name>Martin Väth</name>
+ </maintainer>
+ <upstream>
+ <maintainer>
+ <email>martin@mvath.de</email>
+ <name>Martin Väth</name>
+ <description>Maintainer of the less-select patch</description>
+ </maintainer>
+ <bugs-to>mailto:martin@mvath.de</bugs-to>
+ <remote-id type="github">vaeth/less-select</remote-id>
+ </upstream>
+ <use>
+ <flag name="original-gentoo">Use the gentoo default for the LESS variable.</flag>
+ <flag name="lesspipe">Use sys-apps/lesspipe instead of Gentoo's default lesspipe.sh.</flag>
+ <flag name="less-select">Add the less-select feature (additional options and a binary helper).</flag>
+ <flag name="source">Install sources for keybindings (only useful with less-select).</flag>
+ </use>
+</pkgmetadata>