summaryrefslogtreecommitdiff
path: root/src/repo-diff
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo-diff')
-rwxr-xr-xsrc/repo-diff75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/repo-diff b/src/repo-diff
new file mode 100755
index 0000000..e36edad
--- /dev/null
+++ b/src/repo-diff
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+# Shows a diff between repo databases
+
+# Copyright (C) 2013 Nicolás Reynolds <fauno@parabola.nu>
+#
+# License: GNU GPLv3+
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. libremessages
+
+usage() {
+ print "Usage: %s arch/core/i686 parabola/core/i686" "${0##*/}"
+ print "Compares two repo databases using distro/repo/architecture format."
+ echo
+ print 'Shortcuts:'
+ flag 'arch' 'expands to Arch Linux repo url'
+ flag 'parabola' 'expands to Parabola GNU/Linux-libre repo url'
+}
+
+if test $# -eq 0; then
+ usage
+ exit 0
+fi
+
+b() { bsdtar ztf $1 | cut -d "/" -f1 | sort -u ; }
+n() { echo "$1".db | tr "/" "-"; }
+
+# hopefully simple way to convert
+# parabola/libre/i686
+# to
+# http://repo.parabolagnulinux.org/libre/os/i686/libre.db
+# add more distros here
+g() {
+ echo "$1" | sed -e "s,^\([^/]\+\)/\([^/]\+\)/\([^/]\+\)$,\1/\2/os/\3/\2.db," \
+ -e "s,^parabola/,http://repo.parabolagnulinux.org/," \
+ -e "s,^arch\(linux\)\?/,http://mirrors.kernel.org/archlinux/,"
+}
+
+mkdir ${0##*/}.$$
+pushd ${0##*/}.$$ >/dev/null
+
+d=""
+for i in $1 $2; do
+ n=$(n "$i")
+
+ test -z "$n" && exit 1
+
+ wget -O "$n" -nv $(g "$i")
+ b "$n" >${n}.orig
+
+ d+=" ${n}.orig"
+done
+
+{
+ printf "$(gettext "Difference between %s and %s")\n---\n" $1 $2
+ which diffstat &>/dev/null && diff -auN "${d[@]}" | diffstat
+ diff -auN "${d[@]}"
+} >../${n}.diff
+
+popd >/dev/null
+rm -r ${0##*/}.$$
+
+print "Difference save on %s" "${n}.diff"