pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


SVNrauch2EAGgit patch history migration script, V0.0.1
Posted by Anonymous on Mon 10th Feb 2020 17:52
raw | new post
modification of post by Anonymous (view diff)

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

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at