From ebba5a588534bce575c877694790af87a812aa6c Mon Sep 17 00:00:00 2001 From: Eli Schwartz via arch-projects Date: Mon, 25 Mar 2019 16:32:18 -0400 Subject: sogrep: don't be templated when it is not templated Partition the Makefile targets to only clean configured files, and make the configured files be a subset of the bin programs. Signed-off-by: Eli Schwartz --- .gitignore | 1 - Makefile | 9 ++++-- sogrep | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sogrep.in | 98 -------------------------------------------------------------- 4 files changed, 104 insertions(+), 102 deletions(-) create mode 100644 sogrep delete mode 100644 sogrep.in diff --git a/.gitignore b/.gitignore index 6a1d1e4..b63587b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,4 @@ zsh_completion find-libdeps crossrepomove arch-nspawn -sogrep doc/*.1 diff --git a/Makefile b/Makefile index 055ed2d..39785c3 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ V=20180531 PREFIX = /usr/local MANDIR = $(PREFIX)/share/man -BINPROGS = \ +IN_PROGS = \ checkpkg \ commitpkg \ archco \ @@ -16,7 +16,10 @@ BINPROGS = \ crossrepomove\ arch-nspawn \ mkarchroot \ - makechrootpkg \ + makechrootpkg + +BINPROGS = \ + $(IN_PROGS) \ sogrep CONFIGFILES = \ @@ -90,7 +93,7 @@ doc/%: doc/%.asciidoc a2x --no-xmllint --asciidoc-opts="-f doc/asciidoc.conf" -d manpage -f manpage -D doc $< clean: - rm -f $(BINPROGS) bash_completion zsh_completion $(MANS) + rm -f $(IN_PROGS) bash_completion zsh_completion $(MANS) install: install -dm0755 $(DESTDIR)$(PREFIX)/bin diff --git a/sogrep b/sogrep new file mode 100644 index 0000000..3be2672 --- /dev/null +++ b/sogrep @@ -0,0 +1,98 @@ +#!/bin/bash +# License: Unspecified + +: ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"} +: ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"} +repos=('staging' 'testing' 'core' 'extra' + 'community-staging' 'community-testing' 'community' + 'multilib-staging' 'multilib-testing' 'multilib' + 'gnome-unstable' 'kde-unstable') +arches=('x86_64') + +source /usr/share/makepkg/util/util.sh + +recache() { + local repo arch + + for repo in "${repos[@]}"; do + for arch in "${arches[@]}"; do + rm -rf "${SOCACHE_DIR}/${arch}/${repo}" + mkdir -p "${SOCACHE_DIR}/${arch}/${repo}" + curl "${SOLINKS_MIRROR}/${repo}/os/${arch}/${repo}.links.tar.gz" | bsdtar -xf - -C "${SOCACHE_DIR}/${arch}/${repo}" + done + done +} + +search() { + local repo=$1 arch lib=$2 + + if [[ $repo != all ]]; then + if ! in_array "$repo" "${repos[@]}"; then + echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'" + echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." + exit 1 + fi + local repos=("${repo}") + fi + + if [[ ! -d ${SOCACHE_DIR} ]]; then + recache + fi + + for arch in "${arches[@]}"; do + for repo in "${repos[@]}"; do + db=${SOCACHE_DIR}/${arch}/${repo}/ + if [[ -d ${db} ]]; then + while read -rd '' pkg; do + pkg=${pkg#${db}} + printf '%s/%s\n' "${repo}" "${pkg%-*-*/links}" + done < <(grep -rlZ "${lib}" "${db}") + fi + done + done | sort -u +} + +usage() { + cat <<- _EOF_ + Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] REPO LIBNAME + + Check the soname links database for pacman repositories containing + packages linked to a given shared library. If the repository specified + is "all", then all repositories will be searched, otherwise only the + named repository will be searched. + + If the links database does not exist, it will be downloaded first. + + OPTIONS + -r, --refresh Refresh the links databases + -h, --help Show this help text +_EOF_ +} + +if (( $# == 0 )); then + echo "error: No arguments passed." + echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." + exit 1 +fi + +while (( $# )); do + case $1 in + -r|--refresh) + recache + ;; + -h|--help) + usage + exit 0 + ;; + *) + if (( $# < 2 )); then + echo "error: Not enough arguments passed." + echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." + exit 1 + fi + search "$@" + exit $? + ;; + esac + shift +done diff --git a/sogrep.in b/sogrep.in deleted file mode 100644 index 3be2672..0000000 --- a/sogrep.in +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# License: Unspecified - -: ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"} -: ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"} -repos=('staging' 'testing' 'core' 'extra' - 'community-staging' 'community-testing' 'community' - 'multilib-staging' 'multilib-testing' 'multilib' - 'gnome-unstable' 'kde-unstable') -arches=('x86_64') - -source /usr/share/makepkg/util/util.sh - -recache() { - local repo arch - - for repo in "${repos[@]}"; do - for arch in "${arches[@]}"; do - rm -rf "${SOCACHE_DIR}/${arch}/${repo}" - mkdir -p "${SOCACHE_DIR}/${arch}/${repo}" - curl "${SOLINKS_MIRROR}/${repo}/os/${arch}/${repo}.links.tar.gz" | bsdtar -xf - -C "${SOCACHE_DIR}/${arch}/${repo}" - done - done -} - -search() { - local repo=$1 arch lib=$2 - - if [[ $repo != all ]]; then - if ! in_array "$repo" "${repos[@]}"; then - echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'" - echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." - exit 1 - fi - local repos=("${repo}") - fi - - if [[ ! -d ${SOCACHE_DIR} ]]; then - recache - fi - - for arch in "${arches[@]}"; do - for repo in "${repos[@]}"; do - db=${SOCACHE_DIR}/${arch}/${repo}/ - if [[ -d ${db} ]]; then - while read -rd '' pkg; do - pkg=${pkg#${db}} - printf '%s/%s\n' "${repo}" "${pkg%-*-*/links}" - done < <(grep -rlZ "${lib}" "${db}") - fi - done - done | sort -u -} - -usage() { - cat <<- _EOF_ - Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] REPO LIBNAME - - Check the soname links database for pacman repositories containing - packages linked to a given shared library. If the repository specified - is "all", then all repositories will be searched, otherwise only the - named repository will be searched. - - If the links database does not exist, it will be downloaded first. - - OPTIONS - -r, --refresh Refresh the links databases - -h, --help Show this help text -_EOF_ -} - -if (( $# == 0 )); then - echo "error: No arguments passed." - echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." - exit 1 -fi - -while (( $# )); do - case $1 in - -r|--refresh) - recache - ;; - -h|--help) - usage - exit 0 - ;; - *) - if (( $# < 2 )); then - echo "error: Not enough arguments passed." - echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." - exit 1 - fi - search "$@" - exit $? - ;; - esac - shift -done -- cgit v1.2.3-70-g09d2