Created
August 20, 2021 07:35
-
-
Save Hayao0819/a7ea205b899e3a3f49bffc9204a20675 to your computer and use it in GitHub Desktop.
Pacmanのリモートのパッケージの一覧を取得するシェルスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
#shellcheck disable=SC2120 | |
getRemotePkgList(){ | |
local _split="${1-\|}" | |
#while read -r db; do | |
# gzip -dc "${db}" | grep -a -A 1 -e "%NAME%" -e "%ARCH%" -e "%DESC%" | grep -axv "\-\-" | sed "s|%NAME%|\x0\x0|g" | sed "s|^%[^%]*%$|\x0|g" | tr -d "\n" | sed "s|\x0\x0|\n|g" | sed "s|\(.*\)\x0\(.*\)\x0\(.*\)|\1${_split}\3${_split}\2|g" | |
#done < <(find "$(pacman-conf DBPath)/sync" -mindepth 1 -maxdepth 1 -name "*.db" -printf "%p\n") | sort -t "${_split#\\}" | grep -v "^$" | |
find "$(pacman-conf DBPath)/sync" -mindepth 1 -maxdepth 1 -name "*.db" -printf "%p\0" | xargs -I{} -0 bash -c "gzip -dc {} | grep -a -A 1 -e '%NAME%' -e '%ARCH%' -e '%DESC%' | grep -axv '\-\-' | sed 's|%NAME%|\x0\x0|g' | sed 's|^%[^%]*%$|\x0|g' | tr -d '\n' | sed 's|\x0\x0|\n|g' | sed 's|\(.*\)\x0\(.*\)\x0\(.*\)|\1${_split}\3${_split}\2\n|g'" | grep -v "^$" | sort -t "${_split#\\}" | |
} | |
getRemotePkgList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment