Skip to content

Instantly share code, notes, and snippets.

@falconindy
Last active August 3, 2017 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falconindy/eba05be0f14203e59bfabdb15487248b to your computer and use it in GitHub Desktop.
Save falconindy/eba05be0f14203e59bfabdb15487248b to your computer and use it in GitHub Desktop.
#
# Example usage:
# $ git clone --depth=1 git://git.archlinux.org/svntogit/packages.git
# $ ( cd packages >/dev/null && find-https ) >unused-https.txt
#
has_https_available() {
local https_url url_eff
https_url=https${1#http}
url_eff=$(curl -sLfI -o/dev/null -w '%{url_effective}' "$https_url") &&
[[ $url_eff = https:* ]]
}
print_srcinfo() {
local bin=$HOME/code/pkgbuild-introspection/introspect
# introspect from p-i is substantially faster than makepkg.
if type -p "$bin"; then
"$bin" "$1"
else
makepkg --printsrcinfo "$1"
fi
}
find_https() {
local v
mapfile -t sources < <(print_srcinfo "$d" | awk '$1 == "source" && $3 ~ /http:/ { print $3 }')
for v in "${sources[@]}"; do
# strip source renaming
[[ $v = *::* ]] && v=${v#*::}
if has_https_available "$v"; then
d=${d%/trunk/} d=${d##*/}
printf '%s\t%s\n' "$d" "https${v#http}"
continue 2
fi
done
}
if (( $# )); then
search=("$@")
else
search=(*/trunk/PKGBUILD)
fi
MAX_JOBS=${MAX_JOBS:-20}
for d in "${search[@]}"; do
while (( $(jobs -p | wc -l) >= MAX_JOBS )); do
# we could use 'wait -n' here, but it doesn't seem to play nicely with
# interrupting the script and just hangs forever.
sleep 1s
done
find_https "$d" &
done
wait
#!/bin/bash
#
# Attempts to find packages where gpg signatures are available, but not
# referenced by the PKGBUILD. This script expects to run on a git clone of
# Arch's SVN repos, i.e.
#
# git://git.archlinux.org/svntogit/packages.git/
# git://git.archlinux.org/svntogit/community.git/
#
# Example usage:
# $ git clone --depth=1 git://git.archlinux.org/svntogit/packages.git
# $ ( cd packages >/dev/null && find-unused-gpg ) >unused-gpg.txt
#
curl_silent() {
curl -gsLfI -o/dev/null "$@"
}
has_gpg() {
local url=$1 ext=$2
if [[ $url = http:* ]]; then
if curl_silent "https${url#http}.$ext"; then
echo "https${url#http}.$ext"
return 0
fi
fi
curl_silent "$url.$ext" && echo "$url.$ext"
}
print_srcinfo() {
local bin=$HOME/code/pkgbuild-introspection/introspect
# introspect from p-i is substantially faster than makepkg.
if type -p "$bin"; then
"$bin" "$1"
else
makepkg --printsrcinfo "$1"
fi
}
find_unused_gpg() {
local d=$1 sigurl
declare -A sources
while read -r src; do
sources["$src"]=1
done < <(print_srcinfo "$d" | awk '$1 ~ /^source/ && $3 ~ /http:/ { print $3 }')
for v in "${!sources[@]}"; do
# skip non-remote files
[[ $v = *://* ]] || continue
# skip things which look like signatures already
[[ $v = *.@(sig|asc) ]] && continue
# strip source renaming
[[ $v = *::* ]] && v=${v#*::}
for ext in sig asc; do
(( 'sources[$v.$ext]' )) && break 2
done
for ext in sig asc; do
if sigurl=$(has_gpg "$v" "$ext"); then
printf '%s\t%s\n' "$1" "$sigurl"
break
fi
done
done
}
if (( $# )); then
search=("$@")
else
search=(*/trunk/PKGBUILD)
fi
MAX_JOBS=${MAX_JOBS:-20}
for d in "${search[@]}"; do
while (( $(jobs -p | wc -l) >= MAX_JOBS )); do
# we could use 'wait -n' here, but it doesn't seem to play nicely with
# interrupting the script and just hangs forever.
sleep
done
find_unused_gpg "$d" &
done
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment