Difference between
modified post 66d56222 by Anonymous on Fri 7th Feb 2020 17:30
original post 77d by Anonymous on Fri 7th Feb 2020 16:22
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/bin/ksh93 | |
| 2 | 2 | ||
| 3 | 3 | # | |
| 4 | 4 | # merge Rauchs Subversion tree into our git, | |
| 5 | 5 | # one patch at the time | |
| 6 | 6 | # | |
| 7 | 7 | ||
| 8 | 8 | set -o xtrace | |
| 9 | 9 | set -o errexit | |
| 10 | 10 | set -o pipefail | |
| 11 | 11 | ||
| 12 | 12 | which bunzip2 || exit 1 | |
| 13 | 13 | which git || exit 1 | |
| 14 | 14 | which realpath || exit 1 | |
| 15 | 15 | which svn || exit 1 | |
| 16 | 16 | which svnadmin || exit 1 | |
| 17 | 17 | which svnrdump || exit 1 | |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | builtin chmod || exit 1 | |
| 21 | + | #builtin grep || exit 1 | |
| 21 | 22 | #builtin ln || exit 1 # broken Debian ksh93 package config, grrr... | |
| 22 | 23 | builtin mkdir || exit 1 | |
| 23 | 24 | builtin printf || exit 1 | |
| 24 | 25 | #builtin rm || exit 1 # broken Debian ksh93 package config, grrr... | |
| 25 | 26 | builtin wc || exit 1 | |
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | 29 | # clean data from previous run | |
| 29 | 30 | rm -Rf gitsvnclone1 svnstore convertedsrc compare_oldnew | |
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | 33 | # squish locale settings, we need the POSIX defaults | |
| 33 | 34 | if [[ "${!LC_*}" != '' ]] ; then | |
| 34 | 35 | unset "${!LC_@}" | |
| 35 | 36 | fi | |
| 36 | 37 | unset LANG | |
| 37 | 38 | export LANG='POSIX' | |
| 38 | 39 | ||
| 39 | 40 | typeset -r infile='rauch_svndump20200128.svndump.bz2' | |
| 40 | 41 | ||
| 41 | 42 | typeset -r basedir="$PWD" | |
| 42 | 43 | compound svninfo | |
| 43 | 44 | ||
| 45 | + | typeset i dummy | |
| 44 | 47 | [[ ! -f "${infile}" ]] && exit 1 | |
| 45 | 48 | [[ ! -r "${infile}" ]] && exit 1 | |
| 46 | 49 | ||
| 47 | 50 | # create empty SVN repository | |
| 48 | 51 | svnadmin create svnstore | |
| 49 | 52 | # add dummy hook to allow property changes for "svnrdump load" | |
| 50 | 53 | printf '#!/bin/sh\nexit 0\n' >'svnstore/hooks/pre-revprop-change' | |
| 51 | 54 | chmod a+x 'svnstore/hooks/pre-revprop-change' | |
| 52 | 55 | ||
| 53 | 56 | bunzip2 -c <"${infile}" | svnrdump load "file://$basedir/svnstore/" | |
| 54 | 57 | ||
| 55 | 58 | # get HEAD revision (number) from svn repository | |
| 56 | 59 | integer svninfo.revision | |
| 57 | 60 | svninfo.cmdout="$(svn info "file://$basedir/svnstore")" | |
| 58 | 61 | dummy="${svninfo.cmdout/~(E)Revision:[[:space:]]+([[:digit:]]+)/ }" | |
| 59 | 62 | (( svninfo.revision=.sh.match[1] )) | |
| 60 | 63 | ||
| 61 | 64 | printf '# Subversion info:\n' | |
| 62 | 65 | print -v svninfo | |
| 63 | 66 | ||
| 64 | 67 | mkdir 'gitsvnclone1' | |
| 65 | 68 | cd 'gitsvnclone1' | |
| 66 | 69 | git svn clone "file://$basedir/svnstore" | |
| 67 | 70 | ||
| 68 | 71 | ls -lad 'svnstore/trunk/projekt/ptxdist/' | |
| 69 | 72 | ||
| 70 | 73 | ||
| 71 | - | cd 'svnstore/trunk/projekt/ptxdist/' | |
| 72 | 74 | ||
| 75 | + | # | |
| 73 | 76 | # extract all patches from git repository previously | |
| 74 | 77 | # stored by "git svn" there | |
| 78 | + | # | |
| 75 | 80 | git format-patch -$(( svninfo.revision+1 )) | |
| 76 | 81 | ||
| 77 | 82 | # remove patch files which are empty | |
| 78 | - | (for i in *.patch ; do if [[ ! -s "$i" ]] ; then rm -- "$i" ; fi ; done) | |
| 83 | + | for i in *.patch ; do if [[ ! -s "$i" ]] ; then rm -- "$i" ; fi ; done | |
| 79 | 84 | ||
| 80 | 85 | # list remaining patches | |
| 81 | 86 | IFS=$'\n' ; typeset -a patchlist=( $(ls -1ad $PWD/*.patch ) ) | |
| 82 | 87 | printf '\n#### Patches:\n' | |
| 83 | 88 | printf '%q\n' "${patchlist[@]}" | |
| 84 | 89 | printf '\n#### Number of patches: %d\n' "$(wc -l <<<"$patchlist")" | |
| 85 | 90 | ||
| 91 | + | ||
| 86 | 92 | cd "$basedir" | |
| 87 | 93 | mkdir 'convertedsrc' | |
| 88 | 94 | cd 'convertedsrc' | |
| 89 | 95 | ||
| 90 | 96 | printf '%s\n' "${patchlist[@]}" | sort -n | while read i ; do | |
| 91 | 97 | # 1. use "|| true" to circumvent -o errexit for now since | |
| 92 | 98 | # GNU patch does not support GIT binary patches and returns | |
| 93 | 99 | # a non-0 exit code for such patches | |
| 94 | 100 | # 2. use --force to avoid interactive queries about GIT binary patches | |
| 95 | 101 | patch -p3 --force <"$i" || true | |
| 96 | 102 | done | |
| 97 | 103 | ||
| 104 | + | ||
| 98 | 105 | cd "$basedir" | |
| 99 | 106 | mkdir 'compare_oldnew' | |
| 100 | 107 | cd 'compare_oldnew' | |
| 101 | 108 | (mkdir 'old' && cd 'old' && svn export "file://$basedir/svnstore/trunk/projekt/ptxdist") | |
| 102 | - | mkdir new | |
| 109 | + | mkdir 'new' ; ln -s '../../convertedsrc/ptxdist' 'new/.' | |
| 104 | 110 | ||
| 108 | 111 | ||
| 109 | - | ||
| 112 | + | # | |
| 110 | - | printf '# DONE!\n' | |
| 113 | + | # Check whether the sources differ | |
| 111 | - | exit 0 | |
| 114 | + | # We exclude binaries here because GNU patch doesn't support GIT binary | |
| 112 | - | # EOF. | |
| 115 | + | # patches and the previous state skipped them completely. Instead, we let | |
| 113 | - | ||
| 116 | + | # grep(1) filter complains of diff(1) that those files only exists in | |
| 114 | - | ||
| 117 | + | # compare_oldnew/old/ptxdist/ but not in compare_oldnew/new/ptxdist/ | |
| 115 | - | ||
| 118 | + | # | |
| 116 | - | ||
| 119 | + | cd "$basedir" | |
| 117 | - | ||
| 120 | + | (diff -r -u 'compare_oldnew/old/ptxdist/' 'compare_oldnew/new/ptxdist/' || true) 2>&1 | | |
| 118 | - | ||
| 121 | + | grep -E -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))$' | |
| 119 | 122 | ||
| 120 | 123 | ||
| 121 | - | ||
| 124 | + | printf '# DONE!\n' | |
| 122 | - | ||
| 125 | + | exit 0 | |
| 123 | - | ||
| 126 | + | # EOF. | |
| 124 | 127 |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
eckelmann.kpaste.net RSS