AutoPkg Repo List Fiddling

Here’s a little one for you. I needed to keep the recipe repositories in sync across two machines.

AutoPkg will happily give you a repo-list- here’s part of mine:

autopkg repo-list
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.48kRAM-recipes (
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.HobbitHardcase-recipes (
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.MichalMMac-recipes (
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.adobe-ccp-recipes (
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.arubdesu-recipes (
/Users/Anthony.WILLIAMS/Library/AutoPkg/RecipeRepos/com.github.autopkg.aysiu-recipes (

Unfortunately that isn’t in a form you can feed to AutoPkg’s repo-add command. We need something like sed to make it right. Here we go.

autopkg repo-list | sed "s#[^(]*(\([^)]*\)).*#\1#"

Now we add them on the other computer. Pipe the above into repos.txt and then:

while read -r line ; do
autopkg repo-add $line
done < repos.txt

Now if AutoPkg had an option to list the repositories in search order rather than alphabetical…

3 thoughts on “AutoPkg Repo List Fiddling

  1. Try this:

    defaults read com.github.autopkg RECIPE_REPOS | grep URL | sed ‘s|^.*URL = \”||g’ | sed ‘s|\”.*$||g’

    • Although that still doesn’t give you the search order. You’d have to do a while loop on defaults read com.github.autopkg RECIPE_SEARCH_DIRS and match the path in the RECIPE_REPOS dictionary.

      • Yes, it gives you the same result as mine. I was actually contemplating some hard core work on the repo name in RECIPE_SEARCH_DIRS to extract the URL from that but a while loop and grep might do the job better. I’ll give it some thought.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s