pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


SVNrauch2EAGgit patch history migration script, V0.0.1
Posted by Anonymous on Fri 7th Feb 2020 15:29
raw | new post
view followups (newest first): SVNrauch2EAGgit patch history migration script, V0.0.1 by Anonymous
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 ln     || exit 1 # broken Debian ksh93 package config, grrr...
  22. builtin mkdir   || exit 1
  23. builtin printf  || exit 1
  24. #builtin rm     || exit 1 # broken Debian ksh93 package config, grrr...
  25. builtin wc      || exit 1
  26.  
  27.  
  28. # clean data from previous run
  29. rm -Rf gitsvnclone1 svnstore convertedsrc compare_oldnew
  30.  
  31.  
  32. # squish locale settings, we need the POSIX defaults
  33. if [[ "${!LC_*}" != '' ]] ; then
  34.         unset "${!LC_@}"
  35. fi
  36. unset LANG
  37. export LANG='POSIX'
  38.  
  39. typeset -r infile='rauch_svndump20200128.svndump.bz2'
  40.  
  41. typeset -r basedir="$PWD"
  42. compound svninfo
  43.  
  44. [[ ! -f "${infile}" ]] && exit 1
  45. [[ ! -r "${infile}" ]] && exit 1
  46.  
  47. # create empty SVN repository
  48. svnadmin create svnstore
  49. # add dummy hook to allow property changes for "svnrdump load"
  50. printf '#!/bin/sh\nexit 0\n' >'svnstore/hooks/pre-revprop-change'
  51. chmod a+x 'svnstore/hooks/pre-revprop-change'
  52.  
  53. bunzip2 -c <"${infile}" | svnrdump load "file://$basedir/svnstore/"
  54.  
  55. # get HEAD revision (number) from svn repository
  56. integer svninfo.revision
  57. svninfo.cmdout="$(svn info "file://$basedir/svnstore")"
  58. dummy="${svninfo.cmdout/~(E)Revision:[[:space:]]+([[:digit:]]+)/ }"
  59. (( svninfo.revision=.sh.match[1] ))
  60.  
  61. printf '# Subversion info:\n'
  62. print -v svninfo
  63.  
  64. mkdir 'gitsvnclone1'
  65. cd 'gitsvnclone1'
  66. git svn clone "file://$basedir/svnstore"
  67.  
  68. ls -lad 'svnstore/trunk/projekt/ptxdist/'
  69.  
  70.  
  71. cd 'svnstore/trunk/projekt/ptxdist/'
  72.  
  73. # extract all patches from git repository previously
  74. # stored by "git svn" there
  75. git format-patch -$(( svninfo.revision+1 ))
  76.  
  77. # remove patch files which are empty
  78. (for i in *.patch ; do if [[ ! -s "$i" ]] ; then rm -- "$i" ; fi ; done)
  79.  
  80. # list remaining patches
  81. IFS=$'\n' ; typeset -a patchlist=( $(ls -1ad $PWD/*.patch ) )
  82. printf '\n#### Patches:\n'
  83. printf '%q\n' "${patchlist[@]}"
  84. printf '\n#### Number of patches: %d\n' "$(wc -l <<<"$patchlist")"
  85.  
  86. cd "$basedir"
  87. mkdir 'convertedsrc'
  88. cd 'convertedsrc'
  89.  
  90. printf '%s\n' "${patchlist[@]}" | sort -n | while read i ; do
  91.         # 1. use "|| true" to circumvent -o errexit for now since
  92.         # GNU patch does not support GIT binary patches and returns
  93.         # a non-0 exit code for such patches
  94.         # 2. use --force to avoid interactive queries about binary patches
  95.         patch -p3 --force <"$i" || true
  96. done
  97.  
  98. cd "$basedir"
  99. mkdir 'compare_oldnew'
  100. cd 'compare_oldnew'
  101. (mkdir 'old' && cd 'old' && svn export "file://$basedir/svnstore/trunk/projekt/ptxdist")
  102. mkdir new
  103. ln -s '../../convertedsrc/ptxdist' 'new/.'
  104.  
  105. cd "$basedir"
  106. (diff -r -u 'compare_oldnew/old/ptxdist/' 'compare_oldnew/new/ptxdist/' || true) 2>&1 |
  107.         egrep -v '^Only in .+(barebox-image|bareboxenv|libEMC|lin|\.(app|png|jpg|jpeg|gz|bin|iop|pdf|so\..+|crc|vtg))$'
  108.  
  109.  
  110. printf '# DONE!\n'
  111. exit 0
  112. # 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