Browse files

Make packaging the git repo optional

New behavior: `./dist.sh` prepares tarballs of sagenb and its
dependencies in dist/ , and `./dist.sh -g` additionally places an
optimized copy of the git repository in dist/
  • Loading branch information...
1 parent 5c5802a commit 3afe890a07462ac42dbd12ba6bb23d918ce237fc @kini kini committed Jun 15, 2012
Showing with 35 additions and 19 deletions.
  1. +2 −1 README.rst
  2. +33 −18 dist.sh
View
3 README.rst
@@ -95,7 +95,8 @@ make sense in some cases.
* Then, update the version in ``setup.py`` and commit this change.
- * Run ``dist.sh``
+ * Run ``dist.sh``, optionally with a ``-g`` argument to package
+ the git repo too.
* Copy the newly generated ``dist/`` directory from the sagenb
repo to the SPKG's root directory and rename it ``src/``
View
51 dist.sh
@@ -3,16 +3,29 @@
# This script should be run when creating a new SPKG for shipping sagenb
# with Sage. For more complete instructions on how to generate a new
# SPKG, read the SPKG.txt file in the current SPKG.
+#
+# Usage: dist.sh [-g]
+#
+# -g Also package the git repository
die () {
echo >&2 "$@"
exit 1
}
+while getopts ":g" opt; do
+ case $opt in
+ g) INSTALL_REPO=1 ;;
+ *) die "Invalid option!"
+ esac
+done
+
cd ${0%/*}
-git diff --quiet && git diff --cached --quiet ||
- die "Uncommitted changes in sagenb - please commit, stash, or discard"
+if [ -n "$INSTALL_REPO" ]; then
+ git diff --quiet && git diff --cached --quiet ||
+ die "Uncommitted changes in sagenb - please commit, stash, or discard"
+fi
rm -rf dist
mkdir -p dist
@@ -23,21 +36,23 @@ python util/fetch_deps.py dist || die "Couldn't fetch all (sub)dependencies"
echo "Creating source tarball of sagenb itself in dist/"
python setup.py sdist > sdist.log || die "Couldn't make sagenb source tarball"
-echo "Sanitizing sagenb git repo (with backup)"
-mv .git .git-backup
-git init
-git fetch .git-backup
-git remote add sagemath https://github.com/sagemath/sagenb
-git branch -f master FETCH_HEAD
-git remote update sagemath
-git branch --set-upstream master sagemath/master
-git reset --mixed
-git gc --aggressive --prune=0
-
-echo "Moving sanitized sagenb git repo to dist/"
-mv .git dist/sagenb.git
-
-echo "Restoring backup of git repo"
-mv .git-backup .git
+if [ -n "$INSTALL_REPO" ]; then
+ echo "Sanitizing sagenb git repo (with backup)"
+ mv .git .git-backup
+ git init
+ git fetch .git-backup
+ git remote add sagemath https://github.com/sagemath/sagenb
+ git branch -f master FETCH_HEAD
+ git remote update sagemath
+ git branch --set-upstream master sagemath/master
+ git reset --mixed
+ git gc --aggressive --prune=0
+
+ echo "Moving sanitized sagenb git repo to dist/"
+ mv .git dist/sagenb.git
+
+ echo "Restoring backup of git repo"
+ mv .git-backup .git
+fi
echo "Done!"

0 comments on commit 3afe890

Please sign in to comment.