#!/bin/ksh93 # # merge Rauchs Subversion tree into our git, # one patch at the time # set -o xtrace set -o errexit set -o pipefail which bunzip2 || exit 1 which git || exit 1 which realpath || exit 1 which svn || exit 1 which svnadmin || exit 1 which svnrdump || exit 1 builtin chmod || exit 1 #builtin ln || exit 1 # broken Debian ksh93 package config, grrr... builtin mkdir || exit 1 builtin printf || exit 1 #builtin rm || exit 1 # broken Debian ksh93 package config, grrr... builtin wc || exit 1 # clean data from previous run rm -Rf gitsvnclone1 svnstore convertedsrc compare_oldnew # squish locale settings, we need the POSIX defaults if [[ "${!LC_*}" != '' ]] ; then unset "${!LC_@}" fi unset LANG export LANG='POSIX' typeset -r infile='rauch_svndump20200128.svndump.bz2' typeset -r basedir="$PWD" compound svninfo [[ ! -f "${infile}" ]] && exit 1 [[ ! -r "${infile}" ]] && exit 1 # create empty SVN repository svnadmin create svnstore # add dummy hook to allow property changes for "svnrdump load" printf '#!/bin/sh\nexit 0\n' >'svnstore/hooks/pre-revprop-change' chmod a+x 'svnstore/hooks/pre-revprop-change' bunzip2 -c <"${infile}" | svnrdump load "file://$basedir/svnstore/" # get HEAD revision (number) from svn repository integer svninfo.revision svninfo.cmdout="$(svn info "file://$basedir/svnstore")" dummy="${svninfo.cmdout/~(E)Revision:[[:space:]]+([[:digit:]]+)/ }" (( svninfo.revision=.sh.match[1] )) printf '# Subversion info:\n' print -v svninfo mkdir 'gitsvnclone1' cd 'gitsvnclone1' git svn clone "file://$basedir/svnstore" ls -lad 'svnstore/trunk/projekt/ptxdist/' cd 'svnstore/trunk/projekt/ptxdist/' # extract all patches from git repository previously # stored by "git svn" there git format-patch -$(( svninfo.revision+1 )) # remove patch files which are empty (for i in *.patch ; do if [[ ! -s "$i" ]] ; then rm -- "$i" ; fi ; done) # list remaining patches IFS=$'\n' ; typeset -a patchlist=( $(ls -1ad $PWD/*.patch ) ) printf '\n#### Patches:\n' printf '%q\n' "${patchlist[@]}" printf '\n#### Number of patches: %d\n' "$(wc -l <<<"$patchlist")" cd "$basedir" mkdir 'convertedsrc' cd 'convertedsrc' printf '%s\n' "${patchlist[@]}" | sort -n | while read i ; do # 1. use "|| true" to circumvent -o errexit for now since # GNU patch does not support GIT binary patches and returns # a non-0 exit code for such patches # 2. use --force to avoid interactive queries about GIT binary patches patch -p3 --force <"$i" || true done cd "$basedir" mkdir 'compare_oldnew' cd 'compare_oldnew' (mkdir 'old' && cd 'old' && svn export "file://$basedir/svnstore/trunk/projekt/ptxdist") mkdir new ln -s '../../convertedsrc/ptxdist' 'new/.' cd "$basedir" (diff -r -u 'compare_oldnew/old/ptxdist/' 'compare_oldnew/new/ptxdist/' || true) 2>&1 | egrep -v '^Only in compare_oldnew/old/.+: (ecu-jobctl-demo|barebox-image|bareboxenv|libEMC|lin|.+\.(app|png|jpg|jpeg|gz|bin|iop|pdf|so\.[[:digit:]]+.+|crc|vtg))$' printf '# DONE!\n' exit 0 # EOF.