Skip to content

Instantly share code, notes, and snippets.

@moto-timo
Last active December 2, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moto-timo/ab70ab96ddbaf5fd1226bd21dbbfec9b to your computer and use it in GitHub Desktop.
Save moto-timo/ab70ab96ddbaf5fd1226bd21dbbfec9b to your computer and use it in GitHub Desktop.
Use git-filter-repo to create meta-python2 layer with the history from meta-openembedded/meta-python
# 1. Start from a clean state
# 2. Clone bare meta-openembedded (local copy can be used to avoid cloning from upstream)
# 3. Clone local working copy of meta-openembedded-orig
# 4. Initialialize pristine meta-python2 repository
# 5. Copy git history from meta-openembedded-orig to meta-python2
# 6. Add original commit hash to all commits and add signed-off-by
# 7. Replace 'meta-python' string with 'meta-python2'
# 8. Fix cases where 'meta-python23' string was created
# 9. Update the 'home of python modules' string in README
# 10. Drop all python3-* files
# 11. Strip all directories except meta-python
# 12. Make the contents of meta-python become the root of meta-python2 repo
rm -rf meta-openembedded.git &&
rm -rf meta-python2 &&
rm -rf meta-openembedded-orig &&
git clone --bare git://git.openembedded.org/meta-openembedded.git meta-openembedded.git &&
git clone meta-openembedded.git meta-openembedded-orig &&
git init meta-python2 &&
git filter-repo --source meta-openembedded-orig --target meta-python2 &&
cd meta-python2 &&
git filter-repo \
--commit-callback "
user_name = b'Tim Orling'
user_email = b'ticotimo@gmail.com'
trailer = b'Signed-off-by: %s <%s>' % (user_name, user_email)
first_match = False
new_commit_message = b''
for line in commit.message.splitlines():
if re.match(b'Signed-off-by:', line) and not first_match:
first_match = True
new_commit_message += b'(From meta-openembedded commit: %s)\n\n' % (commit.original_id)
new_commit_message += line + b'\n'
else:
new_commit_message += line + b'\n'
new_commit_message += trailer
commit.message = new_commit_message" \
--blob-callback "
blob.data = blob.data.replace(b'meta-python', b'meta-python2')
blob.data = blob.data.replace(b'meta-python23', b'meta-python3')
blob.data = blob.data.replace(b'home of python modules', b'home of legacy python2 modules')
" \
--filename-callback "
if b'python3-' in filename:
return None
else:
return filename" &&
git filter-repo --path meta-python &&
git filter-repo --subdirectory-filter meta-python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment