index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2019-03-08 07:19:02 +0100 |
---|---|---|
committer | Levente Polyak <levente@leventepolyak.net> | 2019-03-13 09:16:32 +0100 |
commit | f61421a3f5f29f4f8447846c1135961487fb5db6 (patch) | |
tree | 14c29d578409bb2d9bde08c6c0b6ca7546619a81 | |
parent | 26b2ffc665fb78bfe3345892b7d740d5835387f2 (diff) |
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | doc/footer.asciidoc | 2 | ||||
-rw-r--r-- | doc/sogrep.1.asciidoc | 31 | ||||
-rw-r--r-- | sogrep | 98 |
@@ -16,7 +16,8 @@ BINPROGS = \ crossrepomove\ arch-nspawn \ mkarchroot \ - makechrootpkg + makechrootpkg \ + sogrep CONFIGFILES = \ makepkg-x86_64.conf \ @@ -63,7 +64,8 @@ BASHCOMPLETION_LINKS = \ MANS = \ doc/lddd.1 \ - doc/checkpkg.1 + doc/checkpkg.1 \ + doc/sogrep.1 all: $(BINPROGS) bash_completion zsh_completion man diff --git a/doc/footer.asciidoc b/doc/footer.asciidoc index a092447..a1fb821 100644 --- a/doc/footer.asciidoc +++ b/doc/footer.asciidoc @@ -20,7 +20,7 @@ Maintainers: * Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> * Levente Polyak <anthraxx@archlinux.org> * Pierre Schmitz <pierre@archlinux.de> -* Sébastien Luttringer <seblu@seblu.net> +* Sébastien Luttringer <seblu@seblu.net> * Sven-Hendrik Haase <svenstaro@gmail.com> * Thomas Bächler <thomas@archlinux.org> diff --git a/doc/sogrep.1.asciidoc b/doc/sogrep.1.asciidoc new file mode 100644 index 0000000..328b82b --- /dev/null +++ b/doc/sogrep.1.asciidoc @@ -0,0 +1,31 @@ +sogrep(1) +========= + +Name +---- +sogrep - Find packages using a linked to a given shared library + +Synopsis +-------- +sogrep [options] repo libname + +Description +----------- + +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 a help text + +include::footer.asciidoc[] @@ -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 |