Created
January 9, 2011 20:42
-
-
Save wereHamster/771993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This relies on addons specifying the external dependencies in their toc file. | |
# Blizzard conveniently ignores everything after the first space in the | |
# OptionalDependency field so we can use something like this: | |
# | |
# ## OptionalDependency: FooLibrary [email protected]:you/FooLibrary.git deadbeef:Lib/ | |
# | |
# Where deadbeef:Lib/ is the tree-ish we want to extract and put into Libs/FooLibrary. | |
# | |
# git-archive which works even if the remote doens't support git-upload-archive. | |
archive () { | |
GITDIR="$(mktemp -d $TMPDIR/XXXXXXX)" | |
git clone --bare --quiet "$2" "$GITDIR" | |
git --git-dir "$GITDIR" archive --prefix="$1/" "$3" | tar -xf - | |
RET="$(git --git-dir "$GITDIR" describe --always)" | |
rm -rf "$GITDIR" | |
echo "$RET" | |
} | |
# Create a temporary directory where we'll build the package. | |
ROOT="$(mktemp -d $TMPDIR/XXXXXXX)" | |
pushd "$ROOT" | |
# The source of the addon goes into a subdirectory so that when the user | |
# extracts the package into the AddOns directory it'll just work. | |
NAME="$(archive "$1" "$2" "$3")" | |
pushd "$1" | |
# Extract all optional dependencies into Libs/ | |
cat "$1.toc" | sed -n -e '/^## OptionalDeps/ { s/## OptionalDeps: //; p; }' | \ | |
while read name source treeish; do | |
archive "Libs/$name" "$source" "$treeish" | |
done | |
# Go back to the directory where we started in | |
popd | |
popd | |
# Create the package and clean up | |
tar -cvC "$ROOT" . | xz > "$NAME.tar.xz" | |
rm -rf "$ROOT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment