diff options
author | simona | 2020-10-31 17:35:55 +0100 |
---|---|---|
committer | simona | 2020-10-31 17:35:55 +0100 |
commit | 639b30123e9d4d89110028d7354d5259ef96ae30 (patch) | |
tree | d1584be86c1f577e3ab1e481a062df436cd11c31 | |
download | aur-639b30123e9d4d89110028d7354d5259ef96ae30.tar.gz |
first release
-rw-r--r-- | .SRCINFO | 18 | ||||
-rwxr-xr-x | PKGBUILD | 56 | ||||
-rwxr-xr-x | locatec | 7 | ||||
-rwxr-xr-x | locatecc | 86 |
4 files changed, 167 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..fe99cbda3026 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,18 @@ +pkgbase = locatec + pkgdesc = Better locate/plocate, search inside local path + pkgver = 0.0.1 + pkgrel = 1 + arch = any + license = GPL3 + depends = bash + depends = mlocate + depends = coreutils + optdepends = plocate + optdepends = perl + source = locatec + source = locatecc + md5sums = 915f024abe9d12246891d55e56f49660 + md5sums = 56cbfe0855d86c16293b32e955ce164b + +pkgname = locatec + diff --git a/PKGBUILD b/PKGBUILD new file mode 100755 index 000000000000..b7482536cf00 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,56 @@ +# Maintainer: Simona <simona.pisano[at]gmail[dot]com> +pkgname=locatec +pkgver=0.0.1 +pkgrel=1 +pkgdesc="Better locate/plocate, search inside local path" +#url="https://github.com/simona70/grub-custom-simona" +arch=('any') +license=('GPL3') + +depends=('bash' 'mlocate' 'coreutils') +optdepends=('plocate' 'perl') + +#t does not need to be included in the source array +#changelog=$pkgname.changelog + +source=($pkgname-$pkgver.tar.gz) #file locale incapsulato localmente +#source=("$pkgname"::'git+https://github.com/maateen/battery-monitor.git#branch=devel') +#source=("$pkgname-$pkgver.tar.gz::https://github.com/loh-tar/$pkgname/archive/v$pkgver.tar.gz") +#source=("http://foo.org/bar/foobar.tar.xz") +source=("locatec" "locatecc") + +#backup=('etc/default/grub-custom') + +#noextract=('foobar.tar.xz') +#prepare() { +# lrzip -d source.tar.lrz +#prepare() { +# tar -xf ${pkgname}-${pkgver}.tar.gz + +#generate with 'makepkg -g' +#md5sums=('SKIP') +md5sums=('915f024abe9d12246891d55e56f49660' + '56cbfe0855d86c16293b32e955ce164b') + +# se trova il nuovo si chiama .pacnew (no / root path) +#backup=('dir/file') + +# 4=r 2=w 1=x owner group others +package() { + cd "$srcdir" + + install -Dm755 "$srcdir/locatecc" "$pkgdir/usr/bin/locatecc" + install -Dm755 "$srcdir/locatec" "$pkgdir/usr/bin/locatec" +} + + + + + + + + + + + + diff --git a/locatec b/locatec new file mode 100755 index 000000000000..8a1e72599310 --- /dev/null +++ b/locatec @@ -0,0 +1,7 @@ +#!/bin/bash + +#launcher for locatecc + +reset_expansion(){ CMD="$1";shift;$CMD "$@";set +f;} +set -f;reset_expansion locatecc "$@" + diff --git a/locatecc b/locatecc new file mode 100755 index 000000000000..65cdc3eae2dd --- /dev/null +++ b/locatecc @@ -0,0 +1,86 @@ +#!/bin/bash + +#launch locatecc instead this + +search_str="$@" + + #simona 30/10/2020 + #updatedb /var/lib/mlocate/ + #plocate-build /var/lib/mlocate/mlocate.db /var/lib/mlocate/plocate.db + locate-current() { + [[ -r /bin/plocate ]] && exe="/bin/plocate" || exe="/bin/locate" + [[ $1 == "-h" || $1 == "--help" ]] && { echo "Remember 'updatedb /var/lib/mlocate/' and 'plocate-build /var/lib/mlocate/mlocate.db /var/lib/mlocate/plocate.db'" ; return 0; } + + [[ ${#search_str} -le 3 ]] && { echo "Search string too short or missing"; return 1; } + + rm -f /tmp/locate-temp-file-1 + touch /tmp/locate-temp-file-1 + $exe --ignore-case "$search_str" > /tmp/locate-temp-file-1 + + touch /tmp/locate-temp-file-2 + cat /tmp/locate-temp-file-1 | grep "^$(pwd)" --ignore-case --color=never >/tmp/locate-temp-file-2 + + touch /tmp/locate-temp-file-3 + cat /tmp/locate-temp-file-2 | grep --ignore-case --color=never "/$search_str" >/tmp/locate-temp-file-3 + cat /tmp/locate-temp-file-2 | grep --ignore-case --color=never "/$search_str\.[A-Za-z0-9]*$" >>/tmp/locate-temp-file-3 + + #cancellazione duplicati + touch /tmp/locate-temp-file-4 + [[ -r /bin/perl ]] && perl -ne 'print unless $dup{$_}++;' /tmp/locate-temp-file-3 > /tmp/locate-temp-file-4 || sort -u /tmp/locate-temp-file-3 > /tmp/locate-temp-file-4 + + #se ho una /dir1/dir1/file + #seguito da /dir1/dir1/file/qualcosa1 + #/dir1/dir1/file/qualcosa2 + #la seconsa e terza ricorrenza le devo cancellare + rm -f /tmp/locate-temp-file-5 + touch /tmp/locate-temp-file-5 + pr_line="" + pr_line_len=0 + st_line="off" + st_line_len=0 + while read -r line ; do + line_len=${#line} + if [[ $pr_line != "" ]] ; then + if [[ $st_line == "off" ]] ; then + if [[ ${line:0:$pr_line_len} == $pr_line ]] ; then + st_line=$pr_line + st_line_len=${#st_line} + else + echo $line >>/tmp/locate-temp-file-5 + fi + else + if [[ ${line:0:$st_line_len} != $st_line ]] ; then + st_line="off" + echo $line >>/tmp/locate-temp-file-5 + fi + fi + else + echo $line >>/tmp/locate-temp-file-5 + fi + + #next loop + pr_line=$line + pr_line_len=${#pr_line} + done < /tmp/locate-temp-file-4 + + #per colorazione + grep --color -E $search_str /tmp/locate-temp-file-5 + + count=$(wc -l /tmp/locate-temp-file-5) + count=$(echo $count | cut -f1 -d" ") + echo "$count items found" + + rm -f /tmp/locate-temp-file-1 + rm -f /tmp/locate-temp-file-2 + rm -f /tmp/locate-temp-file-3 + rm -f /tmp/locate-temp-file-4 + rm -f /tmp/locate-temp-file-5 + + [[ $count -gt 0 ]] && return 0 || return 1 + } + + +locate-current + + + |