diff options
author | Erich Eckner <git@eckner.net> | 2019-07-18 14:10:11 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-07-18 14:10:11 +0200 |
commit | 11e8bedbd9f408e795a21d97c624cd93fc10255b (patch) | |
tree | 4289faf2f12aa9fb893fc682228a2511ef230144 /find-package-differences | |
parent | d11d36e7348d2e0e4062034468b02d4868f9f66e (diff) | |
download | archlinuxewe.git.save-11e8bedbd9f408e795a21d97c624cd93fc10255b.tar.xz |
find-package-differences new
Diffstat (limited to 'find-package-differences')
-rwxr-xr-x | find-package-differences | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/find-package-differences b/find-package-differences new file mode 100755 index 00000000..a6c9a964 --- /dev/null +++ b/find-package-differences @@ -0,0 +1,136 @@ +#!/bin/bash + +if [ $# -eq 2 ]; then + cd "${1}" + if [ ! -f '.SRCINFO' ] || + [ "$(stat -c%Y PKGBUILD)" -gt "$(stat -c%Y .SRCINFO)" ]; then + makepkg --printsrcinfo > .SRCINFO + fi + sed ' + /^\S/ b + /^\s\+\(arch\|epoch\|pkgver\|pkgrel\) = \S/ b + /^$/ b + d + ' '.SRCINFO' \ + > "${2}" + all=$( + sed -n ' + /^pkgbase = /,/^$/ { + /^\s/ p + } + ' "${2}" \ + | sed ' + $! s/$/\\/ + ' + ) + all_noarch=$( + printf '%s\n' "${all}" \ + | grep -v '^\sarch = ' \ + | sed ' + $ s/\\$// + ' + ) + sed -i ' + /^pkgbase = /,/^$/ d + /^pkgname = / { + :a + N + /\n$/ ! ba + /\n\sarch = / { + a\ +'"${all_noarch}"' + b + } + a\ +'"${all}"' + } + ' "${2}" + sed -i ' + /^\s*$/d + ' "${2}" + exit +fi + +if [ $# -ne 0 ]; then + >&2 echo 'usage error' + >&2 printf '"%s" ' "$@" + >&2 printf '\n' + exit 1 +fi + +tmp_dir=$(mktemp -d) +trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT + +find "$(pwd)" -maxdepth 2 -mindepth 2 -name 'PKGBUILD' -type f \ +| sed -n ' + s@/[^/]\+$@@ + T + s@/[^/]\+$@\0\n'"${tmp_dir%/}"'\0.srcinfo@ + T + p +' \ +| parallel -j0 -L2 "$0" + +print_names() { + if [ -z "${pkgname}" ] \ + || [ -z "${pkgver}" ] \ + || [ -z "${pkgrel}" ]; then + >&2 echo 'error: some variable is missing' + exit 1 + fi + for arch in "${archs[@]}"; do + printf '%s-%s%s-%s-%s.pkg.tar.xz\n' \ + "${pkgname}" \ + "${epoch:+${epoch}:}" \ + "${pkgver}" \ + "${pkgrel}" \ + "${arch}" + done +} + +diff -u --color <( + find /mnt/archlinuxewe -type f -name '*.pkg.tar.xz' -printf '%f\n' \ + | sort -u +) <( + find "$tmp_dir" -name '*.srcinfo' -exec cat {} + \ + | { + while read key eq value; do + if [ "x${eq}" != 'x=' ]; then + >&2 echo "syntax error" + exit 1 + fi + case "${key}" in + 'pkgname') + if [ -n "${pkgname}" ]; then + print_names + fi + archs=() + pkgname="${value}" + unset epoch + unset pkgver + unset pkgrel + ;; + 'arch') + archs+=("${value}") + ;; + 'epoch') + epoch="${value}" + ;; + 'pkgver') + pkgver="${value}" + ;; + 'pkgrel') + pkgrel="${value}" + ;; + *) + >&2 printf 'unknown key "%s"\n' "${key}" + exit 1 + ;; + esac + done + if [ -n "${pkgname}" ]; then + print_names + fi + } \ + | sort -u +) |