archlinux / asp

Arch Build Source Management Tool
MIT License
294 stars 34 forks source link

Converting to AUR-like git repos #33

Closed sshaikh closed 11 months ago

sshaikh commented 3 years ago

This isn't a bug and perhaps not even a feature request, but I think it may be useful in the context of what asp brings to those hacking on official packages, and my hope that this is the right place to document it.

I'm trying to establish a workflow to deal with package updates, particularly those built from custom PKGBUILDs. The AUR lends itself to this - you can just fork the git repo, make your changes there and merge in any updates to the PKGBUILDs as they happen.

The official PKGBUILDs don't lend themselves to this as easily, mainly because they all live in a single repo. asp helps with this by essentially checking out locally those branches mapped to packages. However the layout (trunk and repo folders) as well as the location (local) make it difficult to integrate into the same workflow as would be used (by me) for AUR packages. I feel that the AUR layout works well (and hear grumblings about it being where the official repo of PKGBUILDs is heading), so I've tried to figure out a way to reproduce that layout, so that I can fork off of it like I do with the AUR. This is what I've come up with.

First to start:

#clone the first package via its branch to save downloading the whole repo
git clone -b packages/termite --single-branch https://github.com/archlinux/svntogit-community.git
cd svntogit-community
#should already be here but just in case
git checkout packages/termite
#use a magic command to create a new branch with just the contents of trunk
git subtree split -P trunk/ -b trunks/termite
#push it somewhere, rename the branch if required
git push http://git-server/arch-packages/termite.git trunks/termite:master

Later to update:

git checkout packages/termite
# pull should fast forward
git pull 
#the same magic command will update the existing branch
git subtree split -P trunk/ -b trunks/termite
#push it to the same place.
git push http://git-server/arch-packages/termite.git trunks/termite:master

To add further packages:

#register the new package and fetch it
git remote set-branches --add origin packages/fish
git fetch
#check it out
git checkout packages/fish
#then the same magic command
git subtree split -P trunk/ -b trunks/fish
#and the same push
git push http://git-server/arch-packages/fish.git trunks/fish:master

This obviously doesn't use asp as it's doing something different, but should be easily scriptable and importantly remain idempotent. I'm not sure if asp itself would be the right tool to offer similar subtree functionality, but it would be cool to have something that abstracts away some of the internals of the svntogit repo.